OSDN Git Service

[RuntimeDyldELF] Handle GOTPCRELX/REX_GOTPCRELX.
authorDavide Italiano <davide@freebsd.org>
Sun, 24 Apr 2016 01:36:37 +0000 (01:36 +0000)
committerDavide Italiano <davide@freebsd.org>
Sun, 24 Apr 2016 01:36:37 +0000 (01:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267309 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s [new file with mode: 0644]

index 5dc1731..c2b843e 100644 (file)
@@ -1708,7 +1708,9 @@ relocation_iterator RuntimeDyldELF::processRelocationRef(
                   Value.Offset);
         addRelocationForSection(RE, Value.SectionID);
       }
-    } else if (RelType == ELF::R_X86_64_GOTPCREL) {
+    } else if (RelType == ELF::R_X86_64_GOTPCREL ||
+               RelType == ELF::R_X86_64_GOTPCRELX ||
+               RelType == ELF::R_X86_64_REX_GOTPCRELX) {
       uint64_t GOTOffset = allocateGOTEntries(SectionID, 1);
       resolveGOTOffsetRelocation(SectionID, Offset, GOTOffset + Addend);
 
@@ -1869,6 +1871,8 @@ bool RuntimeDyldELF::relocationNeedsStub(const RelocationRef &R) const {
 
 
   case ELF::R_X86_64_GOTPCREL:
+  case ELF::R_X86_64_GOTPCRELX:
+  case ELF::R_X86_64_REX_GOTPCRELX:
   case ELF::R_X86_64_PC32:
   case ELF::R_X86_64_PC64:
   case ELF::R_X86_64_64:
diff --git a/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s b/test/ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s
new file mode 100644 (file)
index 0000000..c5a8794
--- /dev/null
@@ -0,0 +1,8 @@
+# RUN: llvm-mc -triple=x86_64-pc-linux -relocation-model=pic -filetype=obj -o %T/file.o %p/Inputs/ELF_STT_FILE_GLOBAL.s
+# RUN: llvm-mc -triple=x86_64-pc-linux -relax-relocations -relocation-model=pic -filetype=obj -o %T/relaxed.o %s
+# RUN: llvm-rtdyld -triple=x86_64-pc-linux -verify %T/file.o %T/relaxed.o
+
+# Test that RTDyldELF does not crash with 'unimplemented relocation'
+
+_main:
+    movq    foo.c@GOTPCREL(%rip), %rax