Index: ELF/Target.cpp =================================================================== --- ELF/Target.cpp +++ ELF/Target.cpp @@ -807,6 +807,8 @@ switch (Type) { default: return false; + case R_X86_64_GOTTPOFF: + case R_X86_64_TPOFF32: case R_X86_64_DTPOFF32: case R_X86_64_DTPOFF64: case R_X86_64_PC8: Index: test/ELF/tls-initial-exec-local.s =================================================================== --- test/ELF/tls-initial-exec-local.s +++ /dev/null @@ -1,36 +0,0 @@ -// REQUIRES: x86 -// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t -// RUN: llvm-readobj -r -s %t | FileCheck %s -// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s - -// CHECK: Name: .got -// CHECK-NEXT: Type: SHT_PROGBITS -// CHECK-NEXT: Flags [ -// CHECK-NEXT: SHF_ALLOC (0x2) -// CHECK-NEXT: SHF_WRITE (0x1) -// CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x2090 - -// CHECK: Relocations [ -// CHECK-NEXT: Section ({{.*}}) .rela.dyn { -// CHECK-NEXT: 0x2090 R_X86_64_TPOFF64 - 0x0 -// CHECK-NEXT: 0x2098 R_X86_64_TPOFF64 - 0x4 -// CHECK-NEXT: } -// CHECK-NEXT: ] - -// 0x1007 + 4233 = 0x2090 -// 0x100e + 4234 = 0x2098 -// DISASM: Disassembly of section .text: -// DISASM-NEXT: .text: -// DISASM-NEXT: 1000: {{.*}} addq 4233(%rip), %rax -// DISASM-NEXT: 1007: {{.*}} addq 4234(%rip), %rax - - addq foo@GOTTPOFF(%rip), %rax - addq bar@GOTTPOFF(%rip), %rax - - .section .tbss,"awT",@nobits -foo: - .long 0 -bar: - .long 0 Index: test/ELF/x86-64-tls-pie.s =================================================================== --- /dev/null +++ test/ELF/x86-64-tls-pie.s @@ -0,0 +1,26 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-cloudabi %s -o %t1.o +# RUN: ld.lld -pie %t1.o -o %t +# RUN: llvm-readobj -r %t | FileCheck %s + +# Bug 27174: R_X86_64_TPOFF32 and R_X86_64_GOTTPOFF relocations should +# be eliminated when building a PIE executable, as the static TLS layout +# is fixed. +# +# CHECK: Relocations [ +# CHECK-NEXT: ] + + .globl _start +_start: + movq %fs:0, %rax + movl $3, i@TPOFF(%rax) + + movq %fs:0, %rdx + movq i@GOTTPOFF(%rip), %rcx + movl $3, (%rdx,%rcx) + + .section .tbss.i,"awT",@nobits + .globl i +i: + .long 0 + .size i, 4