PR tdep/17379: Fix internal-error when stack pointer is invalid.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
CommitLineData
a657e7c1 1# Expect script for MIPS ELF linker tests
4b95cf5c 2# Copyright (C) 2002-2014 Free Software Foundation, Inc.
a657e7c1 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
a657e7c1 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
a657e7c1
CD
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
a657e7c1
CD
20#
21
0a44bf69
RS
22if {[istarget "mips*-*-vxworks"]} {
23 set mipsvxtests {
897aea50 24 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" ""
0a44bf69
RS
25 "-mips2" {vxworks1-lib.s}
26 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
9e3313ae 27 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
0a44bf69
RS
28 "libvxworks1.so"}
29 {"VxWorks executable test 1 (dynamic)" \
897aea50 30 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" ""
0a44bf69
RS
31 "-mips2" {vxworks1.s}
32 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
33 "vxworks1"}
34 {"VxWorks executable test 2 (dynamic)" \
897aea50 35 "-Tvxworks1.ld -q --force-dynamic" ""
0a44bf69
RS
36 "-mips2" {vxworks2.s}
37 {{readelf --segments vxworks2.sd}}
38 "vxworks2"}
39 {"VxWorks executable test 2 (static)"
897aea50 40 "-Tvxworks1.ld" ""
0a44bf69
RS
41 "-mips2" {vxworks2.s}
42 {{readelf --segments vxworks2-static.sd}}
43 "vxworks2"}
44 }
45 run_ld_link_tests $mipsvxtests
46 run_dump_test "vxworks1-static"
8275b357 47 run_dump_test "vxworks-forced-local-1"
0a44bf69
RS
48 return
49}
50
fbf18a5c
TS
51if {![istarget mips*-*-*] || ![is_elf_format]} {
52 return
53}
30a2f863 54
ef2b5578 55set has_newabi [expr [istarget *-*-irix6*] \
99262e37 56 || [istarget mips*-*-linux*] \
d4a43794
RS
57 || [istarget mips*-sde-elf*] \
58 || [istarget mips*-mti-elf*]]
fbf18a5c
TS
59set linux_gnu [expr [istarget mips*-*-linux*]]
60set embedded_elf [expr [istarget mips*-*-elf]]
30a2f863 61
ef2b5578 62# Set defaults.
e319abb4 63set abi_asflags(o32) "-32"
99262e37
MR
64set abi_asflags(n32) "-march=from-abi -n32 -EB"
65set abi_asflags(n64) "-march=from-abi -64 -EB"
ef2b5578
MR
66set abi_ldflags(o32) ""
67set abi_ldflags(n32) -melf32bmipn32
68set abi_ldflags(n64) -melf64bmip
69
70# Override as needed.
71if { [istarget *-*-irix6*] } {
72 set abi_asflags(o32) "-32 -EB"
73 set abi_ldflags(o32) -melf32bsmip
74} elseif { [istarget mips64*-linux*] } {
75 set abi_asflags(o32) "-32 -EB"
76 set abi_ldflags(o32) -melf32btsmip
77} elseif { [istarget mips64*-*freebsd*] } {
78 set abi_asflags(o32) "-32 -EB"
79 set abi_ldflags(o32) -melf32btsmip_fbsd
80}
d4a43794
RS
81if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*]
82 || [istarget mips*-mti-elf*] } {
ef2b5578
MR
83 set abi_ldflags(n32) -melf32btsmipn32
84 set abi_ldflags(n64) -melf64btsmip
85} elseif { [istarget mips64*-*freebsd*] } {
86 set abi_ldflags(n32) -melf32btsmipn32_fbsd
87 set abi_ldflags(n64) -melf64btsmip_fbsd
88}
89
738e5348
RS
90if { $linux_gnu } {
91 run_ld_link_tests [list \
92 [list "Dummy shared library for MIPS16 PIC test 1" \
897aea50 93 "-shared -melf32btsmip" "" \
3c0bfb2a
RS
94 "-EB -32 -mips1" \
95 { mips16-pic-1-dummy.s } \
738e5348
RS
96 {} \
97 "mips16-pic-1-dummy.so"] \
98 [list "MIPS16 PIC test 1" \
897aea50 99 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
100 "-EB -32 -mips1 -I $srcdir/$subdir" \
101 { mips16-pic-1a.s mips16-pic-1b.s } \
738e5348
RS
102 { { objdump { -dr -j.text } mips16-pic-1.dd }
103 { readelf -A mips16-pic-1.gd } } \
104 "mips16-pic-1"] \
105 [list "MIPS16 PIC test 2" \
897aea50 106 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
3c0bfb2a
RS
107 "-EB -32 -mips1 -I $srcdir/$subdir" \
108 { mips16-pic-2a.s mips16-pic-2b.s } \
738e5348
RS
109 { { objdump { -dr -j.text } mips16-pic-2.dd } \
110 { readelf -A mips16-pic-2.gd } \
111 { readelf --symbols mips16-pic-2.nd } \
112 { readelf --relocs mips16-pic-2.rd } \
113 { readelf -d mips16-pic-2.ad } } \
861fb55a
DJ
114 "mips16-pic-2"] \
115 [list "MIPS16 PIC test 3" \
897aea50 116 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
117 "-EB -32 -mips1 -I $srcdir/$subdir" \
118 { mips16-pic-3a.s mips16-pic-3b.s } \
861fb55a
DJ
119 { { objdump -dr mips16-pic-3.dd } \
120 { readelf --relocs mips16-pic-3.rd } \
121 { readelf -A mips16-pic-3.gd } } \
61b0a4af
RS
122 "mips16-pic-3"] \
123 [list "MIPS16 PIC test 4 (shared library)" \
897aea50 124 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
3c0bfb2a
RS
125 "-EB -32 -mips1" \
126 { mips16-pic-4a.s mips16-pic-4b.s } \
61b0a4af
RS
127 { { objdump -dr mips16-pic-4a.dd } \
128 { readelf --symbols mips16-pic-4a.nd } \
129 { readelf -A mips16-pic-4a.gd } } \
130 "mips16-pic-4.so"] \
131 [list "MIPS16 PIC test 4 (executable)" \
897aea50 132 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
3c0bfb2a
RS
133 "-EB -32 -mips1" \
134 { mips16-pic-4c.s } \
61b0a4af
RS
135 { { objdump -dr mips16-pic-4b.dd } } \
136 "mips16-pic-4"]]
738e5348
RS
137}
138
fbf18a5c
TS
139# Check MIPS16 markings being passed through link.
140run_dump_test "mips16-1"
8914585c 141
fbf18a5c
TS
142# MIPS branch offset final link checking.
143run_dump_test "branch-misc-1"
7d6c7577 144
df58fc94
RS
145# Jalx test
146run_dump_test "jalx-1"
147
148if { $linux_gnu } {
149 run_ld_link_tests [list \
150 [list "Dummy shared library for JALX test 2" \
897aea50 151 "-shared -nostdlib -melf32btsmip" "" \
df58fc94
RS
152 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
153 { jalx-2-printf.s } \
154 {} \
155 "libjalx-2.so"] \
156 [list "Dummy external function for JALX test 2" \
897aea50 157 "-r -melf32btsmip" "" \
df58fc94
RS
158 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
159 { jalx-2-ex.s } \
160 {} \
161 "jalx-2-ex.o.r"] \
162 [list "MIPS JALX test 2" \
897aea50 163 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
df58fc94
RS
164 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
165 { jalx-2-main.s } \
166 { { objdump -d jalx-2.dd } } \
167 "jalx-2"]]
168}
169
732be173
DJ
170# Test multi-got link. We only do this on GNU/Linux because it requires
171# the "traditional" emulations.
172if { $linux_gnu } {
173 run_dump_test "multi-got-1"
bbe506e8 174 run_dump_test "multi-got-no-shared"
2152e047
DJ
175 run_dump_test "multi-got-hidden-1"
176 run_dump_test "multi-got-hidden-2"
732be173 177}
30a2f863 178
0a61c8c2
RS
179# Test __gnu_local_gp accesses
180if { $linux_gnu } {
181 run_dump_test "no-shared-1-o32"
182 if { $has_newabi } {
183 run_dump_test "no-shared-1-n32"
184 run_dump_test "no-shared-1-n64"
185 }
186}
187
fbf18a5c 188if $has_newabi {
ef2b5578
MR
189 if { $embedded_elf } {
190 run_dump_test "elf-rel-got-n32-embed" \
191 [list [list ld $abi_ldflags(n32)]]
192 run_dump_test "elf-rel-xgot-n32-embed" \
193 [list [list ld $abi_ldflags(n32)]]
194 } else {
195 run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]]
196 run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]]
197 }
48fe7bda 198 if { $linux_gnu } {
ef2b5578
MR
199 run_dump_test "elf-rel-got-n64-linux" \
200 [list [list ld $abi_ldflags(n64)]]
201 run_dump_test "elf-rel-xgot-n64-linux" \
202 [list [list ld $abi_ldflags(n64)]]
203 } elseif { $embedded_elf } {
204 run_dump_test "elf-rel-got-n64-embed" \
205 [list [list ld $abi_ldflags(n64)]]
206 run_dump_test "elf-rel-xgot-n64-embed" \
207 [list [list ld $abi_ldflags(n64)]]
fbf18a5c 208 } else {
ef2b5578
MR
209 run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]]
210 run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]]
48fe7bda
AO
211 }
212
fbf18a5c
TS
213 run_dump_test "relax-jalr-n32"
214 run_dump_test "relax-jalr-n32-shared"
215 run_dump_test "relax-jalr-n64"
216 run_dump_test "relax-jalr-n64-shared"
217}
48fe7bda 218
fbf18a5c
TS
219if { $linux_gnu } {
220 run_dump_test "rel32-o32"
250826bd
RS
221 if { $has_newabi } {
222 run_dump_test "rel32-n32"
223 run_dump_test "rel64"
224 }
861fb55a
DJ
225 # The first test checks that a mixed PIC/non-PIC relocatable link
226 # will not introduce any stubs itself, but will flag PIC functions
227 # for the final link.
228 #
229 # The second test checks that we insert stubs for calls from
230 # non-PIC functions to PIC functions when linking the original
231 # two objects together.
232 #
233 # The third test checks that we do the same when linking the
234 # result of the first link (with no other source files).
235 run_ld_link_tests {
897aea50 236 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
861fb55a
DJ
237 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
238 {{objdump -dr pic-and-nonpic-1-rel.dd}
239 {readelf --symbols pic-and-nonpic-1-rel.nd}}
240 "pic-and-nonpic-1-rel.o"}
241 {"PIC and non-PIC test 1 (static 1)"
897aea50 242 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
861fb55a
DJ
243 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
244 {{objdump -dr pic-and-nonpic-1.dd}
245 {readelf --symbols pic-and-nonpic-1.nd}}
246 "pic-and-nonpic-1-static1.o"}
247 {"PIC and non-PIC test 1 (static 2)"
897aea50 248 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
861fb55a
DJ
249 "" {}
250 {{objdump -dr pic-and-nonpic-1.dd}
251 {readelf --symbols pic-and-nonpic-1.nd}}
252 "pic-and-nonpic-1-static2.o"}
253 }
254 run_dump_test "pic-and-nonpic-2"
255 run_ld_link_tests {
256 {"PIC and non-PIC test 3 (shared library)"
897aea50 257 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
258 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
259 {{readelf --segments pic-and-nonpic-3a.sd}
260 {readelf -A pic-and-nonpic-3a.gd}
261 {objdump -dr pic-and-nonpic-3a.dd}}
262 "pic-and-nonpic-3a.so"}
263 {"PIC and non-PIC test 3 (executable)"
897aea50 264 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
861fb55a
DJ
265 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
266 {{readelf --segments pic-and-nonpic-3b.sd}
267 {objdump -dr pic-and-nonpic-3b.dd}
268 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
269 {readelf -A pic-and-nonpic-3b.gd}
270 {readelf --relocs pic-and-nonpic-3b.rd}
271 {readelf --symbols pic-and-nonpic-3b.nd}
272 {readelf -d pic-and-nonpic-3b.ad}}
273 "pic-and-nonpic-3b"}
274 }
275 run_dump_test "pic-and-nonpic-3-error"
276 run_ld_link_tests {
277 {"PIC and non-PIC test 4 (shared library)"
897aea50 278 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
279 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
280 {}
281 "pic-and-nonpic-4a.so"}
282 {"PIC and non-PIC test 4 (executable)"
897aea50 283 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
284 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
285 {{readelf --segments pic-and-nonpic-4b.sd}
286 {objdump -dr pic-and-nonpic-4b.dd}
287 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
288 {readelf --relocs pic-and-nonpic-4b.rd}
289 {readelf --symbols pic-and-nonpic-4b.nd}
290 {readelf -d pic-and-nonpic-4b.ad}}
291 "pic-and-nonpic-4b"}
292 }
293 run_dump_test "pic-and-nonpic-4-error"
294 run_ld_link_tests {
295 {"PIC and non-PIC test 5 (executable)"
897aea50 296 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
297 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
298 {{readelf --segments pic-and-nonpic-5b.sd}
299 {objdump -dr pic-and-nonpic-5b.dd}
300 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
301 {readelf -A pic-and-nonpic-5b.gd}
302 {readelf --relocs pic-and-nonpic-5b.rd}
303 {readelf --symbols pic-and-nonpic-5b.nd}
304 {readelf -d pic-and-nonpic-5b.ad}}
305 "pic-and-nonpic-5b"}
306 }
307 set abis { o32 -32 elf32btsmip }
308 if $has_newabi {
309 lappend abis n32 -n32 elf32btsmipn32
310 lappend abis n64 -64 elf64btsmip
311 }
312 foreach { abi flag emul } $abis {
313 run_ld_link_tests [list \
314 [list "PIC and non-PIC test 6 ($abi shared library)" \
897aea50 315 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
861fb55a
DJ
316 "$flag -EB -mips3" \
317 [list "pic-and-nonpic-6-${abi}a.s"] {} \
318 "pic-and-nonpic-6-${abi}.so"] \
319 [list "PIC and non-PIC test 6 ($abi executable)" \
897aea50 320 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
861fb55a
DJ
321 "$flag -EB -mips3" \
322 [list "pic-and-nonpic-6-${abi}b.s" \
323 "pic-and-nonpic-6-${abi}c.s"] \
324 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
325 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
326 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
327 "readelf -A pic-and-nonpic-6-${abi}.gd" \
328 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
329 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
330 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
331 "pic-and-nonpic-6-${abi}"]]
43b5366b
MR
332
333 # This checks whether our linker scripts get the scope of _gp right,
334 # and must therefore use default scripts. If they don't, then -- in
335 # addition to dumps failing to match -- the final link fails with:
336 #
337 # ld: gp-hidden.o: undefined reference to symbol '_gp'
338 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
339 # so try adding it to the linker command line
340 #
341 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
342 run_ld_link_tests [list \
343 [list \
344 "_gp scope test ($abi shared library)" \
897aea50 345 "$abi_ldflags($abi) -shared" "" \
43b5366b
MR
346 "$abi_asflags($abi) -KPIC" \
347 { gp-hidden-lib.s } \
348 [list \
349 "readelf --relocs gp-hidden-lib${suff64}.rd" \
350 "readelf --syms gp-hidden.sd"] \
351 "gp-hidden-lib-${abi}.so"] \
352 [list \
353 "_gp scope test ($abi versioned library)" \
897aea50 354 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
43b5366b
MR
355 "$abi_asflags($abi) -KPIC" \
356 { gp-hidden-ver.s } \
357 [list \
358 "readelf --relocs gp-hidden-ver${suff64}.rd" \
359 "readelf --syms gp-hidden.sd"] \
360 "gp-hidden-ver-${abi}.so"] \
361 [list \
362 "_gp scope test ($abi executable)" \
897aea50 363 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
43b5366b
MR
364 "$abi_asflags($abi) -call_nonpic" \
365 { gp-hidden.s } \
366 [list \
367 "readelf --relocs gp-hidden${suff64}.rd" \
368 "readelf --syms gp-hidden.sd"] \
369 "gp-hidden-${abi}"]]
861fb55a 370 }
fbf18a5c 371}
a657e7c1 372
fbf18a5c 373if { $embedded_elf } {
fbf18a5c 374 run_dump_test "region1"
a657e7c1 375}
18ab1921
RS
376
377if $embedded_elf {
378 # This could work on other targets too, but would need the appropriate
379 # ld -m switch.
380 run_dump_test "reloc-1-rel"
381}
382if $has_newabi {
ef2b5578
MR
383 run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]]
384 run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]]
18ab1921
RS
385}
386run_dump_test "reloc-2"
17a6716a 387run_dump_test "reloc-merge-lo16"
3b788261
TS
388run_dump_test "reloc-3"
389if {$has_newabi} {
390 run_dump_test "reloc-3-n32"
391}
43ec5bc0
AN
392run_dump_test "reloc-4"
393run_dump_test "reloc-5"
77c56f44 394if { $has_newabi } {
ef2b5578
MR
395 run_ld_link_tests [list \
396 [list \
397 "reloc test 6a" \
897aea50 398 "-shared $abi_ldflags(n32)" "" \
cde00cbb 399 "$abi_asflags(n32)" \
ef2b5578
MR
400 "reloc-6a.s" \
401 {} \
402 "reloc-6a.so"] \
403 [list \
404 "reloc test 6b" \
897aea50 405 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
cde00cbb 406 "$abi_asflags(n32)" \
ef2b5578
MR
407 "reloc-6b.s" \
408 {} \
409 "reloc-6b"]]
77c56f44 410}
43ec5bc0 411
353057a5
RS
412if {$has_newabi && $linux_gnu} {
413 run_dump_test "eh-frame1-n32"
414 run_dump_test "eh-frame1-n64"
dcf507a6
RS
415 run_dump_test "eh-frame2-n32"
416 run_dump_test "eh-frame2-n64"
353057a5 417}
8c946ed5
RS
418if {$embedded_elf} {
419 run_dump_test "eh-frame3"
420 run_dump_test "eh-frame4"
421}
18e04883
RS
422if {$linux_gnu} {
423 set eh_frame5_test {
424 {"MIPS eh-frame 5"
897aea50 425 "-melf32btsmip -shared -Teh-frame5.ld" ""
18e04883
RS
426 "-32 -EB"
427 {eh-frame5.s}
428 {{readelf {--relocs -wf} eh-frame5.d}}
429 "eh-frame5.so"}
430 }
431 run_ld_link_tests $eh_frame5_test
432}
0efd4160
ILT
433
434run_dump_test "jaloverflow"
c314987d 435run_dump_test "jaloverflow-2"
1f0f3e9b 436if {$has_newabi} {
ef2b5578 437 run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]]
1f0f3e9b 438}
d6f16593 439
776167e8
CM
440run_dump_test "mode-change-error-1"
441
d6f16593
MR
442run_dump_test "mips16-hilo"
443if {$has_newabi} {
444 run_dump_test "mips16-hilo-n32"
445}
f4e584bd 446
cc27e1dc 447if { $linux_gnu } {
250826bd
RS
448 if { $has_newabi } {
449 run_dump_test "textrel-1"
450 }
c224138d
RS
451 run_dump_test "got-page-1"
452 if $has_newabi {
453 run_dump_test "got-page-2"
08b55522 454 run_dump_test "dyn-sec64"
c224138d
RS
455 }
456 run_dump_test "got-page-3"
13db6b44
RS
457 run_ld_link_tests [subst {
458 {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
897aea50 459 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
13db6b44
RS
460 {{objdump -dr got-page-4a.d}
461 {readelf -A got-page-4a.got}}
462 "got-page-4a.so"}
463 {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
897aea50 464 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
13db6b44
RS
465 {{objdump -dr got-page-4b.d}
466 {readelf -A got-page-4b.got}}
467 "got-page-4b.so"}
468 }]
469 if $has_newabi {
470 run_ld_link_tests [subst {
471 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 472 "" "$abi_asflags(n32)" {got-page-5.s}
13db6b44
RS
473 {{objdump -dr got-page-5.d}
474 {readelf -A got-page-5.got}}
475 "got-page-5.so"}
476 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 477 "" "$abi_asflags(n32)" {got-page-6.s}
13db6b44
RS
478 {{objdump -dr got-page-6.d}
479 {readelf -A got-page-6.got}}
480 "got-page-6.so"}
481 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 482 "" "$abi_asflags(n32)"
13db6b44
RS
483 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
484 got-page-7e.s}
485 {{objdump -dr got-page-7.d}
486 {readelf -A got-page-7.got}}
487 "got-page-7a.so"}
488 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 489 "" "$abi_asflags(n32)"
13db6b44
RS
490 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
491 got-page-7d.s}
492 {{objdump -dr got-page-7.d}
493 {readelf -A got-page-7.got}}
494 "got-page-7b.so"}
495 }]
496 }
ccb4c951
RS
497 run_dump_test "got-dump-1"
498 if $has_newabi {
499 run_dump_test "got-dump-2"
500 }
63897e2c 501 run_dump_test "reloc-estimate-1"
cc27e1dc
EC
502}
503
81d43bff
RS
504if $has_newabi {
505 run_dump_test "emit-relocs-1"
506}
507
73934d31
RS
508run_dump_test "hash1a"
509run_dump_test "hash1b"
510run_dump_test "hash1c"
511
5108fc1b
RS
512if {[istarget mips*-*-linux*]} {
513 # The number of symbols that are always included in the symbol table
74541ad4 514 # for these tests. The 4 are:
5108fc1b
RS
515 #
516 # the null symbol entry
517 # the .MIPS.stubs section symbol
2f9efdfc 518 set base_syms 2
5108fc1b
RS
519 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
520 run_ld_link_tests \
521 [list [list \
522 "Stub for dynsym 0x$dynsym" \
897aea50 523 "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \
5108fc1b
RS
524 [concat \
525 "-EB -march=mips1 -32 -KPIC" \
526 "--defsym base_syms=$base_syms" \
527 "--defsym dynsym=0x$dynsym"] \
528 [list "stub-dynsym-1.s"] \
529 [list [list \
530 "objdump" "-dz" \
531 "stub-dynsym-1-$dynsym.d"]] \
532 "stub-dynsym-1-$dynsym"]]
533 }
534 }
535
f4e584bd
DJ
536# For tests which may involve multiple files, use run_ld_link_tests.
537
538# List contains test-items with 3 items followed by 2 lists:
897aea50
MR
539# 0:name 1:ld early options 2:ld late options 3:assembler options
540# 4:filenames of assembler files 5: action and options. 6: name of output file
f4e584bd
DJ
541
542# Actions:
543# objdump: Apply objdump options on result. Compare with regex (last arg).
544# nm: Apply nm options on result. Compare with regex (last arg).
545# readelf: Apply readelf options on result. Compare with regex (last arg).
546
547set mips_tls_tests {
897aea50 548 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
f4e584bd
DJ
549 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
550 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
551 "tls-static-o32"}
897aea50 552 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
553 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
554 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
555 "tlslib-o32.so"}
556 {"Dynamic executable with TLS"
897aea50 557 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
f4e584bd
DJ
558 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
559 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
560 "tls-dynamic-o32"}
561 {"Shared library with multiple GOTs and TLS"
897aea50 562 "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
563 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
564 {{readelf {-d -r} tls-multi-got-1.r}
565 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
566 {objdump -Rsj.got tls-multi-got-1.got}}
567 "tlslib-multi.so"}
568 {"Shared library with TLS and versioning"
897aea50 569 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
f4e584bd
DJ
570 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
571 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
572 "tlslib-o32-ver.so"}
573 {"Dynamic executable with TLS and versioning"
897aea50 574 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
f4e584bd
DJ
575 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
576 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
577 "tls-dynamic-o32-ver"}
578 {"Dynamic executable with TLS and versioning (order 2)"
897aea50 579 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
f4e584bd
DJ
580 "-EB -march=mips1 -32 -KPIC" {}
581 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
582 "tls-dynamic-o32-ver-2"}
583 {"Dynamic executable with TLS and versioning (order 3)"
897aea50 584 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
f4e584bd
DJ
585 "-EB -march=mips1 -32 -KPIC" {}
586 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
587 "tls-dynamic-o32-ver-3"}
588 {"Shared library with TLS and hidden symbols"
897aea50 589 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
f4e584bd
DJ
590 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
591 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
592 "tlslib-o32-hidden.so"}
4005427f 593 {"Shared library with TLS and hidden symbols (2)"
897aea50 594 "-shared -melf32btsmip -T mips-lib.ld" ""
4005427f
RS
595 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
596 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
597 "tls-hidden2.so"}
ead49a57 598 {"Shared library with TLS and hidden symbols (3)"
897aea50 599 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
600 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
601 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
602 {readelf --relocs tls-hidden3.r}}
603 "tls-hidden3.so"}
604 {"Shared library with TLS and hidden symbols (4)"
897aea50 605 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
606 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
607 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
608 "tls-hidden4.so"}
f4e584bd
DJ
609}
610
611if {[istarget mips*-*-linux*]} {
612 run_ld_link_tests $mips_tls_tests
613}
614
08e8dfaf
RS
615set mips16_call_global_test [list \
616 [list "Global calls from mips16" \
897aea50 617 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
ef2b5578 618 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
619 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
620 {{objdump -dr mips16-call-global.d}} \
621 "mips16-call-global"]]
35d3d567
TS
622
623run_ld_link_tests $mips16_call_global_test
b9d58d71 624
08e8dfaf
RS
625set mips16_intermix_test [list \
626 [list "Intermixing mips32 and mips16 functions" \
897aea50 627 "$abi_ldflags(o32)" "" \
ef2b5578 628 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
629 {mips16-intermix-1.s mips16-intermix-2.s} \
630 {{objdump -t mips16-intermix.d}} \
631 "mips16-intermix"]]
b9d58d71
TS
632
633run_ld_link_tests $mips16_intermix_test
b314ec0e
RS
634
635run_dump_test "mips16-local-stubs-1"
2cf19d5c 636
e319abb4
MF
637set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
638
351cdf24 639foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
e319abb4
MF
640 foreach secondfpabi [list 4 5 6 7 ] {
641 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
642 }
643}
644foreach firstfpabi [list 4 5 6 7 ] {
645 foreach secondfpabi [list 0 1 2 3 8] {
646 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
647 }
648}
649foreach firstfpabi [list 0 1 2 3 ] {
650 foreach secondfpabi [list 0 1 2 3 8] {
351cdf24
MF
651 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
652 }
653}
e319abb4 654
351cdf24
MF
655run_dump_test "attr-gnu-4-81"
656
657run_dump_test "attr-gnu-8-00"
658run_dump_test "attr-gnu-8-01"
659run_dump_test "attr-gnu-8-02"
660run_dump_test "attr-gnu-8-10"
661run_dump_test "attr-gnu-8-11"
662run_dump_test "attr-gnu-8-12"
663run_dump_test "attr-gnu-8-20"
664run_dump_test "attr-gnu-8-21"
665run_dump_test "attr-gnu-8-22"
666
e319abb4
MF
667run_dump_test "attr-gnu-4-0-ph" $o32flagslist
668run_dump_test "attr-gnu-4-1-ph" $o32flagslist
669run_dump_test "attr-gnu-4-2-ph" $o32flagslist
670run_dump_test "attr-gnu-4-3-ph" $o32flagslist
671run_dump_test "attr-gnu-4-4-ph" $o32flagslist
672run_dump_test "attr-gnu-4-5-ph" $o32flagslist
673run_dump_test "attr-gnu-4-6-ph" $o32flagslist
674run_dump_test "attr-gnu-4-7-ph" $o32flagslist
675
676if $has_newabi {
677 run_dump_test "attr-gnu-4-0-n32-ph"
678 run_dump_test "attr-gnu-4-1-n32-ph"
679 run_dump_test "attr-gnu-4-2-n32-ph"
680 run_dump_test "attr-gnu-4-3-n32-ph"
681 run_dump_test "attr-gnu-4-0-n64-ph"
682 run_dump_test "attr-gnu-4-1-n64-ph"
683 run_dump_test "attr-gnu-4-2-n64-ph"
684 run_dump_test "attr-gnu-4-3-n64-ph"
685}
686
687run_dump_test "abiflags-strip1-ph" $o32flagslist
688run_dump_test "abiflags-strip2-ph" $o32flagslist
689run_dump_test "abiflags-strip3-ph" $o32flagslist
690run_dump_test "abiflags-strip4-ph" $o32flagslist
691run_dump_test "abiflags-strip5-ph" $o32flagslist
692run_dump_test "abiflags-strip6-ph" $o32flagslist
693run_dump_test "abiflags-strip7-ph" $o32flagslist
694run_dump_test "abiflags-strip8-ph" $o32flagslist
695run_dump_test "abiflags-strip9-ph" $o32flagslist
634835ae 696
ba92f887
MR
697run_dump_test "nan-legacy"
698run_dump_test "nan-2008"
699run_dump_test "nan-mixed-1"
700run_dump_test "nan-mixed-2"
701
634835ae
RS
702if { $linux_gnu } {
703 run_ld_link_tests {
704 {"GOT and versioning 1"
897aea50 705 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
634835ae
RS
706 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
707 {{readelf -d got-vers-1.dd}
708 {readelf --symbols got-vers-1.sd}
709 {readelf --relocs got-vers-1.rd}}
710 "got-vers-1.so"}
711 }
712}
e7e2196d
MR
713
714run_dump_test "undefined"
1063d8cf
CF
715
716# Test the conversion from jr to b
717if { $linux_gnu } {
718 run_dump_test "jr-to-b-1"
719 run_dump_test "jr-to-b-2"
720}
df58fc94
RS
721
722# MIPS16 and microMIPS interlinking test.
723run_dump_test "mips16-and-micromips"
9b11fa1a
MR
724
725# Export class call relocation tests.
726set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
727foreach { abi } $abis {
728 set loadaddr [string map \
729 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
730 set suff [subst \
731 [expr { [istarget *-*-irix*] \
732 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
733 : $abi }]]
734 run_ld_link_tests [list \
735 [list \
736 "MIPS export class call relocation test ($abi)" \
897aea50 737 "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \
9b11fa1a
MR
738 "$abi_asflags($abi) -mips3 -KPIC" \
739 [list export-class-call16-${abi}.s export-class-call16-def.s] \
740 [list \
741 "objdump -d export-class-call16-${suff}.dd" \
742 "readelf -A export-class-call16-${abi}.gd"] \
743 "export-class-call16-${abi}.so"]]
744}
cde7cb01
MR
745
746# Magic __ehdr_start symbol tests.
747set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
748foreach { abi } $abis {
749 set suff [string map {o32 o32 n32 new n64 new} $abi]
750 run_ld_link_tests [list \
751 [list \
752 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
753 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
754 "$abi_asflags($abi)" \
755 [list ehdr_start-${suff}.s] \
756 [list "readelf -s ehdr_start-1.nd"] \
757 "ehdr_start-1-${abi}"]]
758 if [regexp "(?:n32|n64)" "$abi"] {
759 setup_kfail "mips*-*-*" "ld/15428"
760 }
761 run_ld_link_tests [list \
762 [list \
763 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
764 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
765 "$abi_asflags($abi)" \
766 [list ehdr_start-${suff}.s] \
767 [list "readelf -s ehdr_start-2.nd"] \
768 "ehdr_start-2-${abi}"]]
769}
d6101ac2
MR
770
771# R_MIPS_JALR reloc tests.
772set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
773foreach { abi } $abis {
774 run_ld_link_tests [list \
775 [list \
776 "MIPS JALR reloc test ($abi)" \
777 "$abi_ldflags($abi) -T jalr3.ld" "" \
778 "$abi_asflags($abi)" \
779 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
780 [list "objdump -d jalr3.dd"] \
781 "jalr3-${abi}"]]
782}
690f47bf
RS
783
784proc build_mips_plt_lib { abi } {
785 global abi_asflags
786 global abi_ldflags
787
788 run_ld_link_tests [list \
789 [list "Shared $abi library for compressed PLT tests" \
790 "-shared $abi_ldflags($abi)" "" \
791 "$abi_asflags($abi)" \
792 { compressed-plt-1-dyn.s } \
793 {} \
794 "compressed-plt-1-${abi}-dyn.so"]]
795}
796
797proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
798 global abi_asflags
799 global abi_ldflags
800
801 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
802 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
803 if {[string equal $abi o32]} {
804 append as_flags " -march=mips2"
805 }
806 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
807 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
808 set files [list]
809 if { $filter & 3 } {
810 lappend files compressed-plt-1a.s
811 }
812 if { $filter & 12 } {
813 lappend files compressed-plt-1b.s
814 }
815 if { $filter & 16 } {
816 lappend files compressed-plt-1c.s
817 }
818 eval [list lappend files] $extra
819 set readelf_flags "-A --syms --relocs -d"
820 if { [string match "*word*" $suffix] } {
821 append readelf_flags " -x.data"
822 }
823 set objdump_flags "-d -Mgpr-names=numeric"
824 set basename "compressed-plt-1-${abi}-${suffix}"
825 run_ld_link_tests [list \
826 [list "$name" $ld_flags $dynobj \
827 "$as_flags" $files \
828 [list [list readelf $readelf_flags ${basename}.rd] \
829 [list objdump $objdump_flags ${basename}.od]] \
830 $basename]]
831}
832
833if { $linux_gnu } {
834 build_mips_plt_lib o32
835 run_mips_plt_test "o32 PLTs for standard encoding" o32 28 0 se
836 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 19 0 mips16-only
837 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 19 1 umips-only
838 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
839 o32 -1 0 mips16
840 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
841 o32 -1 0 mips16-got compressed-plt-1d.s
842 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
843 o32 -1 0 mips16-word compressed-plt-1e.s
844 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
845 o32 -1 1 umips
846 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
847 o32 -1 1 umips-got compressed-plt-1d.s
848 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
849 o32 -1 1 umips-word compressed-plt-1e.s
850
851 if $has_newabi {
852 build_mips_plt_lib n32
853 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
854 n32 -1 0 mips16
855 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
856 n32 -1 1 umips
857 }
858}
This page took 0.75127 seconds and 4 git commands to generate.