[PATCH] D47098: [ELF] Support R_X86_64_GOTPC{32,64}

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 12 13:23:12 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334532: [ELF] Support R_X86_64_GOTPC{32,64} (authored by MaskRay, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D47098

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


Index: lld/trunk/test/ELF/x86-64-reloc-got.s
===================================================================
--- lld/trunk/test/ELF/x86-64-reloc-got.s
+++ lld/trunk/test/ELF/x86-64-reloc-got.s
@@ -0,0 +1,20 @@
+// REQUIRES: x86
+// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+// RUN: ld.lld %t.o -shared -o %t.so
+// RUN: llvm-readelf -s %t.so | FileCheck %s -check-prefix=SECTION
+// RUN: llvm-objdump -d %t.so | FileCheck %s
+
+// SECTION: .got PROGBITS 0000000000003070 003070 000000
+
+// 0x3070 (.got end) - 0x1007 = 8297
+// CHECK: gotpc32:
+// CHECK-NEXT: 1000: {{.*}} leaq 8297(%rip), %r15
+.global gotpc32
+gotpc32:
+  leaq _GLOBAL_OFFSET_TABLE_(%rip), %r15
+
+// CHECK: gotpc64:
+// CHECK-NEXT: 1007: {{.*}} movabsq $8297, %r11
+.global gotpc64
+gotpc64:
+  movabsq $_GLOBAL_OFFSET_TABLE_-., %r11
Index: lld/trunk/ELF/Arch/X86_64.cpp
===================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp
+++ lld/trunk/ELF/Arch/X86_64.cpp
@@ -105,6 +105,9 @@
   case R_X86_64_REX_GOTPCRELX:
   case R_X86_64_GOTTPOFF:
     return R_GOT_PC;
+  case R_X86_64_GOTPC32:
+  case R_X86_64_GOTPC64:
+    return R_GOTONLY_PC_FROM_END;
   case R_X86_64_NONE:
     return R_NONE;
   default:
@@ -300,6 +303,7 @@
   case R_X86_64_32S:
   case R_X86_64_TPOFF32:
   case R_X86_64_GOT32:
+  case R_X86_64_GOTPC32:
   case R_X86_64_GOTPCREL:
   case R_X86_64_GOTPCRELX:
   case R_X86_64_REX_GOTPCRELX:
@@ -319,6 +323,7 @@
   case R_X86_64_PC64:
   case R_X86_64_SIZE64:
   case R_X86_64_GOT64:
+  case R_X86_64_GOTPC64:
     write64le(Loc, Val);
     break;
   default:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47098.151011.patch
Type: text/x-patch
Size: 1619 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180612/fb343817/attachment.bin>


More information about the llvm-commits mailing list