Update year range in copyright notice of all files.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
CommitLineData
a657e7c1 1# Expect script for MIPS ELF linker tests
2571583a 2# Copyright (C) 2002-2017 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 57 || [istarget mips*-sde-elf*] \
a9d58c06
AB
58 || [istarget mips*-mti-elf*] \
59 || [istarget mips*-img-elf*]]
fbf18a5c
TS
60set linux_gnu [expr [istarget mips*-*-linux*]]
61set embedded_elf [expr [istarget mips*-*-elf]]
30a2f863 62
ef2b5578 63# Set defaults.
e319abb4 64set abi_asflags(o32) "-32"
99262e37
MR
65set abi_asflags(n32) "-march=from-abi -n32 -EB"
66set abi_asflags(n64) "-march=from-abi -64 -EB"
ef2b5578
MR
67set abi_ldflags(o32) ""
68set abi_ldflags(n32) -melf32bmipn32
69set abi_ldflags(n64) -melf64bmip
70
71# Override as needed.
72if { [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
81}
d4a43794 82if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*]
a9d58c06 83 || [istarget mips*-mti-elf*] || [istarget mips*-img-elf*]} {
ef2b5578
MR
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
89}
90
738e5348
RS
91if { $linux_gnu } {
92 run_ld_link_tests [list \
93 [list "Dummy shared library for MIPS16 PIC test 1" \
897aea50 94 "-shared -melf32btsmip" "" \
3c0bfb2a
RS
95 "-EB -32 -mips1" \
96 { mips16-pic-1-dummy.s } \
738e5348
RS
97 {} \
98 "mips16-pic-1-dummy.so"] \
99 [list "MIPS16 PIC test 1" \
897aea50 100 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
101 "-EB -32 -mips1 -I $srcdir/$subdir" \
102 { mips16-pic-1a.s mips16-pic-1b.s } \
738e5348
RS
103 { { objdump { -dr -j.text } mips16-pic-1.dd }
104 { readelf -A mips16-pic-1.gd } } \
105 "mips16-pic-1"] \
106 [list "MIPS16 PIC test 2" \
897aea50 107 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
3c0bfb2a
RS
108 "-EB -32 -mips1 -I $srcdir/$subdir" \
109 { mips16-pic-2a.s mips16-pic-2b.s } \
738e5348
RS
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 } } \
861fb55a
DJ
115 "mips16-pic-2"] \
116 [list "MIPS16 PIC test 3" \
897aea50 117 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
118 "-EB -32 -mips1 -I $srcdir/$subdir" \
119 { mips16-pic-3a.s mips16-pic-3b.s } \
861fb55a
DJ
120 { { objdump -dr mips16-pic-3.dd } \
121 { readelf --relocs mips16-pic-3.rd } \
122 { readelf -A mips16-pic-3.gd } } \
61b0a4af
RS
123 "mips16-pic-3"] \
124 [list "MIPS16 PIC test 4 (shared library)" \
897aea50 125 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
3c0bfb2a
RS
126 "-EB -32 -mips1" \
127 { mips16-pic-4a.s mips16-pic-4b.s } \
61b0a4af
RS
128 { { objdump -dr mips16-pic-4a.dd } \
129 { readelf --symbols mips16-pic-4a.nd } \
130 { readelf -A mips16-pic-4a.gd } } \
131 "mips16-pic-4.so"] \
132 [list "MIPS16 PIC test 4 (executable)" \
897aea50 133 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
3c0bfb2a
RS
134 "-EB -32 -mips1" \
135 { mips16-pic-4c.s } \
61b0a4af
RS
136 { { objdump -dr mips16-pic-4b.dd } } \
137 "mips16-pic-4"]]
738e5348
RS
138}
139
fbf18a5c
TS
140# Check MIPS16 markings being passed through link.
141run_dump_test "mips16-1"
8914585c 142
fbf18a5c
TS
143# MIPS branch offset final link checking.
144run_dump_test "branch-misc-1"
6f50d611 145run_dump_test "branch-misc-2"
0c117286 146run_dump_test "branch-absolute" [list [list ld $abi_ldflags(o32)]]
b416ba9b 147run_dump_test "branch-absolute-addend" [list [list ld $abi_ldflags(o32)]]
0c117286
MR
148if $has_newabi {
149 run_dump_test "branch-absolute-n32" [list [list ld $abi_ldflags(n32)]]
150 run_dump_test "branch-absolute-addend-n32" \
151 [list [list ld $abi_ldflags(n32)]]
152 run_dump_test "branch-absolute-n64" [list [list ld $abi_ldflags(n64)]]
153 run_dump_test "branch-absolute-addend-n64" \
154 [list [list ld $abi_ldflags(n64)]]
155}
7d6c7577 156
c9775dde
MR
157run_dump_test "mips16-branch-2" [list [list ld $abi_ldflags(o32)]]
158run_dump_test "mips16-branch-3" [list [list ld $abi_ldflags(o32)]]
159run_dump_test "mips16-branch-addend-2" [list [list ld $abi_ldflags(o32)]]
160run_dump_test "mips16-branch-addend-3" [list [list ld $abi_ldflags(o32)]]
b416ba9b
MR
161run_dump_test "mips16-branch-absolute" [list [list ld $abi_ldflags(o32)]]
162run_dump_test "mips16-branch-absolute-addend" \
163 [list [list ld $abi_ldflags(o32)]]
96e9ba5f
MR
164if $has_newabi {
165 run_dump_test "mips16-branch-absolute-n32" \
166 [list [list ld $abi_ldflags(n32)]]
167 run_dump_test "mips16-branch-absolute-addend-n32" \
168 [list [list ld $abi_ldflags(n32)]]
169 run_dump_test "mips16-branch-absolute-n64" \
170 [list [list ld $abi_ldflags(n64)]]
171 run_dump_test "mips16-branch-absolute-addend-n64" \
172 [list [list ld $abi_ldflags(n64)]]
173}
c9775dde 174
0c117286 175run_dump_test "micromips-branch-absolute" [list [list ld $abi_ldflags(o32)]]
b416ba9b
MR
176run_dump_test "micromips-branch-absolute-addend" \
177 [list [list ld $abi_ldflags(o32)]]
0c117286
MR
178if $has_newabi {
179 run_dump_test "micromips-branch-absolute-n32" \
180 [list [list ld $abi_ldflags(n32)]]
181 run_dump_test "micromips-branch-absolute-addend-n32" \
182 [list [list ld $abi_ldflags(n32)]]
183 run_dump_test "micromips-branch-absolute-n64" \
184 [list [list ld $abi_ldflags(n64)]]
185 run_dump_test "micromips-branch-absolute-addend-n64" \
186 [list [list ld $abi_ldflags(n64)]]
187}
188
df58fc94
RS
189# Jalx test
190run_dump_test "jalx-1"
191
192if { $linux_gnu } {
193 run_ld_link_tests [list \
194 [list "Dummy shared library for JALX test 2" \
897aea50 195 "-shared -nostdlib -melf32btsmip" "" \
df58fc94
RS
196 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
197 { jalx-2-printf.s } \
198 {} \
199 "libjalx-2.so"] \
200 [list "Dummy external function for JALX test 2" \
897aea50 201 "-r -melf32btsmip" "" \
df58fc94
RS
202 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
203 { jalx-2-ex.s } \
204 {} \
205 "jalx-2-ex.o.r"] \
206 [list "MIPS JALX test 2" \
897aea50 207 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
df58fc94
RS
208 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
209 { jalx-2-main.s } \
210 { { objdump -d jalx-2.dd } } \
211 "jalx-2"]]
212}
213
17c6c9d9 214run_dump_test "jalx-addend" [list [list ld $abi_ldflags(o32)]]
44d3da23 215run_dump_test "jalx-local" [list [list ld $abi_ldflags(o32)]]
a6ebf616
MR
216run_dump_test "bal-jalx-addend" [list [list ld $abi_ldflags(o32)]]
217run_dump_test "bal-jalx-local" [list [list ld $abi_ldflags(o32)]]
218run_dump_test "bal-jalx-pic" [list [list ld $abi_ldflags(o32)]]
17c6c9d9
MR
219if $has_newabi {
220 run_dump_test "jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
44d3da23 221 run_dump_test "jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
a6ebf616
MR
222 run_dump_test "bal-jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
223 run_dump_test "bal-jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
224 run_dump_test "bal-jalx-pic-n32" [list [list ld $abi_ldflags(n32)]]
17c6c9d9 225 run_dump_test "jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
44d3da23 226 run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
a6ebf616
MR
227 run_dump_test "bal-jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
228 run_dump_test "bal-jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
229 run_dump_test "bal-jalx-pic-n64" [list [list ld $abi_ldflags(n64)]]
17c6c9d9
MR
230}
231
de341542
MR
232run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
233run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
a6ebf616
MR
234run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
235run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
de341542
MR
236run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
237run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
de341542
MR
238run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
239run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
de341542 240
bc27bb05
MR
241if $has_newabi {
242 run_dump_test "unaligned-jalx-addend-0" \
243 [list [list ld $abi_ldflags(n32)]]
244 run_dump_test "unaligned-jalx-addend-1" \
245 [list [list ld $abi_ldflags(n32)]]
a6ebf616
MR
246 run_dump_test "unaligned-jalx-addend-2" \
247 [list [list ld $abi_ldflags(n32)]]
248 run_dump_test "unaligned-jalx-addend-3" \
249 [list [list ld $abi_ldflags(n32)]]
bc27bb05
MR
250 run_dump_test "unaligned-jalx-addend-mips16-0" \
251 [list [list ld $abi_ldflags(n32)]]
252 run_dump_test "unaligned-jalx-addend-mips16-1" \
253 [list [list ld $abi_ldflags(n32)]]
254 run_dump_test "unaligned-jalx-addend-micromips-0" \
255 [list [list ld $abi_ldflags(n32)]]
256 run_dump_test "unaligned-jalx-addend-micromips-1" \
257 [list [list ld $abi_ldflags(n32)]]
258}
259
99aefae6
MR
260run_dump_test "unaligned-branch" [list [list ld $abi_ldflags(o32)]]
261
9d862524
MR
262if $has_newabi {
263 run_dump_test "unaligned-branch-2" \
264 [list [list ld $abi_ldflags(n32)]]
265 run_dump_test "unaligned-branch-r6-1" \
266 [list [list ld $abi_ldflags(n32)]]
267 run_dump_test "unaligned-branch-r6-2" \
268 [list [list ld $abi_ldflags(n32)]]
269 run_dump_test "unaligned-branch-mips16" \
270 [list [list ld $abi_ldflags(n32)]]
271 run_dump_test "unaligned-branch-micromips" \
272 [list [list ld $abi_ldflags(n32)]]
273 run_dump_test "unaligned-jump" \
274 [list [list ld $abi_ldflags(n32)]]
275 run_dump_test "unaligned-jump-mips16" \
276 [list [list ld $abi_ldflags(n32)]]
277 run_dump_test "unaligned-jump-micromips" \
278 [list [list ld $abi_ldflags(n32)]]
279}
280
de341542
MR
281run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]]
282run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]]
de341542
MR
283run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]]
284run_dump_test "unaligned-ldpc-1" [list [list ld $abi_ldflags(o32)]]
de341542 285
732be173
DJ
286# Test multi-got link. We only do this on GNU/Linux because it requires
287# the "traditional" emulations.
288if { $linux_gnu } {
289 run_dump_test "multi-got-1"
bbe506e8 290 run_dump_test "multi-got-no-shared"
2152e047
DJ
291 run_dump_test "multi-got-hidden-1"
292 run_dump_test "multi-got-hidden-2"
732be173 293}
30a2f863 294
0a61c8c2
RS
295# Test __gnu_local_gp accesses
296if { $linux_gnu } {
297 run_dump_test "no-shared-1-o32"
298 if { $has_newabi } {
299 run_dump_test "no-shared-1-n32"
300 run_dump_test "no-shared-1-n64"
301 }
302}
303
a5499fa4
MF
304# Test PIE debug dynamic tags
305if { $linux_gnu } {
306 run_dump_test "pie-o32"
307 if { $has_newabi } {
308 run_dump_test "pie-n32"
309 run_dump_test "pie-n64"
310 }
311}
312
fbf18a5c 313if $has_newabi {
ef2b5578
MR
314 if { $embedded_elf } {
315 run_dump_test "elf-rel-got-n32-embed" \
316 [list [list ld $abi_ldflags(n32)]]
317 run_dump_test "elf-rel-xgot-n32-embed" \
318 [list [list ld $abi_ldflags(n32)]]
319 } else {
320 run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]]
321 run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]]
322 }
48fe7bda 323 if { $linux_gnu } {
ef2b5578
MR
324 run_dump_test "elf-rel-got-n64-linux" \
325 [list [list ld $abi_ldflags(n64)]]
326 run_dump_test "elf-rel-xgot-n64-linux" \
327 [list [list ld $abi_ldflags(n64)]]
328 } elseif { $embedded_elf } {
329 run_dump_test "elf-rel-got-n64-embed" \
330 [list [list ld $abi_ldflags(n64)]]
331 run_dump_test "elf-rel-xgot-n64-embed" \
332 [list [list ld $abi_ldflags(n64)]]
fbf18a5c 333 } else {
ef2b5578
MR
334 run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]]
335 run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]]
48fe7bda
AO
336 }
337
fbf18a5c
TS
338 run_dump_test "relax-jalr-n32"
339 run_dump_test "relax-jalr-n32-shared"
340 run_dump_test "relax-jalr-n64"
341 run_dump_test "relax-jalr-n64-shared"
342}
48fe7bda 343
fbf18a5c
TS
344if { $linux_gnu } {
345 run_dump_test "rel32-o32"
250826bd
RS
346 if { $has_newabi } {
347 run_dump_test "rel32-n32"
348 run_dump_test "rel64"
349 }
861fb55a
DJ
350 # The first test checks that a mixed PIC/non-PIC relocatable link
351 # will not introduce any stubs itself, but will flag PIC functions
352 # for the final link.
353 #
354 # The second test checks that we insert stubs for calls from
355 # non-PIC functions to PIC functions when linking the original
356 # two objects together.
357 #
358 # The third test checks that we do the same when linking the
359 # result of the first link (with no other source files).
0375b0a5
MR
360 #
361 # We then repeat the same three tests for microMIPS stubs.
861fb55a 362 run_ld_link_tests {
897aea50 363 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
861fb55a
DJ
364 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
365 {{objdump -dr pic-and-nonpic-1-rel.dd}
366 {readelf --symbols pic-and-nonpic-1-rel.nd}}
367 "pic-and-nonpic-1-rel.o"}
368 {"PIC and non-PIC test 1 (static 1)"
897aea50 369 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
861fb55a
DJ
370 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
371 {{objdump -dr pic-and-nonpic-1.dd}
372 {readelf --symbols pic-and-nonpic-1.nd}}
373 "pic-and-nonpic-1-static1.o"}
374 {"PIC and non-PIC test 1 (static 2)"
897aea50 375 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
861fb55a
DJ
376 "" {}
377 {{objdump -dr pic-and-nonpic-1.dd}
378 {readelf --symbols pic-and-nonpic-1.nd}}
379 "pic-and-nonpic-1-static2.o"}
0375b0a5
MR
380 {"PIC and non-PIC test 1, microMIPS (relocatable)"
381 "-r -melf32btsmip" ""
382 "-32 -EB -mips2"
383 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
384 {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
385 {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
386 "pic-and-nonpic-1-micromips-rel.o"}
387 {"PIC and non-PIC test 1, microMIPS (static 1)"
388 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
389 "-32 -EB -mips2"
390 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
391 {{objdump -dr pic-and-nonpic-1-micromips.dd}
392 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
393 "pic-and-nonpic-1-micromips-static1.o"}
394 }
395 # The final executable produced with the following test is supposed
396 # to be the same as one produced with the preceding test, however
397 # as noted in PR ld/20453 it is not. Consequently output from
398 # `objdump -dr' is not the same either. Expect:
399 #
400 # regexp_diff match failure
401 # regexp "^ 4103c: f001 0415 jalx 41054 <f3>$"
402 # line " 4103c: f001 0400 jalx 41000 <.pic.f3>"
403 #
404 # from the test below due to this problem.
405 setup_kfail "mips*-*-*" "ld/20453"
406 # The final check below should be folded into the `run_ld_link_tests'
407 # call above once `setup_kfail' has been removed.
408 run_ld_link_tests {
409 {"PIC and non-PIC test 1, microMIPS (static 2)"
410 "-melf32btsmip -Tpic-and-nonpic-1.ld \
411 tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
412 "" {}
413 {{objdump -dr pic-and-nonpic-1-micromips.dd}
414 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
415 "pic-and-nonpic-1-micromips-static2.o"}
861fb55a
DJ
416 }
417 run_dump_test "pic-and-nonpic-2"
418 run_ld_link_tests {
419 {"PIC and non-PIC test 3 (shared library)"
897aea50 420 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
421 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
422 {{readelf --segments pic-and-nonpic-3a.sd}
423 {readelf -A pic-and-nonpic-3a.gd}
424 {objdump -dr pic-and-nonpic-3a.dd}}
425 "pic-and-nonpic-3a.so"}
426 {"PIC and non-PIC test 3 (executable)"
897aea50 427 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
861fb55a
DJ
428 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
429 {{readelf --segments pic-and-nonpic-3b.sd}
430 {objdump -dr pic-and-nonpic-3b.dd}
431 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
432 {readelf -A pic-and-nonpic-3b.gd}
433 {readelf --relocs pic-and-nonpic-3b.rd}
434 {readelf --symbols pic-and-nonpic-3b.nd}
435 {readelf -d pic-and-nonpic-3b.ad}}
436 "pic-and-nonpic-3b"}
437 }
438 run_dump_test "pic-and-nonpic-3-error"
439 run_ld_link_tests {
440 {"PIC and non-PIC test 4 (shared library)"
897aea50 441 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
442 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
443 {}
444 "pic-and-nonpic-4a.so"}
445 {"PIC and non-PIC test 4 (executable)"
897aea50 446 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
447 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
448 {{readelf --segments pic-and-nonpic-4b.sd}
449 {objdump -dr pic-and-nonpic-4b.dd}
450 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
451 {readelf --relocs pic-and-nonpic-4b.rd}
452 {readelf --symbols pic-and-nonpic-4b.nd}
453 {readelf -d pic-and-nonpic-4b.ad}}
454 "pic-and-nonpic-4b"}
455 }
456 run_dump_test "pic-and-nonpic-4-error"
457 run_ld_link_tests {
458 {"PIC and non-PIC test 5 (executable)"
897aea50 459 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
460 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
461 {{readelf --segments pic-and-nonpic-5b.sd}
462 {objdump -dr pic-and-nonpic-5b.dd}
463 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
464 {readelf -A pic-and-nonpic-5b.gd}
465 {readelf --relocs pic-and-nonpic-5b.rd}
466 {readelf --symbols pic-and-nonpic-5b.nd}
467 {readelf -d pic-and-nonpic-5b.ad}}
468 "pic-and-nonpic-5b"}
469 }
470 set abis { o32 -32 elf32btsmip }
471 if $has_newabi {
472 lappend abis n32 -n32 elf32btsmipn32
473 lappend abis n64 -64 elf64btsmip
474 }
475 foreach { abi flag emul } $abis {
476 run_ld_link_tests [list \
477 [list "PIC and non-PIC test 6 ($abi shared library)" \
897aea50 478 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
861fb55a
DJ
479 "$flag -EB -mips3" \
480 [list "pic-and-nonpic-6-${abi}a.s"] {} \
481 "pic-and-nonpic-6-${abi}.so"] \
482 [list "PIC and non-PIC test 6 ($abi executable)" \
897aea50 483 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
861fb55a
DJ
484 "$flag -EB -mips3" \
485 [list "pic-and-nonpic-6-${abi}b.s" \
486 "pic-and-nonpic-6-${abi}c.s"] \
487 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
488 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
489 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
490 "readelf -A pic-and-nonpic-6-${abi}.gd" \
491 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
492 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
493 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
494 "pic-and-nonpic-6-${abi}"]]
43b5366b
MR
495
496 # This checks whether our linker scripts get the scope of _gp right,
497 # and must therefore use default scripts. If they don't, then -- in
498 # addition to dumps failing to match -- the final link fails with:
499 #
500 # ld: gp-hidden.o: undefined reference to symbol '_gp'
501 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
502 # so try adding it to the linker command line
503 #
504 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
505 run_ld_link_tests [list \
506 [list \
507 "_gp scope test ($abi shared library)" \
897aea50 508 "$abi_ldflags($abi) -shared" "" \
43b5366b
MR
509 "$abi_asflags($abi) -KPIC" \
510 { gp-hidden-lib.s } \
511 [list \
512 "readelf --relocs gp-hidden-lib${suff64}.rd" \
513 "readelf --syms gp-hidden.sd"] \
514 "gp-hidden-lib-${abi}.so"] \
515 [list \
516 "_gp scope test ($abi versioned library)" \
897aea50 517 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
43b5366b
MR
518 "$abi_asflags($abi) -KPIC" \
519 { gp-hidden-ver.s } \
520 [list \
521 "readelf --relocs gp-hidden-ver${suff64}.rd" \
522 "readelf --syms gp-hidden.sd"] \
523 "gp-hidden-ver-${abi}.so"] \
524 [list \
525 "_gp scope test ($abi executable)" \
897aea50 526 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
43b5366b
MR
527 "$abi_asflags($abi) -call_nonpic" \
528 { gp-hidden.s } \
529 [list \
530 "readelf --relocs gp-hidden${suff64}.rd" \
531 "readelf --syms gp-hidden.sd"] \
532 "gp-hidden-${abi}"]]
861fb55a 533 }
fbf18a5c 534}
a657e7c1 535
fbf18a5c 536if { $embedded_elf } {
fbf18a5c 537 run_dump_test "region1"
a657e7c1 538}
18ab1921
RS
539
540if $embedded_elf {
541 # This could work on other targets too, but would need the appropriate
542 # ld -m switch.
543 run_dump_test "reloc-1-rel"
544}
545if $has_newabi {
ef2b5578
MR
546 run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]]
547 run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]]
18ab1921
RS
548}
549run_dump_test "reloc-2"
17a6716a 550run_dump_test "reloc-merge-lo16"
3b788261
TS
551run_dump_test "reloc-3"
552if {$has_newabi} {
553 run_dump_test "reloc-3-n32"
554}
43ec5bc0
AN
555run_dump_test "reloc-4"
556run_dump_test "reloc-5"
77c56f44 557if { $has_newabi } {
ef2b5578
MR
558 run_ld_link_tests [list \
559 [list \
560 "reloc test 6a" \
897aea50 561 "-shared $abi_ldflags(n32)" "" \
cde00cbb 562 "$abi_asflags(n32)" \
ef2b5578
MR
563 "reloc-6a.s" \
564 {} \
565 "reloc-6a.so"] \
566 [list \
567 "reloc test 6b" \
897aea50 568 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
cde00cbb 569 "$abi_asflags(n32)" \
ef2b5578
MR
570 "reloc-6b.s" \
571 {} \
572 "reloc-6b"]]
77c56f44 573}
43ec5bc0 574
ceab86af
MR
575run_dump_test "reloc-local-overflow" [list [list ld $abi_ldflags(o32)]]
576
353057a5
RS
577if {$has_newabi && $linux_gnu} {
578 run_dump_test "eh-frame1-n32"
579 run_dump_test "eh-frame1-n64"
dcf507a6
RS
580 run_dump_test "eh-frame2-n32"
581 run_dump_test "eh-frame2-n64"
353057a5 582}
8c946ed5
RS
583if {$embedded_elf} {
584 run_dump_test "eh-frame3"
585 run_dump_test "eh-frame4"
586}
18e04883
RS
587if {$linux_gnu} {
588 set eh_frame5_test {
589 {"MIPS eh-frame 5"
897aea50 590 "-melf32btsmip -shared -Teh-frame5.ld" ""
18e04883
RS
591 "-32 -EB"
592 {eh-frame5.s}
593 {{readelf {--relocs -wf} eh-frame5.d}}
594 "eh-frame5.so"}
595 }
596 run_ld_link_tests $eh_frame5_test
597}
0efd4160 598
2f0c68f2
CM
599if {$embedded_elf} {
600 run_dump_test "compact-eh1"
601 run_dump_test "compact-eh2"
602 run_dump_test "compact-eh3"
603}
604
605if {$linux_gnu} {
606 run_dump_test "compact-eh4"
607 run_dump_test "compact-eh5"
608 run_dump_test "compact-eh6"
609}
610
0efd4160 611run_dump_test "jaloverflow"
c314987d 612run_dump_test "jaloverflow-2"
77434823
MR
613
614run_dump_test "jal-global-overflow-0" [list [list ld $abi_ldflags(o32)]]
615run_dump_test "jal-global-overflow-1" [list [list ld $abi_ldflags(o32)]]
616run_dump_test "jal-local-overflow-0" [list [list ld $abi_ldflags(o32)]]
617run_dump_test "jal-local-overflow-1" [list [list ld $abi_ldflags(o32)]]
618
6e8ec712
MF
619run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \
620 [list ld $abi_ldflags(o32)]]
538baf8b
AB
621
622if {$has_newabi} {
4861b804
MR
623 run_dump_test "undefweak-overflow" [list [list name (n32)] \
624 [list as $abi_asflags(n32)] \
6e8ec712 625 [list ld $abi_ldflags(n32)]]
4861b804
MR
626 run_dump_test "undefweak-overflow" [list [list name (n64)] \
627 [list as $abi_asflags(n64)] \
6e8ec712 628 [list ld $abi_ldflags(n64)]]
538baf8b
AB
629}
630
1f0f3e9b 631if {$has_newabi} {
ef2b5578 632 run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]]
1f0f3e9b 633}
d6f16593 634
776167e8
CM
635run_dump_test "mode-change-error-1"
636
d6f16593
MR
637run_dump_test "mips16-hilo"
638if {$has_newabi} {
639 run_dump_test "mips16-hilo-n32"
640}
f4e584bd 641
cc27e1dc 642if { $linux_gnu } {
250826bd
RS
643 if { $has_newabi } {
644 run_dump_test "textrel-1"
645 }
c224138d
RS
646 run_dump_test "got-page-1"
647 if $has_newabi {
648 run_dump_test "got-page-2"
08b55522 649 run_dump_test "dyn-sec64"
c224138d
RS
650 }
651 run_dump_test "got-page-3"
13db6b44
RS
652 run_ld_link_tests [subst {
653 {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
897aea50 654 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
13db6b44
RS
655 {{objdump -dr got-page-4a.d}
656 {readelf -A got-page-4a.got}}
657 "got-page-4a.so"}
658 {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
897aea50 659 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
13db6b44
RS
660 {{objdump -dr got-page-4b.d}
661 {readelf -A got-page-4b.got}}
662 "got-page-4b.so"}
663 }]
664 if $has_newabi {
665 run_ld_link_tests [subst {
666 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 667 "" "$abi_asflags(n32)" {got-page-5.s}
13db6b44
RS
668 {{objdump -dr got-page-5.d}
669 {readelf -A got-page-5.got}}
670 "got-page-5.so"}
671 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 672 "" "$abi_asflags(n32)" {got-page-6.s}
13db6b44
RS
673 {{objdump -dr got-page-6.d}
674 {readelf -A got-page-6.got}}
675 "got-page-6.so"}
676 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 677 "" "$abi_asflags(n32)"
13db6b44
RS
678 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
679 got-page-7e.s}
680 {{objdump -dr got-page-7.d}
681 {readelf -A got-page-7.got}}
682 "got-page-7a.so"}
683 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 684 "" "$abi_asflags(n32)"
13db6b44
RS
685 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
686 got-page-7d.s}
687 {{objdump -dr got-page-7.d}
688 {readelf -A got-page-7.got}}
689 "got-page-7b.so"}
690 }]
691 }
ccb4c951
RS
692 run_dump_test "got-dump-1"
693 if $has_newabi {
694 run_dump_test "got-dump-2"
695 }
63897e2c 696 run_dump_test "reloc-estimate-1"
cc27e1dc
EC
697}
698
81d43bff
RS
699if $has_newabi {
700 run_dump_test "emit-relocs-1"
701}
702
73934d31
RS
703run_dump_test "hash1a"
704run_dump_test "hash1b"
705run_dump_test "hash1c"
706
5108fc1b
RS
707if {[istarget mips*-*-linux*]} {
708 # The number of symbols that are always included in the symbol table
74541ad4 709 # for these tests. The 4 are:
5108fc1b
RS
710 #
711 # the null symbol entry
712 # the .MIPS.stubs section symbol
2f9efdfc 713 set base_syms 2
5108fc1b
RS
714 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
715 run_ld_link_tests \
716 [list [list \
717 "Stub for dynsym 0x$dynsym" \
897aea50 718 "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \
5108fc1b
RS
719 [concat \
720 "-EB -march=mips1 -32 -KPIC" \
721 "--defsym base_syms=$base_syms" \
722 "--defsym dynsym=0x$dynsym"] \
723 [list "stub-dynsym-1.s"] \
724 [list [list \
725 "objdump" "-dz" \
726 "stub-dynsym-1-$dynsym.d"]] \
727 "stub-dynsym-1-$dynsym"]]
728 }
729 }
730
f4e584bd
DJ
731# For tests which may involve multiple files, use run_ld_link_tests.
732
733# List contains test-items with 3 items followed by 2 lists:
897aea50
MR
734# 0:name 1:ld early options 2:ld late options 3:assembler options
735# 4:filenames of assembler files 5: action and options. 6: name of output file
f4e584bd
DJ
736
737# Actions:
738# objdump: Apply objdump options on result. Compare with regex (last arg).
739# nm: Apply nm options on result. Compare with regex (last arg).
740# readelf: Apply readelf options on result. Compare with regex (last arg).
741
742set mips_tls_tests {
897aea50 743 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
f4e584bd
DJ
744 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
745 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
746 "tls-static-o32"}
897aea50 747 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
748 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
749 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
750 "tlslib-o32.so"}
751 {"Dynamic executable with TLS"
897aea50 752 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
f4e584bd
DJ
753 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
754 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
755 "tls-dynamic-o32"}
756 {"Shared library with multiple GOTs and TLS"
897aea50 757 "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
758 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
759 {{readelf {-d -r} tls-multi-got-1.r}
760 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
761 {objdump -Rsj.got tls-multi-got-1.got}}
762 "tlslib-multi.so"}
763 {"Shared library with TLS and versioning"
897aea50 764 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
f4e584bd
DJ
765 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
766 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
767 "tlslib-o32-ver.so"}
768 {"Dynamic executable with TLS and versioning"
897aea50 769 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
f4e584bd
DJ
770 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
771 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
772 "tls-dynamic-o32-ver"}
773 {"Dynamic executable with TLS and versioning (order 2)"
897aea50 774 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
f4e584bd
DJ
775 "-EB -march=mips1 -32 -KPIC" {}
776 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
777 "tls-dynamic-o32-ver-2"}
778 {"Dynamic executable with TLS and versioning (order 3)"
897aea50 779 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
f4e584bd
DJ
780 "-EB -march=mips1 -32 -KPIC" {}
781 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
782 "tls-dynamic-o32-ver-3"}
783 {"Shared library with TLS and hidden symbols"
897aea50 784 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
f4e584bd
DJ
785 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
786 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
787 "tlslib-o32-hidden.so"}
4005427f 788 {"Shared library with TLS and hidden symbols (2)"
897aea50 789 "-shared -melf32btsmip -T mips-lib.ld" ""
4005427f
RS
790 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
791 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
792 "tls-hidden2.so"}
ead49a57 793 {"Shared library with TLS and hidden symbols (3)"
897aea50 794 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
795 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
796 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
797 {readelf --relocs tls-hidden3.r}}
798 "tls-hidden3.so"}
799 {"Shared library with TLS and hidden symbols (4)"
897aea50 800 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
801 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
802 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
803 "tls-hidden4.so"}
f4e584bd
DJ
804}
805
806if {[istarget mips*-*-linux*]} {
807 run_ld_link_tests $mips_tls_tests
808}
809
08e8dfaf
RS
810set mips16_call_global_test [list \
811 [list "Global calls from mips16" \
897aea50 812 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
ef2b5578 813 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
814 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
815 {{objdump -dr mips16-call-global.d}} \
816 "mips16-call-global"]]
35d3d567
TS
817
818run_ld_link_tests $mips16_call_global_test
b9d58d71 819
08e8dfaf
RS
820set mips16_intermix_test [list \
821 [list "Intermixing mips32 and mips16 functions" \
897aea50 822 "$abi_ldflags(o32)" "" \
ef2b5578 823 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
824 {mips16-intermix-1.s mips16-intermix-2.s} \
825 {{objdump -t mips16-intermix.d}} \
826 "mips16-intermix"]]
b9d58d71
TS
827
828run_ld_link_tests $mips16_intermix_test
b314ec0e
RS
829
830run_dump_test "mips16-local-stubs-1"
2cf19d5c 831
ca9584fb
CM
832set mips16_fp_stub_test [list \
833 [list "Floating-point stub for mips16 functions" \
834 "$abi_ldflags(o32)" "" \
835 "$abi_asflags(o32) -mips32r2" \
836 {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
837 {{readelf --debug-dump=frames mips16-fp-stub.d}} \
838 "mips16-fp-stub"]]
839
840run_ld_link_tests $mips16_fp_stub_test
841
e319abb4
MF
842set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
843
351cdf24 844foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
e319abb4
MF
845 foreach secondfpabi [list 4 5 6 7 ] {
846 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
847 }
848}
849foreach firstfpabi [list 4 5 6 7 ] {
3350cc01 850 foreach secondfpabi [list 0 1 2 3 8 9] {
e319abb4
MF
851 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
852 }
853}
854foreach firstfpabi [list 0 1 2 3 ] {
3350cc01 855 foreach secondfpabi [list 0 1 2 3 8 9] {
351cdf24
MF
856 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
857 }
858}
e319abb4 859
351cdf24
MF
860run_dump_test "attr-gnu-4-81"
861
862run_dump_test "attr-gnu-8-00"
863run_dump_test "attr-gnu-8-01"
864run_dump_test "attr-gnu-8-02"
865run_dump_test "attr-gnu-8-10"
866run_dump_test "attr-gnu-8-11"
867run_dump_test "attr-gnu-8-12"
868run_dump_test "attr-gnu-8-20"
869run_dump_test "attr-gnu-8-21"
870run_dump_test "attr-gnu-8-22"
871
e319abb4
MF
872run_dump_test "attr-gnu-4-0-ph" $o32flagslist
873run_dump_test "attr-gnu-4-1-ph" $o32flagslist
874run_dump_test "attr-gnu-4-2-ph" $o32flagslist
875run_dump_test "attr-gnu-4-3-ph" $o32flagslist
876run_dump_test "attr-gnu-4-4-ph" $o32flagslist
877run_dump_test "attr-gnu-4-5-ph" $o32flagslist
878run_dump_test "attr-gnu-4-6-ph" $o32flagslist
879run_dump_test "attr-gnu-4-7-ph" $o32flagslist
880
881if $has_newabi {
882 run_dump_test "attr-gnu-4-0-n32-ph"
883 run_dump_test "attr-gnu-4-1-n32-ph"
884 run_dump_test "attr-gnu-4-2-n32-ph"
885 run_dump_test "attr-gnu-4-3-n32-ph"
886 run_dump_test "attr-gnu-4-0-n64-ph"
887 run_dump_test "attr-gnu-4-1-n64-ph"
888 run_dump_test "attr-gnu-4-2-n64-ph"
889 run_dump_test "attr-gnu-4-3-n64-ph"
890}
891
892run_dump_test "abiflags-strip1-ph" $o32flagslist
893run_dump_test "abiflags-strip2-ph" $o32flagslist
894run_dump_test "abiflags-strip3-ph" $o32flagslist
895run_dump_test "abiflags-strip4-ph" $o32flagslist
896run_dump_test "abiflags-strip5-ph" $o32flagslist
897run_dump_test "abiflags-strip6-ph" $o32flagslist
898run_dump_test "abiflags-strip7-ph" $o32flagslist
899run_dump_test "abiflags-strip8-ph" $o32flagslist
900run_dump_test "abiflags-strip9-ph" $o32flagslist
09c14161 901run_dump_test "abiflags-strip10-ph" $o32flagslist
634835ae 902
ba92f887
MR
903run_dump_test "nan-legacy"
904run_dump_test "nan-2008"
905run_dump_test "nan-mixed-1"
906run_dump_test "nan-mixed-2"
907
634835ae
RS
908if { $linux_gnu } {
909 run_ld_link_tests {
910 {"GOT and versioning 1"
897aea50 911 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
634835ae
RS
912 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
913 {{readelf -d got-vers-1.dd}
914 {readelf --symbols got-vers-1.sd}
915 {readelf --relocs got-vers-1.rd}}
916 "got-vers-1.so"}
917 }
918}
e7e2196d
MR
919
920run_dump_test "undefined"
1063d8cf
CF
921
922# Test the conversion from jr to b
923if { $linux_gnu } {
924 run_dump_test "jr-to-b-1"
925 run_dump_test "jr-to-b-2"
926}
df58fc94
RS
927
928# MIPS16 and microMIPS interlinking test.
929run_dump_test "mips16-and-micromips"
9b11fa1a
MR
930
931# Export class call relocation tests.
932set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
933foreach { abi } $abis {
934 set loadaddr [string map \
935 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
936 set suff [subst \
937 [expr { [istarget *-*-irix*] \
938 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
939 : $abi }]]
940 run_ld_link_tests [list \
941 [list \
942 "MIPS export class call relocation test ($abi)" \
897aea50 943 "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \
9b11fa1a
MR
944 "$abi_asflags($abi) -mips3 -KPIC" \
945 [list export-class-call16-${abi}.s export-class-call16-def.s] \
946 [list \
947 "objdump -d export-class-call16-${suff}.dd" \
948 "readelf -A export-class-call16-${abi}.gd"] \
949 "export-class-call16-${abi}.so"]]
950}
cde7cb01
MR
951
952# Magic __ehdr_start symbol tests.
953set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
954foreach { abi } $abis {
955 set suff [string map {o32 o32 n32 new n64 new} $abi]
956 run_ld_link_tests [list \
957 [list \
958 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
959 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
960 "$abi_asflags($abi)" \
961 [list ehdr_start-${suff}.s] \
962 [list "readelf -s ehdr_start-1.nd"] \
963 "ehdr_start-1-${abi}"]]
cde7cb01
MR
964 run_ld_link_tests [list \
965 [list \
966 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
967 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
968 "$abi_asflags($abi)" \
969 [list ehdr_start-${suff}.s] \
970 [list "readelf -s ehdr_start-2.nd"] \
971 "ehdr_start-2-${abi}"]]
972}
d6101ac2
MR
973
974# R_MIPS_JALR reloc tests.
975set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
976foreach { abi } $abis {
977 run_ld_link_tests [list \
978 [list \
979 "MIPS JALR reloc test ($abi)" \
980 "$abi_ldflags($abi) -T jalr3.ld" "" \
981 "$abi_asflags($abi)" \
982 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
983 [list "objdump -d jalr3.dd"] \
984 "jalr3-${abi}"]]
985}
690f47bf
RS
986
987proc build_mips_plt_lib { abi } {
988 global abi_asflags
989 global abi_ldflags
990
991 run_ld_link_tests [list \
992 [list "Shared $abi library for compressed PLT tests" \
993 "-shared $abi_ldflags($abi)" "" \
994 "$abi_asflags($abi)" \
995 { compressed-plt-1-dyn.s } \
996 {} \
997 "compressed-plt-1-${abi}-dyn.so"]]
998}
999
1000proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
1001 global abi_asflags
1002 global abi_ldflags
1003
1004 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
1005 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
1006 if {[string equal $abi o32]} {
1007 append as_flags " -march=mips2"
1008 }
1009 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
1010 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
1011 set files [list]
54806ffa 1012 if { $filter & 7 } {
690f47bf
RS
1013 lappend files compressed-plt-1a.s
1014 }
54806ffa 1015 if { $filter & 56 } {
690f47bf
RS
1016 lappend files compressed-plt-1b.s
1017 }
54806ffa 1018 if { $filter & 64 } {
690f47bf
RS
1019 lappend files compressed-plt-1c.s
1020 }
1021 eval [list lappend files] $extra
1022 set readelf_flags "-A --syms --relocs -d"
1023 if { [string match "*word*" $suffix] } {
1024 append readelf_flags " -x.data"
1025 }
1026 set objdump_flags "-d -Mgpr-names=numeric"
1027 set basename "compressed-plt-1-${abi}-${suffix}"
1028 run_ld_link_tests [list \
1029 [list "$name" $ld_flags $dynobj \
1030 "$as_flags" $files \
1031 [list [list readelf $readelf_flags ${basename}.rd] \
1032 [list objdump $objdump_flags ${basename}.od]] \
1033 $basename]]
1034}
1035
1036if { $linux_gnu } {
1037 build_mips_plt_lib o32
54806ffa
MR
1038 run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
1039 run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
1040 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
1041 run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
1042 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
1043 run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
690f47bf 1044 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
54806ffa
MR
1045 o32 109 0 mips16
1046 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
1047 o32 18 0 mips16-branch
690f47bf 1048 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
54806ffa 1049 o32 109 0 mips16-got compressed-plt-1d.s
690f47bf 1050 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
54806ffa 1051 o32 109 0 mips16-word compressed-plt-1e.s
690f47bf 1052 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
54806ffa
MR
1053 o32 109 1 umips
1054 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
1055 o32 18 1 umips-branch
690f47bf 1056 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
54806ffa 1057 o32 109 1 umips-got compressed-plt-1d.s
690f47bf 1058 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
54806ffa 1059 o32 109 1 umips-word compressed-plt-1e.s
690f47bf
RS
1060
1061 if $has_newabi {
1062 build_mips_plt_lib n32
1063 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
54806ffa 1064 n32 109 0 mips16
690f47bf 1065 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
54806ffa 1066 n32 109 1 umips
690f47bf
RS
1067 }
1068}
1f599d0e
MR
1069
1070# PR ld/19908 export class tests.
1071if { $linux_gnu } {
1072 run_ld_link_tests [list \
1073 [list "Shared library for MIPS export class symbol reference tests" \
1074 "$abi_ldflags(o32) -shared" "" \
1075 "$abi_asflags(o32)" \
1076 { export-class-ref-f2.s } \
1077 { { readelf --dyn-syms export-class-ref-lib.sd } } \
1078 "export-class-ref-lib.so"]]
1079 foreach { class flag } { internal 1 hidden 2 protected 3 } {
1080 run_ld_link_tests [list \
1081 [list "MIPS $class symbol reference test 1" \
1082 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1083 "$abi_asflags(o32) --defsym defv=$flag" \
1084 { export-class-ref-f0.s export-class-ref-f1.s } \
1085 [list [list readelf --dyn-syms export-$class-ref.sd] \
1086 [list readelf --dyn-syms export-local-ref.sd]] \
1087 "export-$class-ref"] \
1088 [list "MIPS $class symbol reference test 2" \
1089 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1090 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
1091 { export-class-ref-f0.s export-class-ref-f1.s } \
1092 [list [list readelf --dyn-syms export-$class-ref.sd] \
1093 [list readelf --dyn-syms export-local-ref.sd]] \
1094 "export-$class-ref"]]
1095 }
1096}
This page took 0.694133 seconds and 4 git commands to generate.