[lld] r334532 - [ELF] Support R_X86_64_GOTPC{32,64}
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 12 13:18:41 PDT 2018
Author: maskray
Date: Tue Jun 12 13:18:41 2018
New Revision: 334532
URL: http://llvm.org/viewvc/llvm-project?rev=334532&view=rev
Log:
[ELF] Support R_X86_64_GOTPC{32,64}
Reviewers: ruiu, grimar, espindola
Subscribers: emaste, arichardson, llvm-commits
Differential Revision: https://reviews.llvm.org/D47098
Added:
lld/trunk/test/ELF/x86-64-reloc-got.s
Modified:
lld/trunk/ELF/Arch/X86_64.cpp
Modified: lld/trunk/ELF/Arch/X86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/X86_64.cpp?rev=334532&r1=334531&r2=334532&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/X86_64.cpp (original)
+++ lld/trunk/ELF/Arch/X86_64.cpp Tue Jun 12 13:18:41 2018
@@ -105,6 +105,9 @@ RelExpr X86_64<ELFT>::getRelExpr(RelType
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 @@ void X86_64<ELFT>::relocateOne(uint8_t *
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 @@ void X86_64<ELFT>::relocateOne(uint8_t *
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:
Added: lld/trunk/test/ELF/x86-64-reloc-got.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/x86-64-reloc-got.s?rev=334532&view=auto
==============================================================================
--- lld/trunk/test/ELF/x86-64-reloc-got.s (added)
+++ lld/trunk/test/ELF/x86-64-reloc-got.s Tue Jun 12 13:18:41 2018
@@ -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
More information about the llvm-commits
mailing list