[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / x86-64-tlsdesc-ld.s
blob2f55aed4159bcf5cc1d70654ffb114454ecf19dc
1 # REQUIRES: x86
2 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
4 # RUN: ld.lld -shared %t.o -o %t.so
5 # RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=LD-REL %s
6 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t.so | FileCheck --check-prefix=LD %s
8 # RUN: ld.lld %t.o -o %t
9 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
10 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
12 ## Check _TLS_MODULE_BASE_ used by LD produces a dynamic relocation with a value of 0.
13 # LD-REL: .rela.dyn {
14 # LD-REL-NEXT: 0x2318 R_X86_64_TLSDESC - 0x0
15 # LD-REL-NEXT: }
17 ## 0x2318-0x1267 = 4273
18 ## dtpoff(a) = 8, dtpoff(b) = 12
19 # LD: leaq 4273(%rip), %rax
20 # LD-NEXT: 1267: callq *(%rax)
21 # LD-NEXT: movl %fs:8(%rax), %edx
22 # LD-NEXT: addl %fs:12(%rax), %edx
24 ## When producing an executable, the LD code sequence can be relaxed to LE.
25 ## It is the same as GD->LE.
26 ## tpoff(_TLS_MODULE_BASE_) = 0, tpoff(a) = -8, tpoff(b) = -4
28 # NOREL: no relocations
30 # LE: movq $0, %rax
31 # LE-NEXT: nop
32 # LE-NEXT: movl %fs:-8(%rax), %edx
33 # LE-NEXT: addl %fs:-4(%rax), %edx
35 # RUN: ld.lld -r %t.o -o %t.ro
36 # RUN: llvm-readelf -s %t.ro | FileCheck --check-prefix=RELOCATABLE %s
37 # RUN: ld.lld %t.ro -o %t
38 # RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
39 # RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
41 # RELOCATABLE: 0000000000000000 0 TLS GLOBAL DEFAULT UND _TLS_MODULE_BASE_
43 leaq _TLS_MODULE_BASE_@tlsdesc(%rip), %rax
44 call *_TLS_MODULE_BASE_@tlscall(%rax)
45 movl %fs:a@dtpoff(%rax), %edx
46 addl %fs:b@dtpoff(%rax), %edx
48 .section .tbss
49 .zero 8
51 .zero 4
53 .zero 4