[llvm] r209154 - [RuntimeDyld] Fix x86-64 MachO GOT relocation handling.
Lang Hames
lhames at gmail.com
Mon May 19 12:21:25 PDT 2014
Author: lhames
Date: Mon May 19 14:21:25 2014
New Revision: 209154
URL: http://llvm.org/viewvc/llvm-project?rev=209154&view=rev
Log:
[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>.
Added:
llvm/trunk/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o (with props)
llvm/trunk/test/ExecutionEngine/RuntimeDyld/macho_relocations.test
- copied, changed from r209145, llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test
Removed:
llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test
Modified:
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=209154&r1=209153&r2=209154&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Mon May 19 14:21:25 2014
@@ -573,6 +573,10 @@ relocation_iterator RuntimeDyldMachO::pr
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::pr
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::pr
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) {
Added: llvm/trunk/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o?rev=209154&view=auto
==============================================================================
Binary file - no diff available.
Propchange: llvm/trunk/test/ExecutionEngine/RuntimeDyld/Inputs/x86_64_macho_pic_globals_GOT.o
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Removed: llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test?rev=209153&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test (removed)
@@ -1 +0,0 @@
-RUN: llvm-rtdyld -printline %p/Inputs/arm_secdiff_reloc.o
Copied: llvm/trunk/test/ExecutionEngine/RuntimeDyld/macho_relocations.test (from r209145, llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/macho_relocations.test?p2=llvm/trunk/test/ExecutionEngine/RuntimeDyld/macho_relocations.test&p1=llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test&r1=209145&r2=209154&rev=209154&view=diff
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test (original)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/macho_relocations.test Mon May 19 14:21:25 2014
@@ -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
More information about the llvm-commits
mailing list