[PATCH] D48058: Handle R_X86_64_GOTOFF64.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 11 16:56:45 PDT 2018


ruiu created this revision.
ruiu added a reviewer: MaskRay.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

R_X86_64_GOTOFF64 is a relocation type to set to a distance betwween
a symbol and the beginning of the .got section. Previously, we always
created a dynamic relocation for the relocation type even though it
can be resolved at link-time.

Creating a dynamic relocation for R_X86_64_GOTOFF64 caused link failure
for some programs that do have a relocation of the type in a .text
section, as text relocations are prohibited in most configurations.


https://reviews.llvm.org/D48058

Files:
  lld/ELF/Arch/X86_64.cpp
  lld/test/ELF/x86-64-reloc-gotoff64.s


Index: lld/test/ELF/x86-64-reloc-gotoff64.s
===================================================================
--- /dev/null
+++ lld/test/ELF/x86-64-reloc-gotoff64.s
@@ -0,0 +1,17 @@
+// REQUIRES: x86
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld -shared -o %t.so %t.o
+// RUN: llvm-readelf -sections %t.so | FileCheck %s
+// RUN: llvm-objdump -d %t.so | FileCheck -check-prefix=DISASM %s
+
+// CHECK: .dynamic DYNAMIC  0000000000002000 002000
+// CHECK: .got     PROGBITS 0000000000002070 002070
+
+// DISASM: 1000: 48 ba 90 ff ff ff ff ff ff ff   movabsq $-112, %rdx
+
+.global _start
+.weak _DYNAMIC
+.hidden _DYNAMIC
+_start:
+  movabsq $_DYNAMIC at GOTOFF, %rdx
Index: lld/ELF/Arch/X86_64.cpp
===================================================================
--- lld/ELF/Arch/X86_64.cpp
+++ lld/ELF/Arch/X86_64.cpp
@@ -105,6 +105,8 @@
   case R_X86_64_REX_GOTPCRELX:
   case R_X86_64_GOTTPOFF:
     return R_GOT_PC;
+  case R_X86_64_GOTOFF64:
+    return R_GOTREL;
   case R_X86_64_NONE:
     return R_NONE;
   default:
@@ -319,6 +321,7 @@
   case R_X86_64_PC64:
   case R_X86_64_SIZE64:
   case R_X86_64_GOT64:
+  case R_X86_64_GOTOFF64:
     write64le(Loc, Val);
     break;
   default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48058.150868.patch
Type: text/x-patch
Size: 1232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180611/6aec15fd/attachment.bin>


More information about the llvm-commits mailing list