summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-10-04 15:59:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-10-04 15:59:01 +0000
commitda0e3d07b2c849bd398ab0becf6e9fd02e82c15a (patch)
tree5bcc5988dd6da645e0e62533983e0f4932d4f41a /llvm/lib
parent25a3ada060ed869d8061116de8c371c7e348608e (diff)
downloadbcm5719-llvm-da0e3d07b2c849bd398ab0becf6e9fd02e82c15a.tar.gz
bcm5719-llvm-da0e3d07b2c849bd398ab0becf6e9fd02e82c15a.zip
Include the section address in the computation of the relocation.
llvm-svn: 115509
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index cc6d51efb0b..7e0ce7d711e 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -539,7 +539,14 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
const MCSymbol &SymbolB = RefB->getSymbol();
MCSymbolData &SDB = Asm.getSymbolData(SymbolB);
IsPCRel = true;
- Value += Layout.getFragmentOffset(Fragment) + Fixup.getOffset() - Layout.getSymbolAddress(&SDB);
+ MCSectionData *Sec = Fragment->getParent();
+
+ // Offset of the symbol in the section
+ int64_t a = Layout.getSymbolAddress(&SDB) - Layout.getSectionAddress(Sec);
+
+ // Ofeset of the relocation in the section
+ int64_t b = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
+ Value += b - a;
}
// Check that this case has already been fully resolved before we get
OpenPOWER on IntegriCloud