Optimistically ignore scattered relocations in MachO in RuntimeDyld. This
authorLang Hames <lhames@gmail.com>
Fri, 9 Aug 2013 00:57:01 +0000 (00:57 +0000)
committerLang Hames <lhames@gmail.com>
Fri, 9 Aug 2013 00:57:01 +0000 (00:57 +0000)
un-breaks simple use cases while I work on more general support.

<rdar://problem/14487667>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188044 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
test/ExecutionEngine/RuntimeDyld/Inputs/arm_secdiff_reloc.o [new file with mode: 0644]
test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test [new file with mode: 0644]
test/ExecutionEngine/RuntimeDyld/lit.local.cfg [new file with mode: 0644]

index 0384b322624dec1bc8ccbc2e49399c0bf21e00b8..5d5ff3a2c41a9898d6f40bb186feebe3792773c0 100644 (file)
@@ -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 (file)
index 0000000..5392266
Binary files /dev/null and b/test/ExecutionEngine/RuntimeDyld/Inputs/arm_secdiff_reloc.o differ
diff --git a/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test b/test/ExecutionEngine/RuntimeDyld/arm_secdiff_reloc.test
new file mode 100644 (file)
index 0000000..92e4dd7
--- /dev/null
@@ -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 (file)
index 0000000..df9b335
--- /dev/null
@@ -0,0 +1 @@
+config.suffixes = ['.test']