1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o 3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-got.s -o %t2.o 4// RUN: ld.lld -shared %t2.o -soname=so -o %t2.so 5// RUN: ld.lld -e main %t1.o %t2.so -o %t3 6// RUN: llvm-readobj -S -r %t3 | FileCheck %s 7// RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=DISASM %s 8 9// CHECK: Section { 10// CHECK: Index: 9 11// CHECK-NEXT: Name: .got 12// CHECK-NEXT: Type: SHT_PROGBITS 13// CHECK-NEXT: Flags [ 14// CHECK-NEXT: SHF_ALLOC 15// CHECK-NEXT: SHF_WRITE 16// CHECK-NEXT: ] 17// CHECK-NEXT: Address: [[ADDR:.*]] 18// CHECK-NEXT: Offset: 0x3C0 19// CHECK-NEXT: Size: 16 20// CHECK-NEXT: Link: 0 21// CHECK-NEXT: Info: 0 22// CHECK-NEXT: AddressAlignment: 8 23// CHECK-NEXT: EntrySize: 0 24// CHECK-NEXT: } 25 26// CHECK: Relocations [ 27// CHECK-NEXT: Section (5) .rela.dyn { 28// CHECK-NEXT: 0x2023C8 R_X86_64_TPOFF64 tls0 0x0 29// CHECK-NEXT: [[ADDR]] R_X86_64_TPOFF64 tls1 0x0 30// CHECK-NEXT: } 31// CHECK-NEXT: ] 32 33// 0x2012d0 + 4329 + 7 = 0x2023C0 34// 0x2012dA + 4327 + 7 = 0x2023C8 35// 0x2012e4 + 4317 + 7 = 0x2023C8 36// DISASM: Disassembly of section .text: 37// DISASM-EMPTY: 38// DISASM-NEXT: <main>: 39// DISASM-NEXT: 2012d0: {{.*}} movq 4329(%rip), %rax 40// DISASM-NEXT: 2012d7: {{.*}} movl %fs:(%rax), %eax 41// DISASM-NEXT: 2012da: {{.*}} movq 4327(%rip), %rax 42// DISASM-NEXT: 2012e1: {{.*}} movl %fs:(%rax), %eax 43// DISASM-NEXT: 2012e4: {{.*}} movq 4317(%rip), %rax 44// DISASM-NEXT: 2012eb: {{.*}} movl %fs:(%rax), %eax 45// DISASM-NEXT: 2012ee: {{.*}} retq 46 47.section .tdata,"awT",@progbits 48 49.text 50 .globl main 51 .align 16, 0x90 52 .type main,@function 53main: 54 movq tls1@GOTTPOFF(%rip), %rax 55 movl %fs:0(%rax), %eax 56 movq tls0@GOTTPOFF(%rip), %rax 57 movl %fs:0(%rax), %eax 58 movq tls0@GOTTPOFF(%rip), %rax 59 movl %fs:0(%rax), %eax 60 ret 61