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 | 1fcbc0850068faa55c6712dee4eb2d581cb452d4 (patch) | |
tree | 7b386a3f83d94c2753b1cc98e53e100cca8f0860 /llvm | |
parent | c2ec8c5281d1feb7dd447d413a35bbd4d87cc4b6 (diff) | |
download | bcm5719-llvm-1fcbc0850068faa55c6712dee4eb2d581cb452d4.tar.gz bcm5719-llvm-1fcbc0850068faa55c6712dee4eb2d581cb452d4.zip |
[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>.
llvm-svn: 209154
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp | 9 | ||||
-rw-r--r-- | llvm/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o | bin | 0 -> 704 bytes | |||
-rw-r--r-- | llvm/test/ExecutionEngine/RuntimeDyld/macho_relocations.test (renamed from llvm/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test) | 1 |
3 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 66456a990b7..30529808d0d 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/llvm/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) { diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o b/llvm/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o Binary files differnew file mode 100644 index 00000000000..2013a0e81de --- /dev/null +++ b/llvm/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o diff --git a/llvm/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test b/llvm/test/ExecutionEngine/RuntimeDyld/macho_relocations.test index 92e4dd793cc..d3407352ce7 100644 --- a/llvm/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test +++ b/llvm/test/ExecutionEngine/RuntimeDyld/macho_relocations.test @@ -1 +1,2 @@ RUN: llvm-rtdyld -printline %p/Inputs/arm_secdiff_reloc.o +RUN: llvm-rtdyld %p/Inputs/x86_64_macho_pic_globals_GOT.o |