diff options
author | Lang Hames <lhames@gmail.com> | 2014-05-19 19:21:25 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2014-05-19 19:21:25 +0000 |
commit | b96f71fed63641165462e05cf3ecf5012122afa1 (patch) | |
tree | 1e5cdd4b0f8f5b9022ddf237bdbc34fb71ea9491 /lib/ExecutionEngine | |
parent | 8ad418b61b53a619bf9dd954c5399b69b7d78a96 (diff) | |
download | llvm-b96f71fed63641165462e05cf3ecf5012122afa1.tar.gz llvm-b96f71fed63641165462e05cf3ecf5012122afa1.tar.bz2 llvm-b96f71fed63641165462e05cf3ecf5012122afa1.tar.xz |
[RuntimeDyld] Fix x86-64 MachO GOT relocation handling.
For GOT relocations the addend should modify the offset to the
GOT entry, not the value of the entry itself. Teach RuntimeDyldMachO
to do The Right Thing here.
Fixes <rdar://problem/16961886>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209154 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r-- | lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 66456a990b..30529808d0 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -573,6 +573,10 @@ relocation_iterator RuntimeDyldMachO::processRelocationRef( RelType == MachO::X86_64_RELOC_GOT_LOAD)) { assert(IsPCRel); assert(Size == 2); + + // FIXME: Teach the generic code above not to prematurely conflate + // relocation addends and symbol offsets. + Value.Addend -= Addend; StubMap::const_iterator i = Stubs.find(Value); uint8_t *Addr; if (i != Stubs.end()) { @@ -581,7 +585,8 @@ relocation_iterator RuntimeDyldMachO::processRelocationRef( Stubs[Value] = Section.StubOffset; uint8_t *GOTEntry = Section.Address + Section.StubOffset; RelocationEntry GOTRE(SectionID, Section.StubOffset, - MachO::X86_64_RELOC_UNSIGNED, 0, false, 3); + MachO::X86_64_RELOC_UNSIGNED, Value.Addend, false, + 3); if (Value.SymbolName) addRelocationForSymbol(GOTRE, Value.SymbolName); else @@ -590,7 +595,7 @@ relocation_iterator RuntimeDyldMachO::processRelocationRef( Addr = GOTEntry; } RelocationEntry TargetRE(SectionID, Offset, - MachO::X86_64_RELOC_UNSIGNED, Value.Addend, true, + MachO::X86_64_RELOC_UNSIGNED, Addend, true, 2); resolveRelocation(TargetRE, (uint64_t)Addr); } else if (Arch == Triple::arm && (RelType & 0xf) == MachO::ARM_RELOC_BR24) { |