d0a588c5f92158f4fa39ed0078c6abd1bd699a4d
[external/binutils.git] / ld / testsuite / ld-aarch64 / aarch64-elf.exp
1 # Expect script for various AARCH64 ELF tests.
2 # Copyright (C) 2009-2019 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20
21 # Exclude non-aarch64-ELF targets.
22 if { ![is_elf_format] || ![istarget "aarch64*-*-*"] } {
23     return
24 }
25
26 # List contains test-items with 3 items followed by 2 lists:
27 # 0:name 1:ld early options 2:ld late options 3:assembler options
28 # 4:filenames of assembler files 5: action and options. 6: name of output file
29
30 # Actions:
31 # objdump: Apply objdump options on result.  Compare with regex (last arg).
32 # nm: Apply nm options on result.  Compare with regex (last arg).
33 # readelf: Apply readelf options on result.  Compare with regex (last arg).
34
35 set aarch64elftests {
36     {"Erratum 835769 dump test"
37      "--fix-cortex-a53-835769" "" "" {erratum835769.s}
38      {{objdump -dr erratum835769.d}}
39      "erratum835769"}
40     {"Erratum 835769 dump test -shared"
41      "--fix-cortex-a53-835769 -shared" "" "" {erratum835769.s}
42      {{objdump -dr erratum835769.d}}
43      "erratum835769"}
44 }
45
46 proc aarch64_choose_ilp32_emul {} {
47     if [istarget *linux*] then {
48         if [istarget aarch64_be-*] {
49             return "aarch64linux32b"
50         }
51         return "aarch64linux32"
52     }
53     if [istarget aarch64_be-*] {
54         return "aarch64elf32b"
55     }
56     return "aarch64elf32"
57 }
58
59 proc aarch64_choose_lp64_emul {} {
60     if [istarget *linux*] then {
61         if [istarget aarch64_be-*] {
62             return "aarch64linuxb"
63         }
64         return "aarch64linux"
65     }
66     if [istarget aarch64_be-*] {
67         return "aarch64elfb"
68     }
69     return "aarch64elf"
70 }
71
72 proc run_dump_test_lp64 { testname } {
73   run_dump_test $testname \
74                 [list [list as "-mabi=lp64"] \
75                       [list ld [concat "-m " [aarch64_choose_lp64_emul]]]]
76 }
77
78 set eh-frame-merge-lp64 [list [list "EH Frame merge" \
79                               [concat "-m " [aarch64_choose_lp64_emul] \
80                                       " -Ttext 0x8000"] \
81                               "" "-mabi=lp64" {eh-frame-bar.s eh-frame-foo.s} \
82                               {{objdump --dwarf=frames eh-frame.d}} \
83                               "eh-frame"]]
84
85 run_ld_link_tests $aarch64elftests
86 run_ld_link_tests eh-frame-merge-lp64
87
88 run_dump_test "erratum843419"
89 run_dump_test "erratum843419_tls_ie"
90 run_dump_test "erratum843419-adr"
91 run_dump_test "erratum843419-adrp"
92 run_dump_test "erratum843419-far-adr"
93 run_dump_test "erratum843419-far-full"
94 run_dump_test "erratum843419-full"
95 run_dump_test "erratum843419-no-args"
96
97 # Relocation Tests
98 run_dump_test_lp64 "weak-undefined"
99 run_dump_test "emit-relocs-28"
100 run_dump_test "emit-relocs-86"
101 run_dump_test "emit-relocs-86-overflow"
102 run_dump_test "emit-relocs-87"
103 run_dump_test "emit-relocs-88"
104 run_dump_test "emit-relocs-88-overflow"
105 run_dump_test "emit-relocs-89"
106 run_dump_test "emit-relocs-90"
107 run_dump_test "emit-relocs-90-overflow"
108 run_dump_test "emit-relocs-92"
109
110 run_dump_test "emit-relocs-112"
111 run_dump_test "emit-relocs-112-overflow"
112 run_dump_test "emit-relocs-113"
113 run_dump_test "emit-relocs-114"
114 run_dump_test "emit-relocs-114-overflow"
115 run_dump_test "emit-relocs-115"
116 run_dump_test "emit-relocs-116"
117 run_dump_test "emit-relocs-116-overflow"
118 run_dump_test "emit-relocs-117"
119 run_dump_test "emit-relocs-118"
120 run_dump_test "emit-relocs-118-overflow"
121 run_dump_test "emit-relocs-119"
122
123 run_dump_test "emit-relocs-257"
124 run_dump_test "emit-relocs-257-be"
125 # 258 is tested in 257
126 # 259 is tested in 257
127 run_dump_test_lp64 "emit-relocs-258-dyn-bad"
128 run_dump_test_lp64 "emit-relocs-259-dyn-bad"
129 run_dump_test_lp64 "emit-relocs-260"
130 run_dump_test_lp64 "emit-relocs-260-be"
131 # 261 is tested by 260
132 run_dump_test_lp64 "emit-relocs-262"
133 run_dump_test_lp64 "emit-relocs-263"
134 run_dump_test_lp64 "emit-relocs-264"
135 run_dump_test_lp64 "emit-relocs-264-bad"
136 run_dump_test_lp64 "emit-relocs-265"
137 run_dump_test_lp64 "emit-relocs-266"
138 run_dump_test_lp64 "emit-relocs-266-bad"
139 run_dump_test_lp64 "emit-relocs-267"
140 run_dump_test_lp64 "emit-relocs-268"
141 run_dump_test_lp64 "emit-relocs-268-bad"
142 run_dump_test_lp64 "emit-relocs-269"
143 run_dump_test_lp64 "emit-relocs-269-bad"
144 run_dump_test_lp64 "emit-relocs-270"
145 run_dump_test_lp64 "emit-relocs-270-bad"
146 run_dump_test_lp64 "emit-relocs-270-overflow"
147 run_dump_test_lp64 "emit-relocs-271"
148 run_dump_test_lp64 "emit-relocs-271-overflow"
149 run_dump_test_lp64 "emit-relocs-272"
150 run_dump_test_lp64 "emit-relocs-272-overflow"
151 run_dump_test_lp64 "emit-relocs-273"
152 run_dump_test_lp64 "emit-relocs-274"
153 run_dump_test_lp64 "emit-relocs-275"
154 run_dump_test_lp64 "emit-relocs-276"
155 run_dump_test_lp64 "emit-relocs-277"
156 run_dump_test_lp64 "emit-relocs-278"
157 run_dump_test_lp64 "emit-relocs-279"
158 run_dump_test_lp64 "emit-relocs-279-bad"
159 run_dump_test_lp64 "emit-relocs-280"
160 # 281 is unused
161 run_dump_test_lp64 "emit-relocs-282"
162 run_dump_test_lp64 "emit-relocs-283"
163 run_dump_test_lp64 "emit-relocs-284"
164 run_dump_test_lp64 "emit-relocs-285"
165 run_dump_test_lp64 "emit-relocs-286"
166 run_dump_test_lp64 "emit-relocs-286-bad"
167 run_dump_test_lp64 "emit-relocs-287"
168 run_dump_test_lp64 "emit-relocs-287-overflow"
169 run_dump_test_lp64 "emit-relocs-288"
170 run_dump_test_lp64 "emit-relocs-289"
171 run_dump_test_lp64 "emit-relocs-289-overflow"
172 run_dump_test_lp64 "emit-relocs-290"
173 run_dump_test_lp64 "emit-relocs-291"
174 run_dump_test_lp64 "emit-relocs-291-overflow"
175 run_dump_test_lp64 "emit-relocs-292"
176 run_dump_test_lp64 "emit-relocs-293"
177 # 294-298 are not done yet
178 run_dump_test_lp64 "emit-relocs-299"
179 # 300 is not done yet
180 run_dump_test_lp64 "emit-relocs-301"
181 run_dump_test_lp64 "emit-relocs-301-be"
182 run_dump_test_lp64 "emit-relocs-302"
183 run_dump_test_lp64 "emit-relocs-302-be"
184 # 303-308 are not done yet
185 run_dump_test_lp64 "emit-relocs-309-up"
186 run_dump_test_lp64 "emit-relocs-309-low"
187 run_dump_test_lp64 "emit-relocs-309-up-bad"
188 run_dump_test_lp64 "emit-relocs-309-low-bad"
189 run_dump_test_lp64 "emit-relocs-310"
190 run_dump_test_lp64 "emit-relocs-310-be"
191 run_dump_test_lp64 "emit-relocs-311"
192 run_dump_test_lp64 "emit-relocs-312"
193 run_dump_test_lp64 "emit-relocs-313"
194 run_dump_test_lp64 "emit-relocs-515"
195 run_dump_test_lp64 "emit-relocs-515-be"
196 run_dump_test_lp64 "emit-relocs-516"
197 run_dump_test_lp64 "emit-relocs-516-be"
198 run_dump_test_lp64 "emit-relocs-523"
199 run_dump_test_lp64 "emit-relocs-524"
200 run_dump_test_lp64 "emit-relocs-525"
201 run_dump_test_lp64 "emit-relocs-526"
202 run_dump_test_lp64 "emit-relocs-526-overflow"
203 run_dump_test_lp64 "emit-relocs-527"
204 run_dump_test_lp64 "emit-relocs-528"
205 run_dump_test_lp64 "emit-relocs-528-overflow"
206 run_dump_test_lp64 "emit-relocs-529"
207 run_dump_test_lp64 "emit-relocs-529-overflow"
208 run_dump_test_lp64 "emit-relocs-530"
209 run_dump_test_lp64 "emit-relocs-531"
210 run_dump_test_lp64 "emit-relocs-531-overflow"
211 run_dump_test_lp64 "emit-relocs-532"
212 run_dump_test_lp64 "emit-relocs-533"
213 run_dump_test_lp64 "emit-relocs-533-overflow"
214 run_dump_test_lp64 "emit-relocs-534"
215 run_dump_test_lp64 "emit-relocs-535"
216 run_dump_test_lp64 "emit-relocs-535-overflow"
217 run_dump_test_lp64 "emit-relocs-536"
218 run_dump_test_lp64 "emit-relocs-537"
219 run_dump_test_lp64 "emit-relocs-537-overflow"
220 run_dump_test_lp64 "emit-relocs-538"
221 run_dump_test_lp64 "emit-relocs-552"
222 run_dump_test_lp64 "emit-relocs-552-overflow"
223 run_dump_test_lp64 "emit-relocs-553"
224 run_dump_test_lp64 "emit-relocs-554"
225 run_dump_test_lp64 "emit-relocs-554-overflow"
226 run_dump_test_lp64 "emit-relocs-555"
227 run_dump_test_lp64 "emit-relocs-556"
228 run_dump_test_lp64 "emit-relocs-556-overflow"
229 run_dump_test_lp64 "emit-relocs-557"
230 run_dump_test_lp64 "emit-relocs-558"
231 run_dump_test_lp64 "emit-relocs-558-overflow"
232 run_dump_test_lp64 "emit-relocs-559"
233
234 run_dump_test "reloc-overflow-bad"
235
236 # test addend correctness when --emit-relocs specified for non-relocatable obj.
237 run_dump_test_lp64 "emit-relocs-local-addend"
238 # test addend correctness when -r specified.
239 run_dump_test_lp64 "local-addend-r"
240
241 # test error handling on pcrel relocation for shared libraries.
242 run_dump_test_lp64 "pcrel_pic_undefined"
243 run_dump_test_lp64 "pcrel_pic_defined"
244
245 run_dump_test "limit-b"
246 run_dump_test "limit-bl"
247 run_dump_test "farcall-back"
248 run_dump_test "farcall-b-defsym"
249 run_dump_test "farcall-bl-defsym"
250 run_dump_test "farcall-b-gsym"
251 run_dump_test "farcall-b-plt"
252 run_dump_test "farcall-bl-plt"
253 run_dump_test "farcall-bl"
254 run_dump_test "farcall-b"
255 run_dump_test "farcall-b-none-function"
256 run_dump_test "farcall-bl-none-function"
257 run_dump_test "farcall-b-section"
258 run_dump_test "farcall-bl-section"
259
260 run_dump_test "tls-relax-all"
261 run_dump_test "tls-relax-all-ilp32"
262 run_dump_test "tls-relax-gd-le"
263 run_dump_test "tls-relax-gd-le-ilp32"
264 run_dump_test "tls-relax-gdesc-le"
265 run_dump_test "tls-relax-gdesc-le-now"
266 run_dump_test "tls-relax-gdesc-le-ilp32"
267 run_dump_test "tls-relax-gd-ie"
268 run_dump_test "tls-relax-gd-ie-ilp32"
269 run_dump_test_lp64 "tls-relax-large-gd-ie"
270 run_dump_test_lp64 "tls-relax-large-gd-ie-be"
271 run_dump_test_lp64 "tls-relax-large-gd-le"
272 run_dump_test_lp64 "tls-relax-large-gd-le-be"
273 run_dump_test_lp64 "tls-relax-large-desc-ie"
274 run_dump_test_lp64 "tls-relax-large-desc-ie-be"
275 run_dump_test_lp64 "tls-relax-large-desc-le"
276 run_dump_test_lp64 "tls-relax-large-desc-le-be"
277 run_dump_test "tls-relax-gdesc-ie"
278 run_dump_test "tls-relax-ie-le"
279 run_dump_test "tls-relax-ie-le-ilp32"
280 run_dump_test "tls-relax-ld-le-small"
281 run_dump_test "tls-relax-ld-le-small-ilp32"
282 run_dump_test "tls-relax-ld-le-tiny"
283 run_dump_test "tls-relax-ld-le-tiny-ilp32"
284 run_dump_test "tls-desc-ie"
285 run_dump_test "tls-desc-ie-ilp32"
286 run_dump_test "tls-relax-gdesc-ie-2"
287 run_dump_test "tls-relax-gdesc-le-2"
288 run_dump_test "tls-relax-gdesc-le-2-ilp32"
289 run_dump_test "tls-relax-ie-le-2"
290 run_dump_test "tls-relax-ie-le-2-ilp32"
291 run_dump_test "tls-relax-ie-le-3"
292 run_dump_test "tls-relax-ie-le-3-ilp32"
293 run_dump_test "tls-tiny-gd"
294 run_dump_test "tls-tiny-gd-ie"
295 run_dump_test "tls-tiny-gd-ie-ilp32"
296 run_dump_test "tls-tiny-gd-le"
297 run_dump_test "tls-tiny-gd-le-ilp32"
298 run_dump_test "tls-tiny-desc"
299 run_dump_test "tls-tiny-desc-ie"
300 run_dump_test "tls-tiny-desc-ie-ilp32"
301 run_dump_test "tls-tiny-desc-le"
302 run_dump_test "tls-tiny-desc-le-ilp32"
303 run_dump_test "tls-tiny-ie"
304 run_dump_test_lp64 "tls-large-ie"
305 run_dump_test_lp64 "tls-large-ie-be"
306 run_dump_test_lp64 "tls-large-desc"
307 run_dump_test_lp64 "tls-large-desc-be"
308 run_dump_test "tls-tiny-ld"
309 run_dump_test "tls-small-ld"
310 run_dump_test_lp64 "tlsle"
311 run_dump_test "tlsle-symbol-offset"
312 run_dump_test "gc-got-relocs"
313 run_dump_test "gc-tls-relocs"
314 run_dump_test_lp64 "gc-plt-relocs"
315 run_dump_test_lp64 "gc-relocs-257-dyn"
316 run_dump_test_lp64 "gc-relocs-257"
317 run_dump_test "implicit_got_section_1"
318 run_dump_test "pr17415"
319 run_dump_test_lp64 "tprel_g2_overflow"
320 run_dump_test "tprel_add_lo12_overflow"
321 run_dump_test "protected-data"
322 run_dump_test_lp64 "pr22764"
323 run_dump_test_lp64 "pr20402"
324
325 # ifunc tests
326 run_dump_test "ifunc-1"
327 run_dump_test "ifunc-1-local"
328 run_dump_test "ifunc-2"
329 run_dump_test "ifunc-2-local"
330 run_dump_test "ifunc-3a"
331 run_dump_test "ifunc-3b"
332 run_dump_test "ifunc-4"
333 run_dump_test "ifunc-4a"
334 run_dump_test "ifunc-5a"
335 run_dump_test "ifunc-5b"
336 run_dump_test "ifunc-5a-local"
337 run_dump_test "ifunc-5b-local"
338 run_dump_test "ifunc-5r-local"
339 run_dump_test "ifunc-6a"
340 run_dump_test "ifunc-6b"
341 run_dump_test "ifunc-7a"
342 run_dump_test "ifunc-7b"
343 run_dump_test "ifunc-7c"
344 run_dump_test "ifunc-8"
345 run_dump_test_lp64 "ifunc-9"
346 run_dump_test_lp64 "ifunc-10"
347 run_dump_test_lp64 "ifunc-11"
348 run_dump_test_lp64 "ifunc-12"
349 run_dump_test_lp64 "ifunc-13"
350 run_dump_test "ifunc-14a"
351 run_dump_test "ifunc-14b"
352 run_dump_test "ifunc-14c"
353 run_dump_test "ifunc-14d"
354 run_dump_test "ifunc-14e"
355 run_dump_test "ifunc-14f"
356 run_dump_test "ifunc-15"
357 run_dump_test "ifunc-16"
358 run_dump_test "ifunc-17a"
359 run_dump_test "ifunc-17b"
360 run_dump_test_lp64 "ifunc-18a"
361 run_dump_test_lp64 "ifunc-18b"
362 run_dump_test_lp64 "ifunc-19a"
363 run_dump_test_lp64 "ifunc-19b"
364 run_dump_test_lp64 "ifunc-20"
365 run_dump_test_lp64 "ifunc-21"
366 run_dump_test_lp64 "ifunc-22"
367
368 run_dump_test "relasz"
369 run_dump_test_lp64 "relocs-1027-symbolic-func"
370
371 run_dump_test_lp64 "dt_textrel"
372
373 run_dump_test "plt_mapping_symbol"
374
375 run_dump_test_lp64 "rela-abs-relative"
376 run_dump_test_lp64 "rela-abs-relative-be"
377 run_dump_test_lp64 "rela-abs-relative-opt"
378
379 run_dump_test_lp64 "pie-bind-locally"
380
381 run_dump_test "property-bti-pac1"
382 run_dump_test "property-bti-pac2"
383 run_dump_test "property-bti-pac3"
384 run_dump_test "property-bti-pac4-a"
385 run_dump_test "property-bti-pac4-b"
386 run_dump_test "bti-plt-1"
387 run_dump_test "bti-plt-2"
388
389 run_dump_test_lp64 "variant_pcs-r"
390 run_dump_test_lp64 "variant_pcs-shared"
391 run_dump_test_lp64 "variant_pcs-now"
392
393 set aarch64elflinktests {
394   {"ld-aarch64/so with global symbol" "-shared" "" "" {copy-reloc-so.s}
395     {} "copy-reloc-so.so"}
396   {"ld-aarch64/exe with copy relocation" "-e0 tmpdir/copy-reloc-so.so" "" ""
397     {copy-reloc-exe.s} {{objdump -R copy-reloc.d}} "copy-reloc"}
398   {"ld-aarch64/exe with copy relocation 2" "-e0 tmpdir/copy-reloc-so.so" "" ""
399     {copy-reloc-exe-2.s} {{objdump -R copy-reloc-2.d}} "copy-reloc-2"}
400   {"ld-aarch64/exe with copy relocation elimination" "-e0 tmpdir/copy-reloc-so.so" "" ""
401     {copy-reloc-exe-eliminate.s} {{objdump -R copy-reloc-eliminate.d}} "copy-reloc-elimination"}
402   {"ld-aarch64/so with global func" "-shared" "" "" {func-in-so.s}
403     {} "func-in-so.so"}
404   {"ld-aarch64/func sym hash opt for exe"
405    "-e0 --hash-style=gnu tmpdir/func-in-so.so" "" ""
406     {func-sym-hash-opt.s} {{readelf --dyn-sym func-sym-hash-opt.d}} "hash-opt"}
407   {"Build bti-plt-so for PLT tests" "-shared" "" "" {bti-plt-so.s}
408     {} "libbti-plt-so.so"}
409 }
410
411 run_ld_link_tests $aarch64elflinktests
412
413 run_dump_test "bti-plt-3"
414 run_dump_test "bti-plt-4"
415 run_dump_test "bti-plt-5"
416 run_dump_test "bti-plt-6"
417 run_dump_test "bti-plt-7"
418
419 run_dump_test "pac-plt-1"
420 run_dump_test "pac-plt-2"
421 run_dump_test "bti-pac-plt-1"
422 run_dump_test "bti-pac-plt-2"
423
424 run_dump_test "bti-warn"