aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-04-30 15:40:54 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-04-30 15:40:54 +0000
commite87dadc44b1544c35e13cf48dfe167109929a944 (patch)
treeb5142993e8acc356f130f2e58f4ae1aefdbd8d17 /lib/ExecutionEngine
parent1872730c5a0d95ba9d2ed7e1e9607e86c50e9070 (diff)
Fix Addend computation for non external relocations on Macho.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
index 6054b2ab79..b3467a9ab3 100644
--- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
+++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
@@ -232,12 +232,12 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
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);
+ uint8_t *LocalAddress = Section.Address + Offset;
+ unsigned NumBytes = 1 << Size;
+ uint64_t Addend = 0;
+ memcpy(&Addend, LocalAddress, NumBytes);
+ if (isExtern) {
// Obtain the symbol name which is referenced in the relocation
SymbolRef Symbol;
RelI.getSymbol(Symbol);
@@ -260,29 +260,11 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID,
}
}
} else {
- error_code err;
- uint8_t sectionIndex = static_cast<uint8_t>(RelType & 0xFF);
- section_iterator si = Obj.begin_sections(),
- se = Obj.end_sections();
- for (uint8_t i = 1; i < sectionIndex; i++) {
- error_code err;
- si.increment(err);
- if (si == se)
- break;
- }
- assert(si != se && "No section containing relocation!");
- Value.SectionID = findOrEmitSection(Obj, *si, true, ObjSectionToID);
- Value.Addend = 0;
- // FIXME: The size and type of the relocation determines if we can
- // encode an Addend in the target location itself, and if so, how many
- // bytes we should read in order to get it. We don't yet support doing
- // that, and just assuming it's sizeof(intptr_t) is blatantly wrong.
- //Value.Addend = *(const intptr_t *)Target;
- if (Value.Addend) {
- // The MachO addend is an offset from the current section. We need it
- // to be an offset from the destination section
- Value.Addend += Section.ObjAddress - Sections[Value.SectionID].ObjAddress;
- }
+ SectionRef Sec = MachO->getRelocationSection(RE);
+ Value.SectionID = findOrEmitSection(Obj, Sec, true, ObjSectionToID);
+ uint64_t Addr;
+ Sec.getAddress(Addr);
+ Value.Addend = Addend - Addr;
}
if (Arch == Triple::arm && (RelType & 0xf) == macho::RIT_ARM_Branch24Bit) {