1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-opt-gdie.s -o %tso.o
4// RUN: ld.lld -shared %tso.o -soname=so -o %t.so
5// RUN: ld.lld %t.o %t.so -o %t1
6// RUN: llvm-readelf -S %t1 | FileCheck --check-prefix=SEC --implicit-check-not=.plt %s
7// RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=RELOC %s
8// RUN: llvm-objdump -d --no-show-raw-insn %t1 | FileCheck --check-prefix=DISASM %s
9
10// SEC: .got PROGBITS 00000000002023a8 0003a8 000010 00 WA 0 0 8
11
12//RELOC:      Relocations [
13//RELOC-NEXT:   Section (5) .rela.dyn {
14//RELOC-NEXT:     0x2023A8 R_X86_64_TPOFF64 tlsshared0 0x0
15//RELOC-NEXT:     0x2023B0 R_X86_64_TPOFF64 tlsshared1 0x0
16//RELOC-NEXT:   }
17//RELOC-NEXT: ]
18
19// 0x2023A8 - (2012d1+7) = 4304
20// 0x2023B0 - (2012e1+7) = 4296
21// DISASM:      Disassembly of section .text:
22// DISASM-EMPTY:
23// DISASM-NEXT: <_start>:
24// DISASM-NEXT:               movq %fs:0, %rax
25// DISASM-NEXT: 2012d1:       addq 4304(%rip), %rax
26// DISASM-NEXT:               movq %fs:0, %rax
27// DISASM-NEXT: 2012e1:       addq 4296(%rip), %rax
28
29.section .text
30.globl _start
31_start:
32 .byte 0x66
33 leaq tlsshared0@tlsgd(%rip),%rdi
34 .word 0x6666
35 rex64
36 call __tls_get_addr@plt
37 .byte 0x66
38 leaq tlsshared1@tlsgd(%rip),%rdi
39 .word 0x6666
40 rex64
41 call __tls_get_addr@plt
42