2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
3 # RUN: echo '.tbss; .globl c; c: .zero 4' | llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
4 # RUN: ld.lld -shared -soname=t1.so %t1.o -o %t1.so
6 # RUN: ld.lld -shared %t.o %t1.o -o %t.so
7 # RUN: llvm-readobj -r -x .got %t.so | FileCheck --check-prefix=GD-RELA %s
8 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck --check-prefix=GD %s
10 # RUN: ld.lld -shared %t.o %t1.o -o %t-rel.so -z rel
11 # RUN: llvm-readobj -r -x .got %t-rel.so | FileCheck --check-prefix=GD-REL %s
13 # RUN: ld.lld %t.o %t1.o -o %t
14 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
15 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
17 # RUN: ld.lld %t.o %t1.so -o %t
18 # RUN: llvm-readobj -r %t | FileCheck --check-prefix=IE-REL %s
19 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=IE %s
21 # GD-RELA: .rela.dyn {
22 # GD-RELA-NEXT: 0x23D0 R_X86_64_TLSDESC - 0xB
23 # GD-RELA-NEXT: 0x23B0 R_X86_64_TLSDESC a 0x0
24 # GD-RELA-NEXT: 0x23C0 R_X86_64_TLSDESC c 0x0
26 # GD-RELA: Hex dump of section '.got':
27 # GD-RELA-NEXT: 0x000023b0 00000000 00000000 00000000 00000000
28 # GD-RELA-NEXT: 0x000023c0 00000000 00000000 00000000 00000000
29 # GD-RELA-NEXT: 0x000023d0 00000000 00000000 00000000 00000000
32 # GD-REL-NEXT: 0x23B8 R_X86_64_TLSDESC -
33 # GD-REL-NEXT: 0x2398 R_X86_64_TLSDESC a
34 # GD-REL-NEXT: 0x23A8 R_X86_64_TLSDESC c
36 # GD-REL: Hex dump of section '.got':
37 # GD-REL-NEXT: 0x00002398 00000000 00000000 00000000 00000000
38 # GD-REL-NEXT: 0x000023a8 00000000 00000000 00000000 00000000
39 # GD-REL-NEXT: 0x000023b8 00000000 00000000 0b000000 00000000
41 ## &.rela.dyn[a]-pc = 0x23B0-0x12e7 = 4297
42 # GD: leaq 4297(%rip), %rax
43 # GD-NEXT: 12e7: callq *(%rax)
44 # GD-NEXT: movl %fs:(%rax), %eax
46 ## &.rela.dyn[b]-pc = 0x23D0-0x12f3 = 4317
47 # GD-NEXT: leaq 4317(%rip), %rcx
48 # GD-NEXT: 12f3: movq %rcx, %rax
49 # GD-NEXT: callq *(%rax)
50 # GD-NEXT: movl %fs:(%rax), %eax
52 ## &.rela.dyn[c]-pc = 0x23C0-0x1302 = 4286
53 # GD-NEXT: leaq 4286(%rip), %r15
54 # GD-NEXT: 1302: movq %r15, %rax
55 # GD-NEXT: callq *(%rax)
56 # GD-NEXT: movl %fs:(%rax), %eax
58 # NOREL: no relocations
60 ## tpoff(a) = st_value(a) - tls_size = -8
63 # LE-NEXT: movl %fs:(%rax), %eax
64 ## tpoff(b) = st_value(b) - tls_size = -5
66 # LE-NEXT: movq %rcx, %rax
68 # LE-NEXT: movl %fs:(%rax), %eax
69 ## tpoff(c) = st_value(c) - tls_size = -4
71 # LE-NEXT: movq %r15, %rax
73 # LE-NEXT: movl %fs:(%rax), %eax
76 # IE-REL-NEXT: 0x202378 R_X86_64_TPOFF64 c 0x0
79 ## a is relaxed to use LE.
82 # IE-NEXT: movl %fs:(%rax), %eax
83 # IE-NEXT: movq $-1, %rcx
84 # IE-NEXT: movq %rcx, %rax
86 # IE-NEXT: movl %fs:(%rax), %eax
87 ## &.rela.dyn[c]-pc = 0x202378 - 0x2012aa = 4302
88 # IE-NEXT: movq 4302(%rip), %r15
89 # IE-NEXT: 2012aa: movq %r15, %rax
91 # IE-NEXT: movl %fs:(%rax), %eax
93 leaq
a@tlsdesc
(%rip
), %rax
97 ## leaq/call may not be adjacent: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
98 ## Test non-RAX registers as well.
99 leaq
b@tlsdesc
(%rip
), %rcx
101 call
*b@tlscall
(%rax
)
102 movl
%fs:(%rax
), %eax
104 leaq c@tlsdesc
(%rip
), %r15
106 call
*c@tlscall
(%rax
)
107 movl
%fs:(%rax
), %eax