From: Benjamin Kramer Date: Mon, 30 Aug 2010 17:20:17 +0000 (+0000) Subject: MCELF: The value of all common symbols is the offset from the start of the section... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6cc53be24c894532b33a92069b092112ced7ad99;p=oota-llvm.git MCELF: The value of all common symbols is the offset from the start of the section. Patch by Roman Divacky. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112492 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index dd2419fa051..7f1ba81764d 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -367,6 +367,11 @@ void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD, if (Data.isCommon() && Data.isExternal()) Value = Data.getCommonAlignment(); + if (!Data.isCommon()) + if (MCFragment *FF = Data.getFragment()) + Value = Layout.getSymbolAddress(&Data) - + Layout.getSectionAddress(FF->getParent()); + ESize = Data.getSize(); if (Data.getSize()) { MCValue Res; @@ -380,12 +385,9 @@ void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD, Layout.getAssembler().getSymbolData(Res.getSymB()->getSymbol()); Size = Layout.getSymbolAddress(&A) - Layout.getSymbolAddress(&B); - Value = Layout.getSymbolAddress(&Data); } } else if (ESize->getKind() == MCExpr::Constant) { Size = static_cast(ESize)->getValue(); - MCFragment *F = Data.getFragment(); - Value = Layout.getSymbolAddress(&Data) - Layout.getSectionAddress(F->getParent()); } else { assert(0 && "Unsupported size expression"); }