[ELF] Make section member orders consistent
[llvm-project.git] / lld / test / ELF / ppc64-tls-pcrel-ie.s
blob38c081f9664692a4d11e6d6c53d4eece54438fc2
1 # REQUIRES: ppc
3 # RUN: split-file %s %t
5 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/asm -o %t.o
6 # RUN: llvm-mc -filetype=obj -triple=powerpc64le %t/defs -o %t-defs.o
7 # RUN: ld.lld --shared %t-defs.o --soname=t-defs -o %t-defs.so
8 # RUN: ld.lld -T %t/lds %t.o %t-defs.so -o %t-ie
9 # RUN: ld.lld -T %t/lds %t.o %t-defs.o -o %t-le
11 # RUN: llvm-readelf -r %t-ie | FileCheck %s --check-prefix=IE-RELOC
12 # RUN: llvm-readelf -s %t-ie | FileCheck %s --check-prefix=IE-SYM
13 # RUN: llvm-readelf -x .got %t-ie | FileCheck %s --check-prefix=IE-GOT
14 # RUN: llvm-objdump -d --no-show-raw-insn %t-ie | FileCheck %s --check-prefix=IE
16 # RUN: llvm-readelf -r %t-le | FileCheck %s --check-prefix=LE-RELOC
17 # RUN: llvm-readelf -s %t-le | FileCheck %s --check-prefix=LE-SYM
18 # RUN: llvm-readelf -x .got %t-le 2>&1 | FileCheck %s --check-prefix=LE-GOT
19 # RUN: llvm-objdump -d --no-show-raw-insn %t-le | FileCheck %s --check-prefix=LE
21 ## This test checks the Initial Exec PC Relative TLS implementation.
22 ## The IE version checks that the relocations are generated correctly.
23 ## The LE version checks that the Initial Exec to Local Exec relaxation is
24 ## done correctly.
26 #--- lds
27 SECTIONS {
28 .text_addr 0x1001000 : { *(.text_addr) }
29 .text_val 0x1002000 : { *(.text_val) }
30 .text_twoval 0x1003000 : { *(.text_twoval) }
31 .text_incrval 0x1004000 : { *(.text_incrval) }
32 .text_incrval_half 0x1005000 : { *(.text_incrval_half) }
33 .text_incrval_word 0x1006000 : { *(.text_incrval_word) }
34 .text_incrval_float 0x1007000 : { *(.text_incrval_float) }
35 .text_incrval_double 0x1008000 : { *(.text_incrval_double) }
36 .text_incrval_dword 0x1009000 : { *(.text_incrval_dword) }
37 .text_incrval_half_zero 0x1010000 : { *(.text_incrval_half_zero) }
40 #--- defs
41 .section .tbss,"awT",@nobits
42 .globl x
44 .long 0
45 .globl y
47 .long 0
49 #--- asm
50 # IE-RELOC: Relocation section '.rela.dyn' at offset 0x10090 contains 2 entries:
51 # IE-RELOC: 00000000010100f0 0000000100000049 R_PPC64_TPREL64 0000000000000000 x + 0
52 # IE-RELOC-NEXT: 00000000010100f8 0000000200000049 R_PPC64_TPREL64 0000000000000000 y + 0
54 # IE-SYM: Symbol table '.dynsym' contains 3 entries:
55 # IE-SYM: 1: 0000000000000000 0 TLS GLOBAL DEFAULT UND x
56 # IE-SYM: 2: 0000000000000000 0 TLS GLOBAL DEFAULT UND y
58 # IE-GOT: Hex dump of section '.got':
59 # IE-GOT-NEXT: 0x010100e8 e8800101 00000000 00000000 00000000
61 # LE-RELOC: There are no relocations in this file.
63 # LE-SYM: Symbol table '.symtab' contains 14 entries:
64 # LE-SYM: 0000000000000000 0 TLS GLOBAL DEFAULT [[#]] x
65 # LE-SYM: 0000000000000004 0 TLS GLOBAL DEFAULT [[#]] y
67 # LE-GOT: could not find section '.got'
69 # IE-LABEL: <IEAddr>:
70 # IE-NEXT: pld 3, 61680(0), 1
71 # IE-NEXT: add 3, 3, 13
72 # IE-NEXT: blr
73 # LE-LABEL: <IEAddr>:
74 # LE-NEXT: paddi 3, 13, -28672, 0
75 # LE-NEXT: nop
76 # LE-NEXT: blr
77 .section .text_addr, "ax", %progbits
78 IEAddr:
79 pld 3, x@got@tprel@pcrel(0), 1
80 add 3, 3, x@tls@pcrel
81 blr
83 # IE-LABEL: <IEAddrCopy>:
84 # IE-NEXT: pld 3, 61664(0), 1
85 # IE-NEXT: add 4, 3, 13
86 # IE-NEXT: blr
87 # LE-LABEL: <IEAddrCopy>:
88 # LE-NEXT: paddi 3, 13, -28672, 0
89 # LE-NEXT: mr 4, 3
90 # LE-NEXT: blr
91 .section .text_addr, "ax", %progbits
92 IEAddrCopy:
93 pld 3, x@got@tprel@pcrel(0), 1
94 add 4, 3, x@tls@pcrel
95 blr
97 # IE-LABEL: <IEVal>:
98 # IE-NEXT: pld 3, 57584(0), 1
99 # IE-NEXT: lwzx 3, 3, 13
100 # IE-NEXT: blr
101 # LE-LABEL: <IEVal>:
102 # LE-NEXT: paddi 3, 13, -28672, 0
103 # LE-NEXT: lwz 3, 0(3)
104 # LE-NEXT: blr
105 .section .text_val, "ax", %progbits
106 IEVal:
107 pld 3, x@got@tprel@pcrel(0), 1
108 lwzx 3, 3, x@tls@pcrel
111 # IE-LABEL: <IETwoVal>:
112 # IE-NEXT: pld 3, 53488(0), 1
113 # IE-NEXT: pld 4, 53488(0), 1
114 # IE-NEXT: lwzx 3, 3, 13
115 # IE-NEXT: lwzx 4, 4, 13
116 # IE-NEXT: blr
117 # LE-LABEL: <IETwoVal>:
118 # LE-NEXT: paddi 3, 13, -28672, 0
119 # LE-NEXT: paddi 4, 13, -28668, 0
120 # LE-NEXT: lwz 3, 0(3)
121 # LE-NEXT: lwz 4, 0(4)
122 # LE-NEXT: blr
123 .section .text_twoval, "ax", %progbits
124 IETwoVal:
125 pld 3, x@got@tprel@pcrel(0), 1
126 pld 4, y@got@tprel@pcrel(0), 1
127 lwzx 3, 3, x@tls@pcrel
128 lwzx 4, 4, y@tls@pcrel
131 # IE-LABEL: <IEIncrementVal>:
132 # IE-NEXT: pld 4, 49400(0), 1
133 # IE-NEXT: lwzx 3, 4, 13
134 # IE-NEXT: stwx 3, 4, 13
135 # IE-NEXT: blr
136 # LE-LABEL: <IEIncrementVal>:
137 # LE-NEXT: paddi 4, 13, -28668, 0
138 # LE-NEXT: lwz 3, 0(4)
139 # LE-NEXT: stw 3, 0(4)
140 # LE-NEXT: blr
141 .section .text_incrval, "ax", %progbits
142 IEIncrementVal:
143 pld 4, y@got@tprel@pcrel(0), 1
144 lwzx 3, 4, y@tls@pcrel
145 stwx 3, 4, y@tls@pcrel
148 # IE-LABEL: <IEIncrementValHalf>:
149 # IE-NEXT: pld 4, 45304(0), 1
150 # IE-NEXT: lhax 3, 4, 13
151 # IE-NEXT: sthx 3, 4, 13
152 # IE-NEXT: blr
153 # LE-LABEL: <IEIncrementValHalf>:
154 # LE-NEXT: paddi 4, 13, -28668, 0
155 # LE-NEXT: lha 3, 0(4)
156 # LE-NEXT: sth 3, 0(4)
157 # LE-NEXT: blr
158 .section .text_incrval_half, "ax", %progbits
159 IEIncrementValHalf:
160 pld 4, y@got@tprel@pcrel(0), 1
161 lhax 3, 4, y@tls@pcrel
162 sthx 3, 4, y@tls@pcrel
165 # IE-LABEL: <IEIncrementValWord>:
166 # IE-NEXT: pld 4, 41208(0), 1
167 # IE-NEXT: lwax 3, 4, 13
168 # IE-NEXT: stwx 3, 4, 13
169 # IE-NEXT: blr
170 # LE-LABEL: <IEIncrementValWord>:
171 # LE-NEXT: paddi 4, 13, -28668, 0
172 # LE-NEXT: lwa 3, 0(4)
173 # LE-NEXT: stw 3, 0(4)
174 # LE-NEXT: blr
175 .section .text_incrval_word, "ax", %progbits
176 IEIncrementValWord:
177 pld 4, y@got@tprel@pcrel(0), 1
178 lwax 3, 4, y@tls@pcrel
179 stwx 3, 4, y@tls@pcrel
182 # IE-LABEL: <IEIncrementValFloat>:
183 # IE-NEXT: pld 4, 37112(0), 1
184 # IE-NEXT: lfsx 3, 4, 13
185 # IE-NEXT: stfsx 3, 4, 13
186 # IE-NEXT: blr
187 # LE-LABEL: <IEIncrementValFloat>:
188 # LE-NEXT: paddi 4, 13, -28668, 0
189 # LE-NEXT: lfs 3, 0(4)
190 # LE-NEXT: stfs 3, 0(4)
191 # LE-NEXT: blr
192 .section .text_incrval_float, "ax", %progbits
193 IEIncrementValFloat:
194 pld 4, y@got@tprel@pcrel(0), 1
195 lfsx 3, 4, y@tls@pcrel
196 stfsx 3, 4, y@tls@pcrel
199 # IE-LABEL: <IEIncrementValDouble>:
200 # IE-NEXT: pld 4, 33016(0), 1
201 # IE-NEXT: lfdx 3, 4, 13
202 # IE-NEXT: stfdx 3, 4, 13
203 # IE-NEXT: blr
204 # LE-LABEL: <IEIncrementValDouble>:
205 # LE-NEXT: paddi 4, 13, -28668, 0
206 # LE-NEXT: lfd 3, 0(4)
207 # LE-NEXT: stfd 3, 0(4)
208 # LE-NEXT: blr
209 .section .text_incrval_double, "ax", %progbits
210 IEIncrementValDouble:
211 pld 4, y@got@tprel@pcrel(0), 1
212 lfdx 3, 4, y@tls@pcrel
213 stfdx 3, 4, y@tls@pcrel
216 # IE-LABEL: <IEIncrementValDword>:
217 # IE-NEXT: pld 4, 28920(0), 1
218 # IE-NEXT: ldx 3, 4, 13
219 # IE-NEXT: stdx 3, 4, 13
220 # IE-NEXT: blr
221 # LE-LABEL: <IEIncrementValDword>:
222 # LE-NEXT: paddi 4, 13, -28668, 0
223 # LE-NEXT: ld 3, 0(4)
224 # LE-NEXT: std 3, 0(4)
225 # LE-NEXT: blr
226 .section .text_incrval_dword, "ax", %progbits
227 IEIncrementValDword:
228 pld 4, y@got@tprel@pcrel(0), 1
229 ldx 3, 4, y@tls@pcrel
230 stdx 3, 4, y@tls@pcrel
233 # IE-LABEL: <IEIncrementValHalfZero>:
234 # IE-NEXT: pld 4, 248(0), 1
235 # IE-NEXT: lhzx 3, 4, 13
236 # IE-NEXT: sthx 3, 4, 13
237 # IE-NEXT: blr
238 # LE-LABEL: <IEIncrementValHalfZero>:
239 # LE-NEXT: paddi 4, 13, -28668, 0
240 # LE-NEXT: lhz 3, 0(4)
241 # LE-NEXT: sth 3, 0(4)
242 # LE-NEXT: blr
243 .section .text_incrval_half_zero, "ax", %progbits
244 IEIncrementValHalfZero:
245 pld 4, y@got@tprel@pcrel(0), 1
246 lhzx 3, 4, y@tls@pcrel
247 sthx 3, 4, y@tls@pcrel