[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / loongarch-tlsdesc.s
blobbf09b1e4bbae9208b2571195609880178b1515ed
1 # REQUIRES: loongarch
2 # RUN: rm -rf %t && split-file %s %t && cd %t
3 # RUN: llvm-mc -filetype=obj -triple=loongarch64 a.s -o a.64.o
4 # RUN: llvm-mc -filetype=obj -triple=loongarch64 c.s -o c.64.o
5 # RUN: ld.lld -shared -soname=c.64.so c.64.o -o c.64.so
6 # RUN: llvm-mc -filetype=obj -triple=loongarch32 --defsym ELF32=1 a.s -o a.32.o
7 # RUN: llvm-mc -filetype=obj -triple=loongarch32 --defsym ELF32=1 c.s -o c.32.o
8 # RUN: ld.lld -shared -soname=c.32.so c.32.o -o c.32.so
10 # RUN: ld.lld -shared -z now a.64.o c.64.o -o a.64.so
11 # RUN: llvm-readobj -r -x .got a.64.so | FileCheck --check-prefix=GD64-RELA %s
12 # RUN: llvm-objdump --no-show-raw-insn -h -d a.64.so | FileCheck %s --check-prefix=GD64
14 # RUN: ld.lld -shared -z now a.64.o c.64.o -o rel.64.so -z rel
15 # RUN: llvm-readobj -r -x .got rel.64.so | FileCheck --check-prefix=GD64-REL %s
17 ## FIXME: The transition frome TLSDESC to IE/LE has not yet been implemented.
18 ## Keep the dynamic relocations and hand them over to dynamic linker.
20 # RUN: ld.lld -e 0 -z now a.64.o c.64.o -o a.64.le
21 # RUN: llvm-readobj -r -x .got a.64.le | FileCheck --check-prefix=LE64-RELA %s
23 # RUN: ld.lld -e 0 -z now a.64.o c.64.so -o a.64.ie
24 # RUN: llvm-readobj -r -x .got a.64.ie | FileCheck --check-prefix=IE64-RELA %s
26 ## 32-bit code is mostly the same. We only test a few variants.
28 # RUN: ld.lld -shared -z now a.32.o c.32.o -o rel.32.so -z rel
29 # RUN: llvm-readobj -r -x .got rel.32.so | FileCheck --check-prefix=GD32-REL %s
31 # GD64-RELA: .rela.dyn {
32 # GD64-RELA-NEXT: 0x20400 R_LARCH_TLS_DESC64 - 0x7FF
33 # GD64-RELA-NEXT: 0x203E0 R_LARCH_TLS_DESC64 a 0x0
34 # GD64-RELA-NEXT: 0x203F0 R_LARCH_TLS_DESC64 c 0x0
35 # GD64-RELA-NEXT: }
36 # GD64-RELA: Hex dump of section '.got':
37 # GD64-RELA-NEXT: 0x000203e0 00000000 00000000 00000000 00000000 .
38 # GD64-RELA-NEXT: 0x000203f0 00000000 00000000 00000000 00000000 .
39 # GD64-RELA-NEXT: 0x00020400 00000000 00000000 00000000 00000000 .
41 # GD64-REL: .rel.dyn {
42 # GD64-REL-NEXT: 0x203E8 R_LARCH_TLS_DESC64 -
43 # GD64-REL-NEXT: 0x203C8 R_LARCH_TLS_DESC64 a
44 # GD64-REL-NEXT: 0x203D8 R_LARCH_TLS_DESC64 c
45 # GD64-REL-NEXT: }
46 # GD64-REL: Hex dump of section '.got':
47 # GD64-REL-NEXT: 0x000203c8 00000000 00000000 00000000 00000000 .
48 # GD64-REL-NEXT: 0x000203d8 00000000 00000000 00000000 00000000 .
49 # GD64-REL-NEXT: 0x000203e8 00000000 00000000 ff070000 00000000 .
51 # GD64: .got 00000030 00000000000203e0
53 ## &.got[a]-. = 0x203e0 - 0x102e0: 0x10 pages, page offset 0x3e0
54 # GD64: 102e0: pcalau12i $a0, 16
55 # GD64-NEXT: addi.d $a0, $a0, 992
56 # GD64-NEXT: ld.d $ra, $a0, 0
57 # GD64-NEXT: jirl $ra, $ra, 0
58 # GD64-NEXT: add.d $a1, $a0, $tp
60 ## &.got[b]-. = 0x203e0+32 - 0x102f4: 0x10 pages, page offset 0x400
61 # GD64: 102f4: pcalau12i $a0, 16
62 # GD64-NEXT: addi.d $a0, $a0, 1024
63 # GD64-NEXT: ld.d $ra, $a0, 0
64 # GD64-NEXT: jirl $ra, $ra, 0
65 # GD64-NEXT: add.d $a2, $a0, $tp
67 ## &.got[c]-. = 0x23e0+16 - 0x10308: 0x10 pages, page offset 0x3f0
68 # GD64: 10308: pcalau12i $a0, 16
69 # GD64-NEXT: addi.d $a0, $a0, 1008
70 # GD64-NEXT: ld.d $ra, $a0, 0
71 # GD64-NEXT: jirl $ra, $ra, 0
72 # GD64-NEXT: add.d $a3, $a0, $tp
74 # LE64-RELA: .rela.dyn {
75 # LE64-RELA-NEXT: 0x30250 R_LARCH_TLS_DESC64 - 0x8
76 # LE64-RELA-NEXT: 0x30260 R_LARCH_TLS_DESC64 - 0x800
77 # LE64-RELA-NEXT: 0x30270 R_LARCH_TLS_DESC64 - 0x7FF
78 # LE64-RELA-NEXT: }
79 # LE64-RELA: Hex dump of section '.got':
80 # LE64-RELA-NEXT: 0x00030250 00000000 00000000 00000000 00000000 .
81 # LE64-RELA-NEXT: 0x00030260 00000000 00000000 00000000 00000000 .
82 # LE64-RELA-NEXT: 0x00030270 00000000 00000000 00000000 00000000 .
84 # IE64-RELA: .rela.dyn {
85 # IE64-RELA-NEXT: 0x303D8 R_LARCH_TLS_DESC64 - 0x8
86 # IE64-RELA-NEXT: 0x303F8 R_LARCH_TLS_DESC64 - 0x7FF
87 # IE64-RELA-NEXT: 0x303E8 R_LARCH_TLS_DESC64 c 0x0
88 # IE64-RELA-NEXT: }
89 # IE64-RELA: Hex dump of section '.got':
90 # IE64-RELA-NEXT: 0x000303d8 00000000 00000000 00000000 00000000 .
91 # IE64-RELA-NEXT: 0x000303e8 00000000 00000000 00000000 00000000 .
92 # IE64-RELA-NEXT: 0x000303f8 00000000 00000000 00000000 00000000 .
94 # GD32-REL: .rel.dyn {
95 # GD32-REL-NEXT: 0x20270 R_LARCH_TLS_DESC32 -
96 # GD32-REL-NEXT: 0x20260 R_LARCH_TLS_DESC32 a
97 # GD32-REL-NEXT: 0x20268 R_LARCH_TLS_DESC32 c
98 # GD32-REL-NEXT: }
99 # GD32-REL: Hex dump of section '.got':
100 # GD32-REL-NEXT: 0x00020260 00000000 00000000 00000000 00000000 .
101 # GD32-REL-NEXT: 0x00020270 00000000 ff070000 .
103 #--- a.s
104 .macro add dst, src1, src2
105 .ifdef ELF32
106 add.w \dst, \src1, \src2
107 .else
108 add.d \dst, \src1, \src2
109 .endif
110 .endm
112 la.tls.desc $a0, a
113 add $a1, $a0, $tp
115 la.tls.desc $a0, b
116 add $a2, $a0, $tp
118 la.tls.desc $a0, c
119 add $a3, $a0, $tp
121 .section .tbss,"awT",@nobits
122 .globl a
123 .zero 8
125 .zero 2039 ## Place b at 0x7ff
127 .zero 1
129 #--- c.s
130 .section .tbss,"awT",@nobits
131 .globl c
132 c: .zero 4