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: 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