1 # Expect script for MIPS ELF linker tests
2 # Copyright (C) 2002-2014 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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,
22 if {[istarget "mips*-*-vxworks"]} {
24 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" ""
25 "-mips2" {vxworks1-lib.s}
26 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
27 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
29 {"VxWorks executable test 1 (dynamic)" \
30 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" ""
32 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
34 {"VxWorks executable test 2 (dynamic)" \
35 "-Tvxworks1.ld -q --force-dynamic" ""
37 {{readelf --segments vxworks2.sd}}
39 {"VxWorks executable test 2 (static)"
42 {{readelf --segments vxworks2-static.sd}}
45 run_ld_link_tests $mipsvxtests
46 run_dump_test "vxworks1-static"
47 run_dump_test "vxworks-forced-local-1"
51 if {![istarget mips*-*-*] || ![is_elf_format]} {
55 set has_newabi [expr [istarget *-*-irix6*] \
56 || [istarget mips*-*-linux*] \
57 || [istarget mips*-sde-elf*] \
58 || [istarget mips*-mti-elf*] \
59 || [istarget mips*-img-elf*]]
60 set linux_gnu [expr [istarget mips*-*-linux*]]
61 set embedded_elf [expr [istarget mips*-*-elf]]
64 set abi_asflags(o32) "-32"
65 set abi_asflags(n32) "-march=from-abi -n32 -EB"
66 set abi_asflags(n64) "-march=from-abi -64 -EB"
67 set abi_ldflags(o32) ""
68 set abi_ldflags(n32) -melf32bmipn32
69 set abi_ldflags(n64) -melf64bmip
72 if { [istarget *-*-irix6*] } {
73 set abi_asflags(o32) "-32 -EB"
74 set abi_ldflags(o32) -melf32bsmip
75 } elseif { [istarget mips64*-linux*] } {
76 set abi_asflags(o32) "-32 -EB"
77 set abi_ldflags(o32) -melf32btsmip
78 } elseif { [istarget mips64*-*freebsd*] } {
79 set abi_asflags(o32) "-32 -EB"
80 set abi_ldflags(o32) -melf32btsmip_fbsd
82 if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*]
83 || [istarget mips*-mti-elf*] || [istarget mips*-img-elf*]} {
84 set abi_ldflags(n32) -melf32btsmipn32
85 set abi_ldflags(n64) -melf64btsmip
86 } elseif { [istarget mips64*-*freebsd*] } {
87 set abi_ldflags(n32) -melf32btsmipn32_fbsd
88 set abi_ldflags(n64) -melf64btsmip_fbsd
92 run_ld_link_tests [list \
93 [list "Dummy shared library for MIPS16 PIC test 1" \
94 "-shared -melf32btsmip" "" \
96 { mips16-pic-1-dummy.s } \
98 "mips16-pic-1-dummy.so"] \
99 [list "MIPS16 PIC test 1" \
100 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
101 "-EB -32 -mips1 -I $srcdir/$subdir" \
102 { mips16-pic-1a.s mips16-pic-1b.s } \
103 { { objdump { -dr -j.text } mips16-pic-1.dd }
104 { readelf -A mips16-pic-1.gd } } \
106 [list "MIPS16 PIC test 2" \
107 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
108 "-EB -32 -mips1 -I $srcdir/$subdir" \
109 { mips16-pic-2a.s mips16-pic-2b.s } \
110 { { objdump { -dr -j.text } mips16-pic-2.dd } \
111 { readelf -A mips16-pic-2.gd } \
112 { readelf --symbols mips16-pic-2.nd } \
113 { readelf --relocs mips16-pic-2.rd } \
114 { readelf -d mips16-pic-2.ad } } \
116 [list "MIPS16 PIC test 3" \
117 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
118 "-EB -32 -mips1 -I $srcdir/$subdir" \
119 { mips16-pic-3a.s mips16-pic-3b.s } \
120 { { objdump -dr mips16-pic-3.dd } \
121 { readelf --relocs mips16-pic-3.rd } \
122 { readelf -A mips16-pic-3.gd } } \
124 [list "MIPS16 PIC test 4 (shared library)" \
125 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
127 { mips16-pic-4a.s mips16-pic-4b.s } \
128 { { objdump -dr mips16-pic-4a.dd } \
129 { readelf --symbols mips16-pic-4a.nd } \
130 { readelf -A mips16-pic-4a.gd } } \
132 [list "MIPS16 PIC test 4 (executable)" \
133 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
135 { mips16-pic-4c.s } \
136 { { objdump -dr mips16-pic-4b.dd } } \
140 # Check MIPS16 markings being passed through link.
141 run_dump_test "mips16-1"
143 # MIPS branch offset final link checking.
144 run_dump_test "branch-misc-1"
147 run_dump_test "jalx-1"
150 run_ld_link_tests [list \
151 [list "Dummy shared library for JALX test 2" \
152 "-shared -nostdlib -melf32btsmip" "" \
153 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
154 { jalx-2-printf.s } \
157 [list "Dummy external function for JALX test 2" \
158 "-r -melf32btsmip" "" \
159 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
163 [list "MIPS JALX test 2" \
164 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
165 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
167 { { objdump -d jalx-2.dd } } \
171 # Test multi-got link. We only do this on GNU/Linux because it requires
172 # the "traditional" emulations.
174 run_dump_test "multi-got-1"
175 run_dump_test "multi-got-no-shared"
176 run_dump_test "multi-got-hidden-1"
177 run_dump_test "multi-got-hidden-2"
180 # Test __gnu_local_gp accesses
182 run_dump_test "no-shared-1-o32"
184 run_dump_test "no-shared-1-n32"
185 run_dump_test "no-shared-1-n64"
190 if { $embedded_elf } {
191 run_dump_test "elf-rel-got-n32-embed" \
192 [list [list ld $abi_ldflags(n32)]]
193 run_dump_test "elf-rel-xgot-n32-embed" \
194 [list [list ld $abi_ldflags(n32)]]
196 run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]]
197 run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]]
200 run_dump_test "elf-rel-got-n64-linux" \
201 [list [list ld $abi_ldflags(n64)]]
202 run_dump_test "elf-rel-xgot-n64-linux" \
203 [list [list ld $abi_ldflags(n64)]]
204 } elseif { $embedded_elf } {
205 run_dump_test "elf-rel-got-n64-embed" \
206 [list [list ld $abi_ldflags(n64)]]
207 run_dump_test "elf-rel-xgot-n64-embed" \
208 [list [list ld $abi_ldflags(n64)]]
210 run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]]
211 run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]]
214 run_dump_test "relax-jalr-n32"
215 run_dump_test "relax-jalr-n32-shared"
216 run_dump_test "relax-jalr-n64"
217 run_dump_test "relax-jalr-n64-shared"
221 run_dump_test "rel32-o32"
223 run_dump_test "rel32-n32"
224 run_dump_test "rel64"
226 # The first test checks that a mixed PIC/non-PIC relocatable link
227 # will not introduce any stubs itself, but will flag PIC functions
228 # for the final link.
230 # The second test checks that we insert stubs for calls from
231 # non-PIC functions to PIC functions when linking the original
232 # two objects together.
234 # The third test checks that we do the same when linking the
235 # result of the first link (with no other source files).
237 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
238 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
239 {{objdump -dr pic-and-nonpic-1-rel.dd}
240 {readelf --symbols pic-and-nonpic-1-rel.nd}}
241 "pic-and-nonpic-1-rel.o"}
242 {"PIC and non-PIC test 1 (static 1)"
243 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
244 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
245 {{objdump -dr pic-and-nonpic-1.dd}
246 {readelf --symbols pic-and-nonpic-1.nd}}
247 "pic-and-nonpic-1-static1.o"}
248 {"PIC and non-PIC test 1 (static 2)"
249 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
251 {{objdump -dr pic-and-nonpic-1.dd}
252 {readelf --symbols pic-and-nonpic-1.nd}}
253 "pic-and-nonpic-1-static2.o"}
255 run_dump_test "pic-and-nonpic-2"
257 {"PIC and non-PIC test 3 (shared library)"
258 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
259 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
260 {{readelf --segments pic-and-nonpic-3a.sd}
261 {readelf -A pic-and-nonpic-3a.gd}
262 {objdump -dr pic-and-nonpic-3a.dd}}
263 "pic-and-nonpic-3a.so"}
264 {"PIC and non-PIC test 3 (executable)"
265 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
266 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
267 {{readelf --segments pic-and-nonpic-3b.sd}
268 {objdump -dr pic-and-nonpic-3b.dd}
269 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
270 {readelf -A pic-and-nonpic-3b.gd}
271 {readelf --relocs pic-and-nonpic-3b.rd}
272 {readelf --symbols pic-and-nonpic-3b.nd}
273 {readelf -d pic-and-nonpic-3b.ad}}
276 run_dump_test "pic-and-nonpic-3-error"
278 {"PIC and non-PIC test 4 (shared library)"
279 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
280 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
282 "pic-and-nonpic-4a.so"}
283 {"PIC and non-PIC test 4 (executable)"
284 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
285 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
286 {{readelf --segments pic-and-nonpic-4b.sd}
287 {objdump -dr pic-and-nonpic-4b.dd}
288 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
289 {readelf --relocs pic-and-nonpic-4b.rd}
290 {readelf --symbols pic-and-nonpic-4b.nd}
291 {readelf -d pic-and-nonpic-4b.ad}}
294 run_dump_test "pic-and-nonpic-4-error"
296 {"PIC and non-PIC test 5 (executable)"
297 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
298 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
299 {{readelf --segments pic-and-nonpic-5b.sd}
300 {objdump -dr pic-and-nonpic-5b.dd}
301 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
302 {readelf -A pic-and-nonpic-5b.gd}
303 {readelf --relocs pic-and-nonpic-5b.rd}
304 {readelf --symbols pic-and-nonpic-5b.nd}
305 {readelf -d pic-and-nonpic-5b.ad}}
308 set abis { o32 -32 elf32btsmip }
310 lappend abis n32 -n32 elf32btsmipn32
311 lappend abis n64 -64 elf64btsmip
313 foreach { abi flag emul } $abis {
314 run_ld_link_tests [list \
315 [list "PIC and non-PIC test 6 ($abi shared library)" \
316 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
318 [list "pic-and-nonpic-6-${abi}a.s"] {} \
319 "pic-and-nonpic-6-${abi}.so"] \
320 [list "PIC and non-PIC test 6 ($abi executable)" \
321 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
323 [list "pic-and-nonpic-6-${abi}b.s" \
324 "pic-and-nonpic-6-${abi}c.s"] \
325 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
326 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
327 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
328 "readelf -A pic-and-nonpic-6-${abi}.gd" \
329 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
330 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
331 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
332 "pic-and-nonpic-6-${abi}"]]
334 # This checks whether our linker scripts get the scope of _gp right,
335 # and must therefore use default scripts. If they don't, then -- in
336 # addition to dumps failing to match -- the final link fails with:
338 # ld: gp-hidden.o: undefined reference to symbol '_gp'
339 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
340 # so try adding it to the linker command line
342 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
343 run_ld_link_tests [list \
345 "_gp scope test ($abi shared library)" \
346 "$abi_ldflags($abi) -shared" "" \
347 "$abi_asflags($abi) -KPIC" \
348 { gp-hidden-lib.s } \
350 "readelf --relocs gp-hidden-lib${suff64}.rd" \
351 "readelf --syms gp-hidden.sd"] \
352 "gp-hidden-lib-${abi}.so"] \
354 "_gp scope test ($abi versioned library)" \
355 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
356 "$abi_asflags($abi) -KPIC" \
357 { gp-hidden-ver.s } \
359 "readelf --relocs gp-hidden-ver${suff64}.rd" \
360 "readelf --syms gp-hidden.sd"] \
361 "gp-hidden-ver-${abi}.so"] \
363 "_gp scope test ($abi executable)" \
364 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
365 "$abi_asflags($abi) -call_nonpic" \
368 "readelf --relocs gp-hidden${suff64}.rd" \
369 "readelf --syms gp-hidden.sd"] \
374 if { $embedded_elf } {
375 run_dump_test "region1"
379 # This could work on other targets too, but would need the appropriate
381 run_dump_test "reloc-1-rel"
384 run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]]
385 run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]]
387 run_dump_test "reloc-2"
388 run_dump_test "reloc-merge-lo16"
389 run_dump_test "reloc-3"
391 run_dump_test "reloc-3-n32"
393 run_dump_test "reloc-4"
394 run_dump_test "reloc-5"
396 run_ld_link_tests [list \
399 "-shared $abi_ldflags(n32)" "" \
400 "$abi_asflags(n32)" \
406 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
407 "$abi_asflags(n32)" \
413 if {$has_newabi && $linux_gnu} {
414 run_dump_test "eh-frame1-n32"
415 run_dump_test "eh-frame1-n64"
416 run_dump_test "eh-frame2-n32"
417 run_dump_test "eh-frame2-n64"
420 run_dump_test "eh-frame3"
421 run_dump_test "eh-frame4"
426 "-melf32btsmip -shared -Teh-frame5.ld" ""
429 {{readelf {--relocs -wf} eh-frame5.d}}
432 run_ld_link_tests $eh_frame5_test
435 run_dump_test "jaloverflow"
436 run_dump_test "jaloverflow-2"
438 run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]]
441 run_dump_test "mode-change-error-1"
443 run_dump_test "mips16-hilo"
445 run_dump_test "mips16-hilo-n32"
450 run_dump_test "textrel-1"
452 run_dump_test "got-page-1"
454 run_dump_test "got-page-2"
455 run_dump_test "dyn-sec64"
457 run_dump_test "got-page-3"
458 run_ld_link_tests [subst {
459 {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
460 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
461 {{objdump -dr got-page-4a.d}
462 {readelf -A got-page-4a.got}}
464 {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
465 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
466 {{objdump -dr got-page-4b.d}
467 {readelf -A got-page-4b.got}}
471 run_ld_link_tests [subst {
472 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
473 "" "$abi_asflags(n32)" {got-page-5.s}
474 {{objdump -dr got-page-5.d}
475 {readelf -A got-page-5.got}}
477 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
478 "" "$abi_asflags(n32)" {got-page-6.s}
479 {{objdump -dr got-page-6.d}
480 {readelf -A got-page-6.got}}
482 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
483 "" "$abi_asflags(n32)"
484 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
486 {{objdump -dr got-page-7.d}
487 {readelf -A got-page-7.got}}
489 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
490 "" "$abi_asflags(n32)"
491 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
493 {{objdump -dr got-page-7.d}
494 {readelf -A got-page-7.got}}
498 run_dump_test "got-dump-1"
500 run_dump_test "got-dump-2"
502 run_dump_test "reloc-estimate-1"
506 run_dump_test "emit-relocs-1"
509 run_dump_test "hash1a"
510 run_dump_test "hash1b"
511 run_dump_test "hash1c"
513 if {[istarget mips*-*-linux*]} {
514 # The number of symbols that are always included in the symbol table
515 # for these tests. The 4 are:
517 # the null symbol entry
518 # the .MIPS.stubs section symbol
520 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
523 "Stub for dynsym 0x$dynsym" \
524 "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \
526 "-EB -march=mips1 -32 -KPIC" \
527 "--defsym base_syms=$base_syms" \
528 "--defsym dynsym=0x$dynsym"] \
529 [list "stub-dynsym-1.s"] \
532 "stub-dynsym-1-$dynsym.d"]] \
533 "stub-dynsym-1-$dynsym"]]
537 # For tests which may involve multiple files, use run_ld_link_tests.
539 # List contains test-items with 3 items followed by 2 lists:
540 # 0:name 1:ld early options 2:ld late options 3:assembler options
541 # 4:filenames of assembler files 5: action and options. 6: name of output file
544 # objdump: Apply objdump options on result. Compare with regex (last arg).
545 # nm: Apply nm options on result. Compare with regex (last arg).
546 # readelf: Apply readelf options on result. Compare with regex (last arg).
549 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
550 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
551 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
553 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
554 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
555 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
557 {"Dynamic executable with TLS"
558 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
559 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
560 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
562 {"Shared library with multiple GOTs and TLS"
563 "-shared -melf32btsmip -T mips-lib.ld" ""
564 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
565 {{readelf {-d -r} tls-multi-got-1.r}
566 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
567 {objdump -Rsj.got tls-multi-got-1.got}}
569 {"Shared library with TLS and versioning"
570 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
571 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
572 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
574 {"Dynamic executable with TLS and versioning"
575 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
576 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
577 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
578 "tls-dynamic-o32-ver"}
579 {"Dynamic executable with TLS and versioning (order 2)"
580 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
581 "-EB -march=mips1 -32 -KPIC" {}
582 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
583 "tls-dynamic-o32-ver-2"}
584 {"Dynamic executable with TLS and versioning (order 3)"
585 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
586 "-EB -march=mips1 -32 -KPIC" {}
587 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
588 "tls-dynamic-o32-ver-3"}
589 {"Shared library with TLS and hidden symbols"
590 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
591 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
592 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
593 "tlslib-o32-hidden.so"}
594 {"Shared library with TLS and hidden symbols (2)"
595 "-shared -melf32btsmip -T mips-lib.ld" ""
596 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
597 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
599 {"Shared library with TLS and hidden symbols (3)"
600 "-shared -melf32btsmip -T tls-hidden3.ld" ""
601 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
602 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
603 {readelf --relocs tls-hidden3.r}}
605 {"Shared library with TLS and hidden symbols (4)"
606 "-shared -melf32btsmip -T tls-hidden3.ld" ""
607 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
608 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
612 if {[istarget mips*-*-linux*]} {
613 run_ld_link_tests $mips_tls_tests
616 set mips16_call_global_test [list \
617 [list "Global calls from mips16" \
618 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
619 "$abi_asflags(o32) -mips32r2" \
620 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
621 {{objdump -dr mips16-call-global.d}} \
622 "mips16-call-global"]]
624 run_ld_link_tests $mips16_call_global_test
626 set mips16_intermix_test [list \
627 [list "Intermixing mips32 and mips16 functions" \
628 "$abi_ldflags(o32)" "" \
629 "$abi_asflags(o32) -mips32r2" \
630 {mips16-intermix-1.s mips16-intermix-2.s} \
631 {{objdump -t mips16-intermix.d}} \
634 run_ld_link_tests $mips16_intermix_test
636 run_dump_test "mips16-local-stubs-1"
638 set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
640 foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
641 foreach secondfpabi [list 4 5 6 7 ] {
642 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
645 foreach firstfpabi [list 4 5 6 7 ] {
646 foreach secondfpabi [list 0 1 2 3 8] {
647 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
650 foreach firstfpabi [list 0 1 2 3 ] {
651 foreach secondfpabi [list 0 1 2 3 8] {
652 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
656 run_dump_test "attr-gnu-4-81"
658 run_dump_test "attr-gnu-8-00"
659 run_dump_test "attr-gnu-8-01"
660 run_dump_test "attr-gnu-8-02"
661 run_dump_test "attr-gnu-8-10"
662 run_dump_test "attr-gnu-8-11"
663 run_dump_test "attr-gnu-8-12"
664 run_dump_test "attr-gnu-8-20"
665 run_dump_test "attr-gnu-8-21"
666 run_dump_test "attr-gnu-8-22"
668 run_dump_test "attr-gnu-4-0-ph" $o32flagslist
669 run_dump_test "attr-gnu-4-1-ph" $o32flagslist
670 run_dump_test "attr-gnu-4-2-ph" $o32flagslist
671 run_dump_test "attr-gnu-4-3-ph" $o32flagslist
672 run_dump_test "attr-gnu-4-4-ph" $o32flagslist
673 run_dump_test "attr-gnu-4-5-ph" $o32flagslist
674 run_dump_test "attr-gnu-4-6-ph" $o32flagslist
675 run_dump_test "attr-gnu-4-7-ph" $o32flagslist
678 run_dump_test "attr-gnu-4-0-n32-ph"
679 run_dump_test "attr-gnu-4-1-n32-ph"
680 run_dump_test "attr-gnu-4-2-n32-ph"
681 run_dump_test "attr-gnu-4-3-n32-ph"
682 run_dump_test "attr-gnu-4-0-n64-ph"
683 run_dump_test "attr-gnu-4-1-n64-ph"
684 run_dump_test "attr-gnu-4-2-n64-ph"
685 run_dump_test "attr-gnu-4-3-n64-ph"
688 run_dump_test "abiflags-strip1-ph" $o32flagslist
689 run_dump_test "abiflags-strip2-ph" $o32flagslist
690 run_dump_test "abiflags-strip3-ph" $o32flagslist
691 run_dump_test "abiflags-strip4-ph" $o32flagslist
692 run_dump_test "abiflags-strip5-ph" $o32flagslist
693 run_dump_test "abiflags-strip6-ph" $o32flagslist
694 run_dump_test "abiflags-strip7-ph" $o32flagslist
695 run_dump_test "abiflags-strip8-ph" $o32flagslist
696 run_dump_test "abiflags-strip9-ph" $o32flagslist
698 run_dump_test "nan-legacy"
699 run_dump_test "nan-2008"
700 run_dump_test "nan-mixed-1"
701 run_dump_test "nan-mixed-2"
705 {"GOT and versioning 1"
706 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
707 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
708 {{readelf -d got-vers-1.dd}
709 {readelf --symbols got-vers-1.sd}
710 {readelf --relocs got-vers-1.rd}}
715 run_dump_test "undefined"
717 # Test the conversion from jr to b
719 run_dump_test "jr-to-b-1"
720 run_dump_test "jr-to-b-2"
723 # MIPS16 and microMIPS interlinking test.
724 run_dump_test "mips16-and-micromips"
726 # Export class call relocation tests.
727 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
728 foreach { abi } $abis {
729 set loadaddr [string map \
730 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
732 [expr { [istarget *-*-irix*] \
733 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
735 run_ld_link_tests [list \
737 "MIPS export class call relocation test ($abi)" \
738 "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \
739 "$abi_asflags($abi) -mips3 -KPIC" \
740 [list export-class-call16-${abi}.s export-class-call16-def.s] \
742 "objdump -d export-class-call16-${suff}.dd" \
743 "readelf -A export-class-call16-${abi}.gd"] \
744 "export-class-call16-${abi}.so"]]
747 # Magic __ehdr_start symbol tests.
748 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
749 foreach { abi } $abis {
750 set suff [string map {o32 o32 n32 new n64 new} $abi]
751 run_ld_link_tests [list \
753 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
754 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
755 "$abi_asflags($abi)" \
756 [list ehdr_start-${suff}.s] \
757 [list "readelf -s ehdr_start-1.nd"] \
758 "ehdr_start-1-${abi}"]]
759 if [regexp "(?:n32|n64)" "$abi"] {
760 setup_kfail "mips*-*-*" "ld/15428"
762 run_ld_link_tests [list \
764 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
765 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
766 "$abi_asflags($abi)" \
767 [list ehdr_start-${suff}.s] \
768 [list "readelf -s ehdr_start-2.nd"] \
769 "ehdr_start-2-${abi}"]]
772 # R_MIPS_JALR reloc tests.
773 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
774 foreach { abi } $abis {
775 run_ld_link_tests [list \
777 "MIPS JALR reloc test ($abi)" \
778 "$abi_ldflags($abi) -T jalr3.ld" "" \
779 "$abi_asflags($abi)" \
780 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
781 [list "objdump -d jalr3.dd"] \
785 proc build_mips_plt_lib { abi } {
789 run_ld_link_tests [list \
790 [list "Shared $abi library for compressed PLT tests" \
791 "-shared $abi_ldflags($abi)" "" \
792 "$abi_asflags($abi)" \
793 { compressed-plt-1-dyn.s } \
795 "compressed-plt-1-${abi}-dyn.so"]]
798 proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
802 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
803 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
804 if {[string equal $abi o32]} {
805 append as_flags " -march=mips2"
807 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
808 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
811 lappend files compressed-plt-1a.s
813 if { $filter & 12 } {
814 lappend files compressed-plt-1b.s
816 if { $filter & 16 } {
817 lappend files compressed-plt-1c.s
819 eval [list lappend files] $extra
820 set readelf_flags "-A --syms --relocs -d"
821 if { [string match "*word*" $suffix] } {
822 append readelf_flags " -x.data"
824 set objdump_flags "-d -Mgpr-names=numeric"
825 set basename "compressed-plt-1-${abi}-${suffix}"
826 run_ld_link_tests [list \
827 [list "$name" $ld_flags $dynobj \
829 [list [list readelf $readelf_flags ${basename}.rd] \
830 [list objdump $objdump_flags ${basename}.od]] \
835 build_mips_plt_lib o32
836 run_mips_plt_test "o32 PLTs for standard encoding" o32 28 0 se
837 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 19 0 mips16-only
838 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 19 1 umips-only
839 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
841 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
842 o32 -1 0 mips16-got compressed-plt-1d.s
843 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
844 o32 -1 0 mips16-word compressed-plt-1e.s
845 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
847 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
848 o32 -1 1 umips-got compressed-plt-1d.s
849 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
850 o32 -1 1 umips-word compressed-plt-1e.s
853 build_mips_plt_lib n32
854 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
856 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \