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