summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-30 01:29:57 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-30 01:29:57 +0000
commitd00c2765aa6a53e3e15a7f13637c266deffee5a0 (patch)
tree589170995d2ad17dd1ceac9a6b5e54c167258a9f /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
parent428ef1e36882fde14f798efafd69a08bb7726d4e (diff)
downloadbcm5719-llvm-d00c2765aa6a53e3e15a7f13637c266deffee5a0.tar.gz
bcm5719-llvm-d00c2765aa6a53e3e15a7f13637c266deffee5a0.zip
Collect the Addend for external relocs.
This fixes 2013-04-04-RelocAddend.ll. We don't have a testcase for non external relocs with an Addend. I will try to write one. llvm-svn: 180767
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index ddac59fd364..6054b2ab79c 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -230,7 +230,14 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
bool isExtern = MachO->getPlainRelocationExternal(RE);
bool IsPCRel = MachO->getAnyRelocationPCRel(RE);
unsigned Size = MachO->getAnyRelocationLength(RE);
+ uint64_t Offset;
+ RelI.getOffset(Offset);
if (isExtern) {
+ uint8_t *LocalAddress = Section.Address + Offset;
+ unsigned NumBytes = 1 << Size;
+ uint64_t Addend = 0;
+ memcpy(&Addend, LocalAddress, NumBytes);
+
// Obtain the symbol name which is referenced in the relocation
SymbolRef Symbol;
RelI.getSymbol(Symbol);
@@ -240,15 +247,17 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
SymbolTableMap::const_iterator lsi = Symbols.find(TargetName.data());
if (lsi != Symbols.end()) {
Value.SectionID = lsi->second.first;
- Value.Addend = lsi->second.second;
+ Value.Addend = lsi->second.second + Addend;
} else {
// Search for the symbol in the global symbol table
SymbolTableMap::const_iterator gsi = GlobalSymbolTable.find(TargetName.data());
if (gsi != GlobalSymbolTable.end()) {
Value.SectionID = gsi->second.first;
- Value.Addend = gsi->second.second;
- } else
+ Value.Addend = gsi->second.second + Addend;
+ } else {
Value.SymbolName = TargetName.data();
+ Value.Addend = Addend;
+ }
}
} else {
error_code err;
@@ -276,8 +285,6 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
}
}
- uint64_t Offset;
- RelI.getOffset(Offset);
if (Arch == Triple::arm && (RelType & 0xf) == macho::RIT_ARM_Branch24Bit) {
// This is an ARM branch relocation, need to use a stub function.
OpenPOWER on IntegriCloud