From 623f2025a7a32de68a5ab402aa2b50ca3e3a6958 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 9 Aug 2013 00:57:01 +0000 Subject: [PATCH] Optimistically ignore scattered relocations in MachO in RuntimeDyld. This un-breaks simple use cases while I work on more general support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188044 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../RuntimeDyld/RuntimeDyldMachO.cpp | 10 ++++++++++ .../RuntimeDyld/Inputs/arm_secdiff_reloc.o | Bin 0 -> 616 bytes .../RuntimeDyld/arm_secdiff_reloc.test | 1 + test/ExecutionEngine/RuntimeDyld/lit.local.cfg | 1 + 4 files changed, 12 insertions(+) create mode 100644 test/ExecutionEngine/RuntimeDyld/Inputs/arm_secdiff_reloc.o create mode 100644 test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test create mode 100644 test/ExecutionEngine/RuntimeDyld/lit.local.cfg diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index 0384b322624..5d5ff3a2c41 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -287,6 +287,16 @@ void RuntimeDyldMachO::processRelocationRef(unsigned SectionID, macho::RelocationEntry RE = MachO->getRelocation(RelI.getRawDataRefImpl()); uint32_t RelType = MachO->getAnyRelocationType(RE); + + // FIXME: Properly handle scattered relocations. + // For now, optimistically skip these: they can often be ignored, as + // the static linker will already have applied the relocation, and it + // only needs to be reapplied if symbols move relative to one another. + // Note: This will fail horribly where the relocations *do* need to be + // applied, but that was already the case. + if (MachO->isRelocationScattered(RE)) + return; + RelocationValueRef Value; SectionEntry &Section = Sections[SectionID]; diff --git a/test/ExecutionEngine/RuntimeDyld/Inputs/arm_secdiff_reloc.o b/test/ExecutionEngine/RuntimeDyld/Inputs/arm_secdiff_reloc.o new file mode 100644 index 0000000000000000000000000000000000000000..5392266cf560cb739b8ef0d2d15932f92bf73f2f GIT binary patch literal 616 zcmX^2>+L@t1_lOhAZ7$&W+46oVkkiPJs>s~AOaK$Uy@o;0_6ay z`1lalh!6xH#DeJu8o{6fBv?R#EDQ}G3Irf#B^@0b<7h30S-Z0QtxOBoD%5g2xOD4nW-hK<>Z(Ll6eW%}kI# lfM6ojU!72XBZv=5BJ$950!jlQHdsDB&5$8J%?K#O003e`IAj0- literal 0 HcmV?d00001 diff --git a/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test b/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test new file mode 100644 index 00000000000..92e4dd793cc --- /dev/null +++ b/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test @@ -0,0 +1 @@ +RUN: llvm-rtdyld -printline %p/Inputs/arm_secdiff_reloc.o diff --git a/test/ExecutionEngine/RuntimeDyld/lit.local.cfg b/test/ExecutionEngine/RuntimeDyld/lit.local.cfg new file mode 100644 index 00000000000..df9b335dd13 --- /dev/null +++ b/test/ExecutionEngine/RuntimeDyld/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = ['.test'] -- 2.34.1