[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / x86-64-tlsdesc-gd.s
blob433c2b2723463ba2f443cb91e5b06cf145c90485
1 # REQUIRES: x86
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: 0x23E0 R_X86_64_TLSDESC - 0xB
23 # GD-RELA-NEXT: 0x23C0 R_X86_64_TLSDESC a 0x0
24 # GD-RELA-NEXT: 0x23D0 R_X86_64_TLSDESC c 0x0
25 # GD-RELA-NEXT: }
26 # GD-RELA: Hex dump of section '.got':
27 # GD-RELA-NEXT: 0x000023c0 00000000 00000000 00000000 00000000
28 # GD-RELA-NEXT: 0x000023d0 00000000 00000000 00000000 00000000
29 # GD-RELA-NEXT: 0x000023e0 00000000 00000000 00000000 00000000
31 # GD-REL: .rel.dyn {
32 # GD-REL-NEXT: 0x23C8 R_X86_64_TLSDESC -
33 # GD-REL-NEXT: 0x23A8 R_X86_64_TLSDESC a
34 # GD-REL-NEXT: 0x23B8 R_X86_64_TLSDESC c
35 # GD-REL-NEXT: }
36 # GD-REL: Hex dump of section '.got':
37 # GD-REL-NEXT: 0x000023a8 00000000 00000000 00000000 00000000
38 # GD-REL-NEXT: 0x000023b8 00000000 00000000 00000000 00000000
39 # GD-REL-NEXT: 0x000023c8 00000000 00000000 0b000000 00000000
41 ## &.rela.dyn[a]-pc = 0x23C0-0x12e7 = 4313
42 # GD: leaq 4313(%rip), %rax
43 # GD-NEXT: 12e7: callq *(%rax)
44 # GD-NEXT: movl %fs:(%rax), %eax
46 ## &.rela.dyn[b]-pc = 0x23E0-0x12f3 = 4333
47 # GD-NEXT: leaq 4333(%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 = 0x23D0-0x1302 = 4302
53 # GD-NEXT: leaq 4302(%rip), %r15
54 # GD-NEXT: 1302: movq %r15, %rax
55 # GD-NEXT: callq *(%rax)
56 # GD-NEXT: movl %fs:(%rax), %eax
58 ## &.rela.dyn[c]-pc = 0x23D0-0x1312 = 4286
59 # GD-NEXT: leaq 4286(%rip), %r16
60 # GD-NEXT: 1312: movq %r16, %rax
61 # GD-NEXT: callq *(%rax)
62 # GD-NEXT: movl %fs:(%rax), %eax
64 # NOREL: no relocations
66 ## tpoff(a) = st_value(a) - tls_size = -8
67 # LE: movq $-8, %rax
68 # LE-NEXT: nop
69 # LE-NEXT: movl %fs:(%rax), %eax
70 ## tpoff(b) = st_value(b) - tls_size = -5
71 # LE: movq $-5, %rcx
72 # LE-NEXT: movq %rcx, %rax
73 # LE-NEXT: nop
74 # LE-NEXT: movl %fs:(%rax), %eax
75 ## tpoff(c) = st_value(c) - tls_size = -4
76 # LE: movq $-4, %r15
77 # LE-NEXT: movq %r15, %rax
78 # LE-NEXT: nop
79 # LE-NEXT: movl %fs:(%rax), %eax
80 ## tpoff(c) = st_value(c) - tls_size = -4
81 # LE: movq $-4, %r16
82 # LE-NEXT: movq %r16, %rax
83 # LE-NEXT: nop
84 # LE-NEXT: movl %fs:(%rax), %eax
86 # IE-REL: .rela.dyn {
87 # IE-REL-NEXT: 0x202388 R_X86_64_TPOFF64 c 0x0
88 # IE-REL-NEXT: }
90 ## a is relaxed to use LE.
91 # IE: movq $-4, %rax
92 # IE-NEXT: nop
93 # IE-NEXT: movl %fs:(%rax), %eax
94 # IE-NEXT: movq $-1, %rcx
95 # IE-NEXT: movq %rcx, %rax
96 # IE-NEXT: nop
97 # IE-NEXT: movl %fs:(%rax), %eax
98 ## &.rela.dyn[c]-pc = 0x202388 - 0x2012aa = 4318
99 # IE-NEXT: movq 4318(%rip), %r15
100 # IE-NEXT: 2012aa: movq %r15, %rax
101 # IE-NEXT: nop
102 # IE-NEXT: movl %fs:(%rax), %eax
103 ## &.rela.dyn[c]-pc = 0x202388 - 0x2012ba = 4302
104 # IE-NEXT: movq 4302(%rip), %r16
105 # IE-NEXT: 2012ba: movq %r16, %rax
106 # IE-NEXT: nop
107 # IE-NEXT: movl %fs:(%rax), %eax
109 leaq a@tlsdesc(%rip), %rax
110 call *a@tlscall(%rax)
111 movl %fs:(%rax), %eax
113 ## leaq/call may not be adjacent: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5665
114 ## Test non-RAX registers as well.
115 leaq b@tlsdesc(%rip), %rcx
116 movq %rcx, %rax
117 call *b@tlscall(%rax)
118 movl %fs:(%rax), %eax
120 leaq c@tlsdesc(%rip), %r15
121 movq %r15, %rax
122 call *c@tlscall(%rax)
123 movl %fs:(%rax), %eax
125 leaq c@tlsdesc(%rip), %r16
126 movq %r16, %rax
127 call *c@tlscall(%rax)
128 movl %fs:(%rax), %eax
130 .section .tbss
131 .globl a
132 .zero 8
134 .zero 3
136 .zero 1