[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / x86-64-tls-opt-noplt.s
blob2795eb05ca24ed085465ccb6d9fe59f49b0dc3a3
1 // REQUIRES: x86
3 // Checks whether the TLS optimizations match the cases in Chapter 11 of
4 // https://raw.githubusercontent.com/wiki/hjl-tools/x86-psABI/x86-64-psABI-1.0.pdf
6 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
7 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-opt-gdie.s -o %tso.o
8 // RUN: ld.lld -shared %tso.o -soname=t.so -o %t.so
9 // RUN: ld.lld %t.o %t.so -o %t1
10 // RUN: llvm-readobj -r %t1 | FileCheck --check-prefix=RELOC %s
11 // RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %t1 | FileCheck --check-prefix=DISASM %s
13 // RELOC: Relocations [
14 // RELOC-NEXT: Section {{.*}} .rela.dyn {
15 // RELOC-NEXT: 0x202420 R_X86_64_TPOFF64 tlsshared0 0x0
16 // RELOC-NEXT: 0x202428 R_X86_64_TPOFF64 tlsshared1 0x0
17 // RELOC-NEXT: }
18 // RELOC-NEXT: ]
20 // DISASM: <_start>:
22 // Table 11.5: GD -> IE Code Transition (LP64)
23 // DISASM-NEXT: movq %fs:0, %rax
24 // DISASM-NEXT: 201309: addq 4368(%rip), %rax
25 // DISASM-NEXT: movq %fs:0, %rax
26 // DISASM-NEXT: 201319: addq 4360(%rip), %rax
28 // Table 11.7: GD -> LE Code Transition (LP64)
29 // DISASM-NEXT: movq %fs:0, %rax
30 // DISASM-NEXT: leaq -8(%rax), %rax
31 // DISASM-NEXT: movq %fs:0, %rax
32 // DISASM-NEXT: leaq -4(%rax), %rax
35 // Table 11.9: LD -> LE Code Transition (LP64)
36 // DISASM-NEXT: movq %fs:0, %rax
37 // DISASM-NEXT: movq %fs:0, %rax
39 .type tls0,@object
40 .section .tbss,"awT",@nobits
41 .globl tls0
42 .align 4
43 tls0:
44 .long 0
45 .size tls0, 4
47 .type tls1,@object
48 .globl tls1
49 .align 4
50 tls1:
51 .long 0
52 .size tls1, 4
54 .section .text
55 .globl _start
56 _start:
57 // Table 11.5: GD -> IE Code Transition (LP64)
58 .byte 0x66
59 leaq tlsshared0@tlsgd(%rip),%rdi
60 .byte 0x66
61 rex64
62 call *__tls_get_addr@GOTPCREL(%rip)
64 .byte 0x66
65 leaq tlsshared1@tlsgd(%rip),%rdi
66 .byte 0x66
67 rex64
68 call *__tls_get_addr@GOTPCREL(%rip)
70 // Table 11.7: GD -> LE Code Transition (LP64)
71 .byte 0x66
72 leaq tls0@tlsgd(%rip),%rdi
73 .byte 0x66
74 rex64
75 call *__tls_get_addr@GOTPCREL(%rip)
77 .byte 0x66
78 leaq tls1@tlsgd(%rip),%rdi
79 .byte 0x66
80 rex64
81 call *__tls_get_addr@GOTPCREL(%rip)
83 // Table 11.9: LD -> LE Code Transition (LP64)
84 leaq tls0@tlsld(%rip),%rdi
85 call *__tls_get_addr@GOTPCREL(%rip)
87 leaq tls1@tlsld(%rip),%rdi
88 call *__tls_get_addr@GOTPCREL(%rip)