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 dd2419f..7f1ba81 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -367,6 +367,11 @@
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 @@
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<const MCConstantExpr *>(ESize)->getValue();
- MCFragment *F = Data.getFragment();
- Value = Layout.getSymbolAddress(&Data) - Layout.getSectionAddress(F->getParent());
} else {
assert(0 && "Unsupported size expression");
}