]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-mips-elf/mips-elf.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
1 # Expect script for MIPS ELF linker tests
2 # Copyright (C) 2002-2023 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 -T} 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 # run_dump_test_abi ABI NAME ARGS
56 #
57 # Invoke "run_dump_test" for test NAME using ABI if supported by the
58 # target used, passing predefined ABI-specific arguments. ARGS are
59 # as with "run_dump_test" and are appended to ABI-specific arguments,
60 # except for the special "noarch" keyword, which, if present, must
61 # appear first and is consumed causing any "-march=" option to be
62 # removed from ABI-specific GAS arguments.
63 proc run_dump_test_abi { abi name args } {
64 global abi_asflags
65 global abi_ldflags
66 global has_abi
67
68 set args [lindex $args 0]
69 set asflags $abi_asflags($abi)
70 set ldflags $abi_ldflags($abi)
71 if { [lindex $args 0] == "noarch" } {
72 set asflags [regsub -- {-march=[^[:blank:]]*} $asflags {}]
73 set args [lreplace $args 0 0]
74 }
75 if !$has_abi($abi) {
76 lappend args {notarget *-*-*}
77 }
78 if { [llength $args] > 0 } {
79 run_dump_test $name [concat [list [list as $asflags] \
80 [list ld $ldflags]] \
81 $args]
82 } else {
83 run_dump_test $name [list [list as $asflags] [list ld $ldflags]]
84 }
85 }
86
87 # run_dump_test_o32 NAME ARGS
88 #
89 # Invoke "run_dump_test_abi" for test NAME using the o32 ABI and
90 # passing ARGS.
91 proc run_dump_test_o32 { name args } {
92 run_dump_test_abi o32 $name [lindex $args 0]
93 }
94
95 # run_dump_test_n32 NAME ARGS
96 #
97 # Invoke "run_dump_test_abi" for test NAME using the n32 ABI and
98 # passing ARGS.
99 proc run_dump_test_n32 { name args } {
100 run_dump_test_abi n32 $name [lindex $args 0]
101 }
102
103 # run_dump_test_n64 NAME ARGS
104 #
105 # Invoke "run_dump_test_abi" for test NAME using the n64 ABI and
106 # passing ARGS.
107 proc run_dump_test_n64 { name args } {
108 run_dump_test_abi n64 $name [lindex $args 0]
109 }
110
111 # run_dump_test_eabi NAME ARGS
112 #
113 # Invoke "run_dump_test_abi" for test NAME using the eabi ABI and
114 # passing ARGS.
115 proc run_dump_test_eabi { name args } {
116 run_dump_test_abi eabi $name [lindex $args 0]
117 }
118
119 set has_abi(o32) [expr ![istarget *-*-openbsd*] \
120 && ![istarget mips64*el-ps2-elf*]]
121 set has_abi(n32) [expr [istarget *-img-elf*] \
122 || [istarget *-mti-elf*] \
123 || [istarget mips64*el-ps2-elf*] \
124 || [istarget *-sde-elf*] \
125 || [istarget *-*-freebsd*] \
126 || [istarget *-*-irix6*] \
127 || [istarget *-*-kfreebsd*-gnu] \
128 || [istarget *-*-linux*]]
129 set has_abi(n64) [expr [istarget *-*-freebsd*] \
130 || [istarget *-*-irix6*] \
131 || [istarget *-*-kfreebsd*-gnu] \
132 || [istarget *-*-linux*] \
133 || [istarget *-*-netbsd*] \
134 || [istarget *-*-openbsd*]]
135 set has_abi(eabi) [expr [istarget *-*-elf] \
136 && $has_abi(o32)]
137 set irix [expr [istarget *-*-irix*]]
138 set linux_gnu [expr [istarget mips*-*-linux*]]
139 set embedded_elf [expr [istarget mips*-*-elf]]
140
141 # Set defaults.
142 set abi_asflags(o32) ""
143 set abi_asflags(n32) ""
144 set abi_asflags(n64) ""
145 set abi_asflags(eabi) ""
146 set abi_ldflags(o32) ""
147 set abi_ldflags(n32) ""
148 set abi_ldflags(n64) ""
149 set abi_ldflags(eabi) ""
150
151 # Override as needed.
152 if {[istarget *-*-openbsd*] } {
153 set irixemul 0
154 } elseif { [istarget mips64*-*-linux*] } {
155 if [istarget *el-*-*] {
156 set abi_asflags(o32) -32
157 set abi_ldflags(o32) -melf32ltsmip
158 set abi_asflags(n64) "-march=from-abi -64"
159 set abi_ldflags(n64) -melf64ltsmip
160 } else {
161 set abi_asflags(o32) -32
162 set abi_ldflags(o32) -melf32btsmip
163 set abi_asflags(n64) "-march=from-abi -64"
164 set abi_ldflags(n64) -melf64btsmip
165 }
166 set irixemul 0
167 } elseif {[istarget *-*-linux*] } {
168 if [istarget *el-*-*] {
169 set abi_asflags(n32) "-march=from-abi -n32"
170 set abi_ldflags(n32) -melf32ltsmipn32
171 set abi_asflags(n64) "-march=from-abi -64"
172 set abi_ldflags(n64) -melf64ltsmip
173 } else {
174 set abi_asflags(n32) "-march=from-abi -n32"
175 set abi_ldflags(n32) -melf32btsmipn32
176 set abi_asflags(n64) "-march=from-abi -64"
177 set abi_ldflags(n64) -melf64btsmip
178 }
179 set irixemul 0
180 } elseif {[istarget *-img-elf*] \
181 || [istarget *-mti-elf*] \
182 || [istarget *-sde-elf*] \
183 || [istarget *-*-netbsd*] \
184 || [istarget *-*-linux*] \
185 || [istarget *-*-sysv4*] } {
186 if [istarget *el-*-*] {
187 set abi_asflags(o32) -32
188 set abi_asflags(n32) "-march=from-abi -n32"
189 set abi_ldflags(n32) -melf32ltsmipn32
190 set abi_asflags(n64) "-march=from-abi -64"
191 set abi_ldflags(n64) -melf64ltsmip
192 } else {
193 set abi_asflags(o32) -32
194 set abi_asflags(n32) "-march=from-abi -n32"
195 set abi_ldflags(n32) -melf32btsmipn32
196 set abi_asflags(n64) "-march=from-abi -64"
197 set abi_ldflags(n64) -melf64btsmip
198 }
199 set irixemul 0
200 } elseif { [istarget mips64*-*-freebsd*] \
201 || [istarget mips64*-*-kfreebsd*-gnu] } {
202 if [istarget *el-*-*] {
203 set abi_asflags(o32) -32
204 set abi_ldflags(o32) -melf32ltsmip_fbsd
205 set abi_asflags(n64) "-march=from-abi -64"
206 set abi_ldflags(n64) -melf64ltsmip_fbsd
207 } else {
208 set abi_asflags(o32) -32
209 set abi_ldflags(o32) -melf32btsmip_fbsd
210 set abi_asflags(n64) "-march=from-abi -64"
211 set abi_ldflags(n64) -melf64btsmip_fbsd
212 }
213 set irixemul 0
214 } elseif { [istarget *-*-freebsd*] \
215 || [istarget *-*-kfreebsd*-gnu] } {
216 if [istarget *el-*-*] {
217 set abi_asflags(n32) "-march=from-abi -n32"
218 set abi_ldflags(n32) -melf32ltsmipn32_fbsd
219 set abi_asflags(n64) "-march=from-abi -64"
220 set abi_ldflags(n64) -melf64ltsmip_fbsd
221 } else {
222 set abi_asflags(n32) "-march=from-abi -n32"
223 set abi_ldflags(n32) -melf32btsmipn32_fbsd
224 set abi_asflags(n64) "-march=from-abi -64"
225 set abi_ldflags(n64) -melf64btsmip_fbsd
226 }
227 set irixemul 0
228 } elseif { [istarget *vr4100*-*-elf*] \
229 || [istarget *vr4300*-*-elf*] \
230 || [istarget *vr5000*-*-elf*] } {
231 set abi_asflags(o32) -32
232 set irixemul 1
233 } elseif { [istarget mips64*el-ps2-elf*] } {
234 set abi_asflags(o32) -32
235 set abi_ldflags(o32) -melf32lr5900
236 set irixemul 1
237 } elseif { [istarget *-*-elf*] \
238 || [istarget *-*-rtems*] } {
239 set abi_asflags(o32) -32
240 set irixemul 1
241 } elseif { [istarget *-*-irix6*] } {
242 set abi_asflags(o32) -32
243 set abi_asflags(n64) "-march=from-abi -64"
244 set abi_ldflags(o32) -melf32bsmip
245 set abi_ldflags(n64) -melf64bmip
246 set irixemul 1
247 } else {
248 set abi_asflags(o32) -32
249 set irixemul 1
250 }
251 set tmips [expr $irixemul ? {""} : {"t"}]
252
253 if { $linux_gnu } {
254 run_ld_link_tests [list \
255 [list "Dummy shared library for MIPS16 PIC test 1" \
256 "-shared -melf32btsmip" "" \
257 "-EB -32 -mips1" \
258 { mips16-pic-1-dummy.s } \
259 {} \
260 "mips16-pic-1-dummy.so"] \
261 [list "MIPS16 PIC test 1" \
262 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
263 "-EB -32 -mips1 -I $srcdir/$subdir" \
264 { mips16-pic-1a.s mips16-pic-1b.s } \
265 { { objdump { -dr -j.text } mips16-pic-1.dd }
266 { readelf -A mips16-pic-1.gd } } \
267 "mips16-pic-1"] \
268 [list "MIPS16 PIC test 2" \
269 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
270 "-EB -32 -mips1 -I $srcdir/$subdir" \
271 { mips16-pic-2a.s mips16-pic-2b.s } \
272 { { objdump { -dr -j.text } mips16-pic-2.dd } \
273 { readelf -A mips16-pic-2.gd } \
274 { readelf --symbols mips16-pic-2.nd } \
275 { readelf --relocs mips16-pic-2.rd } \
276 { readelf -d mips16-pic-2.ad } } \
277 "mips16-pic-2"] \
278 [list "MIPS16 PIC test 3" \
279 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
280 "-EB -32 -mips1 -I $srcdir/$subdir" \
281 { mips16-pic-3a.s mips16-pic-3b.s } \
282 { { objdump -dr mips16-pic-3.dd } \
283 { readelf --relocs mips16-pic-3.rd } \
284 { readelf -A mips16-pic-3.gd } } \
285 "mips16-pic-3"] \
286 [list "MIPS16 PIC test 4 (shared library)" \
287 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
288 "-EB -32 -mips1" \
289 { mips16-pic-4a.s mips16-pic-4b.s } \
290 { { objdump -dr mips16-pic-4a.dd } \
291 { readelf --symbols mips16-pic-4a.nd } \
292 { readelf -A mips16-pic-4a.gd } } \
293 "mips16-pic-4.so"] \
294 [list "MIPS16 PIC test 4 (executable)" \
295 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
296 "-EB -32 -mips1" \
297 { mips16-pic-4c.s } \
298 { { objdump -dr mips16-pic-4b.dd } } \
299 "mips16-pic-4"]]
300 }
301
302 # Check MIPS16 markings being passed through link.
303 run_dump_test "mips16-1"
304
305 # MIPS branch offset final link checking.
306 run_dump_test "branch-misc-1"
307 run_dump_test "branch-misc-2"
308 run_dump_test_o32 "branch-absolute"
309 run_dump_test_o32 "branch-absolute-addend"
310 run_dump_test_n32 "branch-absolute-n32"
311 run_dump_test_n32 "branch-absolute-addend-n32"
312 run_dump_test_n64 "branch-absolute-n64"
313 run_dump_test_n64 "branch-absolute-addend-n64"
314
315 run_dump_test_o32 "mips16-pcrel-0"
316 run_dump_test_o32 "mips16-pcrel-1" noarch
317 run_dump_test_o32 "mips16e2-pcrel-0" noarch
318 run_dump_test_o32 "mips16e2-pcrel-1" noarch
319 run_dump_test_o32 "mips16-pcrel-addend-2"
320 run_dump_test_o32 "mips16-pcrel-addend-6"
321 run_dump_test_o32 "mips16e2-pcrel-addend-2" noarch
322 run_dump_test_o32 "mips16e2-pcrel-addend-6" noarch
323 run_dump_test_n32 "mips16-pcrel-n32-0"
324 run_dump_test_n32 "mips16-pcrel-n32-1"
325 run_dump_test_n64 "mips16-pcrel-n64-sym32-0"
326 run_dump_test_n64 "mips16-pcrel-n64-sym32-1"
327 run_dump_test_n32 "mips16e2-pcrel-n32-0" noarch
328 run_dump_test_n32 "mips16e2-pcrel-n32-1" noarch
329 run_dump_test_n64 "mips16e2-pcrel-n64-sym32-0" noarch
330 run_dump_test_n64 "mips16e2-pcrel-n64-sym32-1" noarch
331
332 run_dump_test_o32 "mips16-branch-2"
333 run_dump_test_o32 "mips16-branch-3"
334 run_dump_test_o32 "mips16-branch-addend-2"
335 run_dump_test_o32 "mips16-branch-addend-3"
336 run_dump_test_o32 "mips16-branch-absolute"
337 run_dump_test_o32 "mips16-branch-absolute-1"
338 run_dump_test_o32 "mips16-branch-absolute-2"
339 run_dump_test_o32 "mips16-branch-absolute-addend"
340 run_dump_test_o32 "mips16-branch-absolute-addend-1"
341 run_dump_test_n32 "mips16-branch-absolute-n32"
342 run_dump_test_n32 "mips16-branch-absolute-n32-1"
343 run_dump_test_n32 "mips16-branch-absolute-n32-2"
344 run_dump_test_n32 "mips16-branch-absolute-addend-n32"
345 run_dump_test_n32 "mips16-branch-absolute-addend-n32-1"
346 run_dump_test_n64 "mips16-branch-absolute-n64"
347 run_dump_test_n64 "mips16-branch-absolute-n64-1"
348 run_dump_test_n64 "mips16-branch-absolute-n64-2"
349 run_dump_test_n64 "mips16-branch-absolute-addend-n64"
350 run_dump_test_n64 "mips16-branch-absolute-addend-n64-1"
351
352 run_dump_test_o32 "micromips-branch-absolute"
353 run_dump_test_o32 "micromips-branch-absolute-addend"
354 run_dump_test_n32 "micromips-branch-absolute-n32"
355 run_dump_test_n32 "micromips-branch-absolute-addend-n32"
356 run_dump_test_n64 "micromips-branch-absolute-n64"
357 run_dump_test_n64 "micromips-branch-absolute-addend-n64"
358
359 # Jalx test
360 run_dump_test "jalx-1"
361
362 if { $linux_gnu } {
363 run_ld_link_tests [list \
364 [list "Dummy shared library for JALX test 2" \
365 "-shared -nostdlib -melf32btsmip" "" \
366 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
367 { jalx-2-printf.s } \
368 {} \
369 "libjalx-2.so"] \
370 [list "Dummy external function for JALX test 2" \
371 "-r -melf32btsmip" "" \
372 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
373 { jalx-2-ex.s } \
374 {} \
375 "jalx-2-ex.o.r"] \
376 [list "MIPS JALX test 2" \
377 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
378 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
379 { jalx-2-main.s } \
380 { { objdump -d jalx-2.dd } } \
381 "jalx-2"]]
382 }
383
384 run_dump_test_o32 "jalx-addend"
385 run_dump_test_o32 "jalx-local"
386 run_dump_test_o32 "bal-jalx-addend"
387 run_dump_test_o32 "bal-jalx-addend-micromips"
388 run_dump_test_o32 "bal-jalx-local"
389 run_dump_test_o32 "bal-jalx-local-micromips"
390 run_dump_test_o32 "bal-jalx-pic"
391 run_dump_test_o32 "bal-jalx-pic-micromips"
392 run_dump_test_o32 "bal-jalx-pic-ignore"
393 run_dump_test_o32 "bal-jalx-pic-ignore-micromips"
394 run_dump_test_n32 "jalx-addend-n32"
395 run_dump_test_n32 "jalx-local-n32"
396 run_dump_test_n32 "bal-jalx-addend-n32"
397 run_dump_test_n32 "bal-jalx-addend-micromips-n32"
398 run_dump_test_n32 "bal-jalx-local-n32"
399 run_dump_test_n32 "bal-jalx-local-micromips-n32"
400 run_dump_test_n32 "bal-jalx-pic-n32"
401 run_dump_test_n32 "bal-jalx-pic-micromips-n32"
402 run_dump_test_n32 "bal-jalx-pic-ignore-n32"
403 run_dump_test_n32 "bal-jalx-pic-ignore-micromips-n32"
404 run_dump_test_n64 "jalx-addend-n64"
405 run_dump_test_n64 "jalx-local-n64"
406 run_dump_test_n64 "bal-jalx-addend-n64"
407 run_dump_test_n64 "bal-jalx-addend-micromips-n64"
408 run_dump_test_n64 "bal-jalx-local-n64"
409 run_dump_test_n64 "bal-jalx-local-micromips-n64"
410 run_dump_test_n64 "bal-jalx-pic-n64"
411 run_dump_test_n64 "bal-jalx-pic-micromips-n64"
412 run_dump_test_n64 "bal-jalx-pic-ignore-n64"
413 run_dump_test_n64 "bal-jalx-pic-ignore-micromips-n64"
414
415 run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
416 run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
417 run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
418 run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
419 run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
420 run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
421 run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
422 run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
423
424 run_dump_test_n32 "unaligned-jalx-addend-0"
425 run_dump_test_n32 "unaligned-jalx-addend-1"
426 run_dump_test_n32 "unaligned-jalx-addend-2"
427 run_dump_test_n32 "unaligned-jalx-addend-3"
428 run_dump_test_n32 "unaligned-jalx-addend-mips16-0"
429 run_dump_test_n32 "unaligned-jalx-addend-mips16-1"
430 run_dump_test_n32 "unaligned-jalx-addend-micromips-0"
431 run_dump_test_n32 "unaligned-jalx-addend-micromips-1"
432
433 run_dump_test_o32 "unaligned-branch" noarch
434
435 run_dump_test_n32 "unaligned-branch-2"
436 run_dump_test_n32 "unaligned-branch-ignore-2"
437 run_dump_test_n32 "unaligned-branch-r6-1"
438 run_dump_test_n32 "unaligned-branch-ignore-r6-1"
439 run_dump_test_n32 "unaligned-branch-r6-2" noarch
440 run_dump_test_n32 "unaligned-branch-mips16"
441 run_dump_test_n32 "unaligned-branch-ignore-mips16"
442 run_dump_test_n32 "unaligned-branch-micromips"
443 run_dump_test_n32 "unaligned-branch-ignore-micromips"
444 run_dump_test_n32 "unaligned-jump"
445 run_dump_test_n32 "unaligned-jump-mips16"
446 run_dump_test_n32 "unaligned-jump-micromips"
447
448 run_dump_test_o32 "unaligned-lwpc-0" noarch
449 run_dump_test_o32 "unaligned-lwpc-1" noarch
450 run_dump_test_o32 "unaligned-ldpc-0" noarch
451 run_dump_test_o32 "unaligned-ldpc-1" noarch
452
453 # Test multi-got link. We only do this on GNU/Linux because it requires
454 # the "traditional" emulations.
455 if { $linux_gnu } {
456 run_dump_test_o32 "multi-got-1"
457 run_dump_test_o32 "multi-got-no-shared"
458 run_dump_test_o32 "multi-got-hidden-1"
459 run_dump_test_o32 "multi-got-hidden-2"
460 }
461
462 # Test __gnu_local_gp accesses
463 if { $linux_gnu } {
464 run_dump_test_o32 "no-shared-1-o32"
465 run_dump_test_n32 "no-shared-1-n32"
466 run_dump_test_n64 "no-shared-1-n64" {{as -EB} {ld -EB}}
467 }
468
469 # Test PIE debug dynamic tags
470 if { $linux_gnu } {
471 run_dump_test_o32 "pie-o32"
472 run_dump_test_n32 "pie-n32"
473 run_dump_test_n64 "pie-n64"
474 }
475
476 if { $embedded_elf } {
477 run_dump_test_n32 "elf-rel-got-n32-embed" {{as -EB} {ld -EB}}
478 run_dump_test_n32 "elf-rel-xgot-n32-embed" {{as -EB} {ld -EB}}
479 } else {
480 run_dump_test_n32 "elf-rel-got-n32" {{as -EB} {ld -EB}}
481 run_dump_test_n32 "elf-rel-xgot-n32" {{as -EB} {ld -EB}}
482 }
483 if { $irix } {
484 run_dump_test_n64 "elf-rel-got-n64-irix"
485 run_dump_test_n64 "elf-rel-xgot-n64-irix"
486 } elseif { $embedded_elf } {
487 run_dump_test_n64 "elf-rel-got-n64-embed" {{as -EB} {ld -EB}}
488 run_dump_test_n64 "elf-rel-xgot-n64-embed" {{as -EB} {ld -EB}}
489 } else {
490 run_dump_test_n64 "elf-rel-got-n64" {{as -EB} {ld -EB}}
491 run_dump_test_n64 "elf-rel-xgot-n64" {{as -EB} {ld -EB}}
492 }
493
494 run_dump_test_n32 "relax-jalr-n32" {{as -EB} {ld -EB}}
495 run_dump_test_n32 "relax-jalr-n32-shared" {{as -EB} {ld -EB}}
496 run_dump_test_n64 "relax-jalr-n64" {{as -EB} {ld -EB}}
497 run_dump_test_n64 "relax-jalr-n64-shared" {{as -EB} {ld -EB}}
498
499 if { $linux_gnu } {
500 run_dump_test_o32 "rel32-o32" {{as -EB} {ld -EB}}
501 run_dump_test_n32 "rel32-n32" {{as -EB} {ld -EB}}
502 run_dump_test_n64 "rel64" {{as -EB} {ld -EB}}
503 # The first test checks that a mixed PIC/non-PIC relocatable link
504 # will not introduce any stubs itself, but will flag PIC functions
505 # for the final link.
506 #
507 # The second test checks that we insert stubs for calls from
508 # non-PIC functions to PIC functions when linking the original
509 # two objects together.
510 #
511 # The third test checks that we do the same when linking the
512 # result of the first link (with no other source files).
513 #
514 # We then repeat the same three tests for microMIPS stubs.
515 run_ld_link_tests {
516 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
517 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
518 {{objdump -dr pic-and-nonpic-1-rel.dd}
519 {readelf --symbols pic-and-nonpic-1-rel.nd}}
520 "pic-and-nonpic-1-rel.o"}
521 {"PIC and non-PIC test 1 (static 1)"
522 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
523 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
524 {{objdump -dr pic-and-nonpic-1.dd}
525 {readelf --symbols pic-and-nonpic-1.nd}}
526 "pic-and-nonpic-1-static1.o"}
527 {"PIC and non-PIC test 1 R6 compact branches (static 1)"
528 "-melf32btsmip -Tpic-and-nonpic-1.ld --compact-branches" ""
529 "-32 -EB -mips32r6" {pic-and-nonpic-1a-r6.s pic-and-nonpic-1b.s}
530 {{objdump -dr pic-and-nonpic-1-r6.dd}
531 {readelf --symbols pic-and-nonpic-1-r6.nd}}
532 "pic-and-nonpic-1-r6-static1.o"}
533 {"PIC and non-PIC test 1 (static 2)"
534 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
535 "" {}
536 {{objdump -dr pic-and-nonpic-1.dd}
537 {readelf --symbols pic-and-nonpic-1.nd}}
538 "pic-and-nonpic-1-static2.o"}
539 {"PIC and non-PIC test 1, microMIPS (relocatable)"
540 "-r -melf32btsmip" ""
541 "-32 -EB -mips2"
542 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
543 {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
544 {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
545 "pic-and-nonpic-1-micromips-rel.o"}
546 {"PIC and non-PIC test 1, microMIPS (static 1)"
547 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
548 "-32 -EB -mips2"
549 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
550 {{objdump -dr pic-and-nonpic-1-micromips.dd}
551 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
552 "pic-and-nonpic-1-micromips-static1.o"}
553 }
554 # The final executable produced with the following test is supposed
555 # to be the same as one produced with the preceding test, however
556 # as noted in PR ld/20453 it is not. Consequently output from
557 # `objdump -dr' is not the same either. Expect:
558 #
559 # regexp_diff match failure
560 # regexp "^ 4103c: f001 0415 jalx 41054 <f3>$"
561 # line " 4103c: f001 0400 jalx 41000 <.pic.f3>"
562 #
563 # from the test below due to this problem.
564 setup_kfail "mips*-*-*" "ld/20453"
565 # The final check below should be folded into the `run_ld_link_tests'
566 # call above once `setup_kfail' has been removed.
567 run_ld_link_tests {
568 {"PIC and non-PIC test 1, microMIPS (static 2)"
569 "-melf32btsmip -Tpic-and-nonpic-1.ld \
570 tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
571 "" {}
572 {{objdump -dr pic-and-nonpic-1-micromips.dd}
573 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
574 "pic-and-nonpic-1-micromips-static2.o"}
575 }
576 run_dump_test_o32 "pic-and-nonpic-2"
577 run_ld_link_tests {
578 {"PIC and non-PIC test 3 (shared library)"
579 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
580 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
581 {{readelf --segments pic-and-nonpic-3a.sd}
582 {readelf -A pic-and-nonpic-3a.gd}
583 {objdump -dr pic-and-nonpic-3a.dd}}
584 "pic-and-nonpic-3a.so"}
585 {"PIC and non-PIC test 3 (executable)"
586 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
587 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
588 {{readelf --segments pic-and-nonpic-3b.sd}
589 {objdump -dr pic-and-nonpic-3b.dd}
590 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
591 {readelf -A pic-and-nonpic-3b.gd}
592 {readelf --relocs pic-and-nonpic-3b.rd}
593 {readelf --symbols pic-and-nonpic-3b.nd}
594 {readelf -d pic-and-nonpic-3b.ad}}
595 "pic-and-nonpic-3b"}
596 {"PIC and non-PIC test 3 R6 compact branches (shared library)"
597 "-melf32btsmip -shared --compact-branches -Tpic-and-nonpic-3a.ld" ""
598 "-32 -EB -mips32r6" {pic-and-nonpic-3a-r6.s}
599 {{readelf --segments pic-and-nonpic-3a.sd}
600 {readelf -A pic-and-nonpic-3a-r6.gd}
601 {objdump -dr pic-and-nonpic-3a-r6.dd}}
602 "pic-and-nonpic-3a-r6.so"}
603 }
604 run_dump_test_o32 "pic-and-nonpic-3-error" {noarch {as -EB} {ld -EB}}
605 run_ld_link_tests {
606 {"PIC and non-PIC test 4 (shared library)"
607 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
608 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
609 {}
610 "pic-and-nonpic-4a.so"}
611 {"PIC and non-PIC test 4 (executable)"
612 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
613 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
614 {{readelf --segments pic-and-nonpic-4b.sd}
615 {objdump -dr pic-and-nonpic-4b.dd}
616 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
617 {readelf --relocs pic-and-nonpic-4b.rd}
618 {readelf --symbols pic-and-nonpic-4b.nd}
619 {readelf -d pic-and-nonpic-4b.ad}}
620 "pic-and-nonpic-4b"}
621 }
622 run_dump_test_o32 "pic-and-nonpic-4-error" {noarch {as -EB} {ld -EB}}
623 run_ld_link_tests {
624 {"PIC and non-PIC test 5 (executable)"
625 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
626 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
627 {{readelf --segments pic-and-nonpic-5b.sd}
628 {objdump -dr pic-and-nonpic-5b.dd}
629 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
630 {readelf -A pic-and-nonpic-5b.gd}
631 {readelf --relocs pic-and-nonpic-5b.rd}
632 {readelf --symbols pic-and-nonpic-5b.nd}
633 {readelf -d pic-and-nonpic-5b.ad}}
634 "pic-and-nonpic-5b"}
635 }
636 set abis {}
637 if $has_abi(o32) {
638 lappend abis o32 -32 elf32btsmip
639 }
640 if $has_abi(n32) {
641 lappend abis n32 -n32 elf32btsmipn32
642 }
643 if $has_abi(n64) {
644 lappend abis n64 -64 elf64btsmip
645 }
646 foreach { abi flag emul } $abis {
647 run_ld_link_tests [list \
648 [list "PIC and non-PIC test 6 ($abi shared library)" \
649 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
650 "$flag -EB -mips3" \
651 [list "pic-and-nonpic-6-${abi}a.s"] {} \
652 "pic-and-nonpic-6-${abi}.so"] \
653 [list "PIC and non-PIC test 6 ($abi executable)" \
654 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
655 "$flag -EB -mips3" \
656 [list "pic-and-nonpic-6-${abi}b.s" \
657 "pic-and-nonpic-6-${abi}c.s"] \
658 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
659 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
660 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
661 "readelf -A pic-and-nonpic-6-${abi}.gd" \
662 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
663 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
664 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
665 "pic-and-nonpic-6-${abi}"]]
666
667 # This checks whether our linker scripts get the scope of _gp right,
668 # and must therefore use default scripts. If they don't, then -- in
669 # addition to dumps failing to match -- the final link fails with:
670 #
671 # ld: gp-hidden.o: undefined reference to symbol '_gp'
672 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
673 # so try adding it to the linker command line
674 #
675 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
676 run_ld_link_tests [list \
677 [list \
678 "_gp scope test ($abi shared library)" \
679 "$abi_ldflags($abi) -shared" "" \
680 "$abi_asflags($abi) -KPIC" \
681 { gp-hidden-lib.s } \
682 [list \
683 "readelf --relocs gp-hidden-lib${suff64}.rd" \
684 "readelf --syms gp-hidden.sd"] \
685 "gp-hidden-lib-${abi}.so"] \
686 [list \
687 "_gp scope test ($abi versioned library)" \
688 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
689 "$abi_asflags($abi) -KPIC" \
690 { gp-hidden-ver.s } \
691 [list \
692 "readelf --relocs gp-hidden-ver${suff64}.rd" \
693 "readelf --syms gp-hidden.sd"] \
694 "gp-hidden-ver-${abi}.so"] \
695 [list \
696 "_gp scope test ($abi executable)" \
697 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
698 "$abi_asflags($abi) -call_nonpic" \
699 { gp-hidden.s } \
700 [list \
701 "readelf --relocs gp-hidden${suff64}.rd" \
702 "readelf --syms gp-hidden.sd"] \
703 "gp-hidden-${abi}"]]
704 }
705 }
706
707 run_dump_test_eabi "region1"
708
709 run_dump_test_o32 "reloc-1-rel"
710 run_dump_test_n32 "reloc-1-n32"
711 run_dump_test_n64 "reloc-1-n64"
712 run_dump_test_o32 "reloc-2" [list [list objdump [expr { [istarget *el-*-*] \
713 ? "--endian=little" \
714 : "--endian=big" }]]]
715 run_dump_test "reloc-merge-lo16"
716 run_dump_test "reloc-3"
717 run_dump_test_n32 "reloc-3-n32" noarch
718 run_dump_test "reloc-4"
719 run_dump_test "reloc-5"
720 if { $has_abi(n32) && [check_shared_lib_support] } {
721 run_ld_link_tests [list \
722 [list \
723 "reloc test 6a" \
724 "-shared $abi_ldflags(n32)" "" \
725 "$abi_asflags(n32)" \
726 "reloc-6a.s" \
727 {} \
728 "reloc-6a.so"] \
729 [list \
730 "reloc test 6b" \
731 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
732 "$abi_asflags(n32)" \
733 "reloc-6b.s" \
734 {} \
735 "reloc-6b"]]
736 }
737
738 run_dump_test_o32 "reloc-local-overflow"
739 if { $has_abi(o32) } {
740 run_ld_link_tests [list \
741 [list \
742 "MIPS link ELF o32 PIC comdat GOT16/LO16 relocation pairing" \
743 "$abi_ldflags(o32) -e bar" "" "$abi_asflags(o32) -mno-pdr" \
744 "../../../gas/testsuite/gas/mips/comdat-reloc.s" \
745 {} \
746 "comdat-reloc"]]
747 }
748
749 if {$linux_gnu} {
750 run_dump_test_n32 "eh-frame1-n32"
751 run_dump_test_n64 "eh-frame1-n64"
752 run_dump_test_n32 "eh-frame2-n32"
753 run_dump_test_n64 "eh-frame2-n64"
754 }
755 run_dump_test_eabi "eh-frame3"
756 run_dump_test_eabi "eh-frame4"
757 if {$linux_gnu} {
758 set eh_frame5_test {
759 {"MIPS eh-frame 5"
760 "-melf32btsmip -shared -Teh-frame5.ld" ""
761 "-32 -EB"
762 {eh-frame5.s}
763 {{readelf {--relocs -wf} eh-frame5.d}}
764 "eh-frame5.so"}
765 }
766 run_ld_link_tests $eh_frame5_test
767 }
768
769 if {$embedded_elf} {
770 run_dump_test "compact-eh1"
771 run_dump_test "compact-eh2"
772 run_dump_test "compact-eh3"
773 }
774
775 if {$linux_gnu} {
776 run_dump_test "compact-eh4"
777 run_dump_test "compact-eh5"
778 run_dump_test "compact-eh6"
779 }
780
781 run_dump_test "jaloverflow"
782 run_dump_test "jaloverflow-2"
783
784 run_dump_test_o32 "jal-global-overflow-0"
785 run_dump_test_o32 "jal-global-overflow-1"
786 run_dump_test_o32 "jal-local-overflow-0"
787 run_dump_test_o32 "jal-local-overflow-1"
788
789 run_dump_test_o32 "undefweak-overflow"
790
791 run_dump_test_n32 "undefweak-overflow" [list [list name (n32)]]
792 run_dump_test_n64 "undefweak-overflow" [list [list name (n64)]]
793
794 run_dump_test_n32 "jalbal" noarch
795
796 run_dump_test "mode-change-error-1"
797
798 run_dump_test_o32 "mips16-hilo"
799 run_dump_test_n32 "mips16-hilo-n32"
800
801 if { $linux_gnu } {
802 run_dump_test_n32 "textrel-1"
803 run_dump_test "got-page-1"
804 run_dump_test_n32 "got-page-2"
805 run_dump_test_n64 "dyn-sec64" noarch
806 run_dump_test "got-page-3"
807 if $has_abi(o32) {
808 run_ld_link_tests [subst {
809 {"GOT page 4 (one file)"
810 "-shared $abi_ldflags(o32) -T got-page-1.ld"
811 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
812 {{objdump -dr got-page-4a.d}
813 {readelf -A got-page-4a.got}}
814 "got-page-4a.so"}
815 {"GOT page 4 (two files)"
816 "-shared $abi_ldflags(o32) -T got-page-1.ld"
817 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
818 {{objdump -dr got-page-4b.d}
819 {readelf -A got-page-4b.got}}
820 "got-page-4b.so"}
821 }]
822 }
823 if $has_abi(n32) {
824 run_ld_link_tests [subst {
825 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
826 "" "$abi_asflags(n32)" {got-page-5.s}
827 {{objdump -dr got-page-5.d}
828 {readelf -A got-page-5.got}}
829 "got-page-5.so"}
830 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
831 "" "$abi_asflags(n32)" {got-page-6.s}
832 {{objdump -dr got-page-6.d}
833 {readelf -A got-page-6.got}}
834 "got-page-6.so"}
835 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
836 "" "$abi_asflags(n32)"
837 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
838 got-page-7e.s}
839 {{objdump -dr got-page-7.d}
840 {readelf -A got-page-7.got}}
841 "got-page-7a.so"}
842 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
843 "" "$abi_asflags(n32)"
844 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
845 got-page-7d.s}
846 {{objdump -dr got-page-7.d}
847 {readelf -A got-page-7.got}}
848 "got-page-7b.so"}
849 }]
850 }
851 run_dump_test "got-dump-1"
852 run_dump_test_n64 "got-dump-2" noarch
853 run_dump_test "reloc-estimate-1"
854 }
855
856 run_dump_test_n32 "emit-relocs-1" {{as -EB} {ld -EB}}
857
858 run_dump_test "hash1"
859 run_dump_test "hash2"
860
861 if { $linux_gnu && $has_abi(o32) } {
862 # The number of symbols that are always included in the symbol table
863 # for these tests.
864 # the null symbol entry
865 set base_syms 1
866 foreach { isa aflag lflag suffix } \
867 { MIPS -march=mips1 "" "" \
868 microMIPS -mmicromips "" -micromips \
869 "microMIPS insn32" "-mmicromips -minsn32" --insn32 \
870 -micromips-insn32 } {
871 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
872 run_ld_link_tests \
873 [list [list \
874 "Stub for dynsym 0x$dynsym ($isa)" \
875 "-shared -melf32btsmip -T stub-dynsym-1.ld $lflag" \
876 "" \
877 [concat \
878 "-EB $aflag -32 -KPIC" \
879 "--defsym base_syms=$base_syms" \
880 "--defsym dynsym=0x$dynsym"] \
881 [list "stub-dynsym-1.s"] \
882 [list [list \
883 "objdump" "-dz" \
884 "stub-dynsym$suffix-1-$dynsym.d"]] \
885 "stub-dynsym$suffix-1-$dynsym"]]
886 }
887 run_ld_link_tests [list \
888 [list \
889 "Retained stubs for dynsyms ($isa)" \
890 "-shared -melf32btsmip -T stub-dynsym-2.ld $lflag" "" \
891 "-EB $aflag -32 -KPIC" \
892 [list "stub-dynsym-2.s"] \
893 [list \
894 [list \
895 "objdump" \
896 "-dz -j .MIPS.stubs" \
897 "stub-dynsym$suffix-2.dd"] \
898 [list \
899 "readelf" \
900 "--dyn-syms" \
901 "stub-dynsym$suffix-2.sd"] \
902 [list \
903 "readelf" \
904 "-A" \
905 "stub-dynsym$suffix-2.gd"]] \
906 "stub-dynsym$suffix-2"] \
907 [list \
908 "Discarded stubs for dynsyms ($isa)" \
909 "-shared -melf32btsmip -T stub-dynsym-discard-2.ld $lflag" \
910 "" \
911 "-EB $aflag -32 -KPIC" \
912 [list "stub-dynsym-2.s"] \
913 [list \
914 [list \
915 "readelf" \
916 "--dyn-syms" \
917 "stub-dynsym-discard-2.sd"] \
918 [list \
919 "readelf" \
920 "-A" \
921 "stub-dynsym-discard-2.gd"]] \
922 "stub-dynsym-discard$suffix-2"]]
923 }
924 }
925
926 # For tests which may involve multiple files, use run_ld_link_tests.
927
928 # List contains test-items with 3 items followed by 2 lists:
929 # 0:name 1:ld early options 2:ld late options 3:assembler options
930 # 4:filenames of assembler files 5: action and options. 6: name of output file
931
932 # Actions:
933 # objdump: Apply objdump options on result. Compare with regex (last arg).
934 # nm: Apply nm options on result. Compare with regex (last arg).
935 # readelf: Apply readelf options on result. Compare with regex (last arg).
936
937 set mips_tls_tests {
938 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
939 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
940 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
941 "tls-static-o32"}
942 {"Static PIE executable with TLS"
943 "-static -pie -melf32btsmip -T mips-dyn.ld" ""
944 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
945 {{objdump {-dr -m mips:isa32r2} tlsbin-pie-o32.d}
946 {objdump -Rsj.got tlsbin-pie-o32.got}}
947 "tls-static-pie-o32"}
948 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
949 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
950 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
951 "tlslib-o32.so"}
952 {"Dynamic executable with TLS"
953 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
954 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
955 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
956 "tls-dynamic-o32"}
957 {"Dynamic PIE executable with TLS"
958 "-pie -melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
959 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
960 {{objdump {-dr -m mips:isa32r2} tlsdyn-pie-o32.d}
961 {objdump -Rsj.got tlsdyn-pie-o32.got}}
962 "tls-dynamic-pie-o32"}
963 {"Shared library with multiple GOTs and TLS"
964 "-shared -melf32btsmip -T mips-lib.ld" ""
965 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
966 {{readelf {-d -r} tls-multi-got-1.r}
967 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
968 {objdump -Rsj.got tls-multi-got-1.got}}
969 "tlslib-multi.so"}
970 {"Shared library with TLS and versioning"
971 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
972 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
973 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
974 "tlslib-o32-ver.so"}
975 {"Dynamic executable with TLS and versioning"
976 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
977 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
978 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
979 "tls-dynamic-o32-ver"}
980 {"Dynamic executable with TLS and versioning (order 2)"
981 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
982 "-EB -march=mips1 -32 -KPIC" {}
983 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
984 "tls-dynamic-o32-ver-2"}
985 {"Dynamic executable with TLS and versioning (order 3)"
986 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
987 "-EB -march=mips1 -32 -KPIC" {}
988 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
989 "tls-dynamic-o32-ver-3"}
990 {"Shared library with TLS and hidden symbols"
991 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
992 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
993 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
994 "tlslib-o32-hidden.so"}
995 {"Shared library with TLS and hidden symbols (2)"
996 "-shared -melf32btsmip -T mips-lib.ld" ""
997 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
998 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
999 "tls-hidden2.so"}
1000 {"Shared library with TLS and hidden symbols (3)"
1001 "-shared -melf32btsmip -T tls-hidden3.ld" ""
1002 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
1003 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
1004 {readelf --relocs tls-hidden3.r}}
1005 "tls-hidden3.so"}
1006 {"Shared library with TLS and hidden symbols (4)"
1007 "-shared -melf32btsmip -T tls-hidden3.ld" ""
1008 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
1009 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
1010 "tls-hidden4.so"}
1011 }
1012
1013 if { $linux_gnu && $has_abi(o32) } {
1014 run_ld_link_tests $mips_tls_tests
1015 }
1016
1017 set mips16_call_global_test [list \
1018 [list "Global calls from mips16" \
1019 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
1020 "$abi_asflags(o32) -mips32r2" \
1021 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
1022 {{objdump -dr mips16-call-global.d}} \
1023 "mips16-call-global"]]
1024
1025 if { $has_abi(o32) } {
1026 run_ld_link_tests $mips16_call_global_test
1027 }
1028
1029 set mips16_intermix_test [list \
1030 [list "Intermixing mips32 and mips16 functions" \
1031 "$abi_ldflags(o32)" "" \
1032 "$abi_asflags(o32) -mips32r2" \
1033 {mips16-intermix-1.s mips16-intermix-2.s} \
1034 {{objdump -t mips16-intermix.d}} \
1035 "mips16-intermix"]]
1036
1037 if { $has_abi(o32) } {
1038 run_ld_link_tests $mips16_intermix_test
1039 }
1040
1041 run_dump_test "mips16-local-stubs-1"
1042
1043 set mips16_fp_stub_test [list \
1044 [list "Floating-point stub for mips16 functions" \
1045 "$abi_ldflags(o32)" "" \
1046 "$abi_asflags(o32) -mips32r2" \
1047 {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
1048 {{readelf --debug-dump=frames mips16-fp-stub.d}} \
1049 "mips16-fp-stub"]]
1050
1051 if { $has_abi(o32) } {
1052 run_ld_link_tests $mips16_fp_stub_test
1053 }
1054
1055 foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
1056 foreach secondfpabi [list 4 5 6 7 ] {
1057 run_dump_test_o32 "attr-gnu-4-${firstfpabi}${secondfpabi}"
1058 }
1059 }
1060 foreach firstfpabi [list 4 5 6 7 ] {
1061 foreach secondfpabi [list 0 1 2 3 8 9] {
1062 run_dump_test_o32 "attr-gnu-4-${firstfpabi}${secondfpabi}"
1063 }
1064 }
1065 foreach firstfpabi [list 0 1 2 3 ] {
1066 foreach secondfpabi [list 0 1 2 3 8 9] {
1067 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
1068 }
1069 }
1070
1071 run_dump_test "attr-gnu-4-81"
1072
1073 run_dump_test "attr-gnu-8-00"
1074 run_dump_test "attr-gnu-8-01"
1075 run_dump_test "attr-gnu-8-02"
1076 run_dump_test "attr-gnu-8-10"
1077 run_dump_test "attr-gnu-8-11"
1078 run_dump_test "attr-gnu-8-12"
1079 run_dump_test "attr-gnu-8-20"
1080 run_dump_test "attr-gnu-8-21"
1081 run_dump_test "attr-gnu-8-22"
1082
1083 run_dump_test_o32 "attr-gnu-4-0-ph"
1084 run_dump_test_o32 "attr-gnu-4-1-ph"
1085 run_dump_test_o32 "attr-gnu-4-2-ph"
1086 run_dump_test_o32 "attr-gnu-4-3-ph"
1087 run_dump_test_o32 "attr-gnu-4-4-ph"
1088 run_dump_test_o32 "attr-gnu-4-5-ph"
1089 run_dump_test_o32 "attr-gnu-4-6-ph"
1090 run_dump_test_o32 "attr-gnu-4-7-ph"
1091
1092 run_dump_test_n32 "attr-gnu-4-0-n32-ph" noarch
1093 run_dump_test_n32 "attr-gnu-4-1-n32-ph" noarch
1094 run_dump_test_n32 "attr-gnu-4-2-n32-ph" noarch
1095 run_dump_test_n32 "attr-gnu-4-3-n32-ph" noarch
1096 run_dump_test_n64 "attr-gnu-4-0-n64-ph" noarch
1097 run_dump_test_n64 "attr-gnu-4-1-n64-ph" noarch
1098 run_dump_test_n64 "attr-gnu-4-2-n64-ph" noarch
1099 run_dump_test_n64 "attr-gnu-4-3-n64-ph" noarch
1100
1101 run_dump_test_o32 "abiflags-strip1-ph"
1102 run_dump_test_o32 "abiflags-strip2-ph"
1103 run_dump_test_o32 "abiflags-strip3-ph"
1104 run_dump_test_o32 "abiflags-strip4-ph"
1105 run_dump_test_o32 "abiflags-strip5-ph"
1106 run_dump_test_o32 "abiflags-strip6-ph"
1107 run_dump_test_o32 "abiflags-strip7-ph"
1108 run_dump_test_o32 "abiflags-strip8-ph"
1109 run_dump_test_o32 "abiflags-strip9-ph"
1110 run_dump_test_o32 "abiflags-strip10-ph"
1111
1112 run_dump_test "nan-legacy"
1113 run_dump_test "nan-2008"
1114 run_dump_test "nan-mixed-1"
1115 run_dump_test "nan-mixed-2"
1116
1117 if { $linux_gnu && $has_abi(o32) } {
1118 run_ld_link_tests {
1119 {"GOT and versioning 1"
1120 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
1121 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
1122 {{readelf -d got-vers-1.dd}
1123 {readelf --symbols got-vers-1.sd}
1124 {readelf --relocs got-vers-1.rd}}
1125 "got-vers-1.so"}
1126 }
1127 }
1128
1129 run_dump_test "undefined"
1130 run_dump_test "undefined-warn"
1131
1132 # Test the conversion from jr to b
1133 if { $linux_gnu } {
1134 run_dump_test_o32 "jr-to-b-1" noarch
1135 run_dump_test_o32 "jr-to-b-2" noarch
1136 }
1137
1138 # MIPS16 and microMIPS interlinking test.
1139 run_dump_test "mips16-and-micromips"
1140
1141 set abis {}
1142 if $has_abi(o32) {
1143 lappend abis o32
1144 }
1145 if $has_abi(n32) {
1146 lappend abis n32
1147 }
1148 if $has_abi(n64) {
1149 lappend abis n64
1150 }
1151
1152 # Export class call relocation tests.
1153 if [check_shared_lib_support] {
1154 foreach { abi } $abis {
1155 set loadaddr [string map \
1156 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
1157 set suff [subst \
1158 [expr { $irix \
1159 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
1160 : $abi }]]
1161 run_ld_link_tests [list \
1162 [list \
1163 "MIPS export class call relocation test ($abi)" \
1164 "$abi_ldflags($abi) -shared -Ttext $loadaddr\
1165 -T export-class-call16.ld" \
1166 "" \
1167 "$abi_asflags($abi) -mips3 -KPIC" \
1168 [list export-class-call16-${abi}.s export-class-call16-def.s] \
1169 [list \
1170 "objdump -d export-class-call16-${suff}.dd" \
1171 "readelf -A export-class-call16-${abi}.gd"] \
1172 "export-class-call16-${abi}.so"]]
1173 }
1174 }
1175
1176 # Magic __ehdr_start symbol tests.
1177 foreach { abi } $abis {
1178 set suff [string map {o32 o32 n32 new n64 new} $abi]
1179 run_ld_link_tests [list \
1180 [list \
1181 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
1182 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
1183 "$abi_asflags($abi)" \
1184 [list ehdr_start-${suff}.s] \
1185 [list "readelf -s ehdr_start-1.nd"] \
1186 "ehdr_start-1-${abi}"] \
1187 [list \
1188 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
1189 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
1190 "$abi_asflags($abi)" \
1191 [list ehdr_start-${suff}.s] \
1192 [list "readelf -s ehdr_start-2.nd"] \
1193 "ehdr_start-2-${abi}"]]
1194 }
1195
1196 # R_MIPS_JALR reloc tests.
1197 foreach { abi } $abis {
1198 run_ld_link_tests [list \
1199 [list \
1200 "MIPS JALR reloc test ($abi)" \
1201 "$abi_ldflags($abi) -T jalr3.ld" "" \
1202 "$abi_asflags($abi)" \
1203 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
1204 [list "objdump -d jalr3.dd"] \
1205 "jalr3-${abi}"] \
1206 [list \
1207 "MIPS JALR reloc unaligned/cross-mode link test ($abi)" \
1208 "$abi_ldflags($abi) -T jalr3.ld" "" \
1209 "$abi_asflags($abi)" \
1210 [list ../../../gas/testsuite/gas/mips/jalr4.s] \
1211 [list "objdump {-d --prefix-addresses --show-raw-insn} jalr4.dd"] \
1212 "jalr4-${abi}"] \
1213 [list \
1214 "MIPSr6 JALR reloc unaligned/cross-mode link test ($abi)" \
1215 "$abi_ldflags($abi) -T jalr3.ld" "" \
1216 "[string map\
1217 [list o32 -mips32r6\
1218 n32 -mips64r6\
1219 n64 -mips64r6] $abi ]\
1220 [regsub -- {-march=[^[:blank:]]*} $abi_asflags($abi) {}]" \
1221 {../../../gas/testsuite/gas/mips/jalr4.s} \
1222 {{objdump {-d --prefix-addresses --show-raw-insn} jalr4-r6.dd}} \
1223 "jalr4-${abi}"]]
1224 }
1225
1226 proc build_mips_plt_lib { abi } {
1227 global abi_asflags
1228 global abi_ldflags
1229
1230 run_ld_link_tests [list \
1231 [list "Shared $abi library for compressed PLT tests" \
1232 "-shared $abi_ldflags($abi)" "" \
1233 "$abi_asflags($abi)" \
1234 { compressed-plt-1-dyn.s } \
1235 {} \
1236 "compressed-plt-1-${abi}-dyn.so"]]
1237 }
1238
1239 proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
1240 global abi_asflags
1241 global abi_ldflags
1242
1243 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
1244 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
1245 if {[string equal $abi o32]} {
1246 append as_flags " -march=mips2"
1247 }
1248 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
1249 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
1250 set files [list]
1251 if { $filter & 7 } {
1252 lappend files compressed-plt-1a.s
1253 }
1254 if { $filter & 56 } {
1255 lappend files compressed-plt-1b.s
1256 }
1257 if { $filter & 64 } {
1258 lappend files compressed-plt-1c.s
1259 }
1260 eval [list lappend files] $extra
1261 set readelf_flags "-A --syms --relocs -d"
1262 if { [string match "*word*" $suffix] } {
1263 append readelf_flags " -x.data"
1264 }
1265 set objdump_flags "-d -Mgpr-names=numeric"
1266 set basename "compressed-plt-1-${abi}-${suffix}"
1267 run_ld_link_tests [list \
1268 [list "$name" $ld_flags $dynobj \
1269 "$as_flags" $files \
1270 [list [list readelf $readelf_flags ${basename}.rd] \
1271 [list objdump $objdump_flags ${basename}.od]] \
1272 $basename]]
1273 }
1274
1275 if { $linux_gnu && $has_abi(o32) } {
1276 build_mips_plt_lib o32
1277 run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
1278 run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
1279 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
1280 run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
1281 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
1282 run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
1283 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
1284 o32 109 0 mips16
1285 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
1286 o32 18 0 mips16-branch
1287 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
1288 o32 109 0 mips16-got compressed-plt-1d.s
1289 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
1290 o32 109 0 mips16-word compressed-plt-1e.s
1291 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
1292 o32 109 1 umips
1293 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
1294 o32 18 1 umips-branch
1295 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
1296 o32 109 1 umips-got compressed-plt-1d.s
1297 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
1298 o32 109 1 umips-word compressed-plt-1e.s
1299 }
1300
1301 if { $linux_gnu && $has_abi(n32) } {
1302 build_mips_plt_lib n32
1303 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
1304 n32 109 0 mips16
1305 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
1306 n32 109 1 umips
1307 }
1308
1309 # Verify graceful handling of n64 PLT 32-bit range overflows. Given
1310 # that the alignment of `.got.plt' is 8 the highest usable positive
1311 # address is 0x7fff7ff8 and the lowest usable negative address is
1312 # 0xffffffff7fff8000.
1313 if { $linux_gnu && $has_abi(n64) } {
1314 run_ld_link_tests [list \
1315 [list "Shared library for MIPS n64 PLT 32-bit range tests" \
1316 "-shared $abi_ldflags(n64)" "" \
1317 "$abi_asflags(n64)" \
1318 { n64-plt-lib.s } \
1319 {} \
1320 "n64-plt-lib.so"] \
1321 [list "MIPS n64 PLT 32-bit range test 1" \
1322 "$abi_ldflags(n64) -T n64-plt-1.ld -e foo" \
1323 "tmpdir/n64-plt-lib.so" \
1324 "$abi_asflags(n64)" \
1325 { n64-plt.s } \
1326 { { objdump -d n64-plt-1.dd } \
1327 { readelf -A n64-plt-1.gd } } \
1328 "n64-plt-1"] \
1329 [list "MIPS n64 PLT 32-bit range test 2" \
1330 "$abi_ldflags(n64) -T n64-plt-2.ld -e foo" \
1331 "tmpdir/n64-plt-lib.so" \
1332 "$abi_asflags(n64)" \
1333 { n64-plt.s } \
1334 { { ld n64-plt-2.ed } } \
1335 "n64-plt-2"] \
1336 [list "MIPS n64 PLT 32-bit range test 3" \
1337 "$abi_ldflags(n64) -T n64-plt-3.ld -e foo" \
1338 "tmpdir/n64-plt-lib.so" \
1339 "$abi_asflags(n64)" \
1340 { n64-plt.s } \
1341 { { ld n64-plt-3.ed } } \
1342 "n64-plt-3"] \
1343 [list "MIPS n64 PLT 32-bit range test 4" \
1344 "$abi_ldflags(n64) -T n64-plt-4.ld -e foo" \
1345 "tmpdir/n64-plt-lib.so" \
1346 "$abi_asflags(n64)" \
1347 { n64-plt.s } \
1348 { { objdump -d n64-plt-4.dd } \
1349 { readelf -A n64-plt-4.gd } } \
1350 "n64-plt-4"]]
1351 }
1352
1353 # PR ld/19908 export class tests.
1354 if { $linux_gnu && $has_abi(o32) } {
1355 run_ld_link_tests [list \
1356 [list "Shared library for MIPS export class symbol reference tests" \
1357 "$abi_ldflags(o32) -shared" "" \
1358 "$abi_asflags(o32)" \
1359 { export-class-ref-f2.s } \
1360 { { readelf --dyn-syms export-class-ref-lib.sd } } \
1361 "export-class-ref-lib.so"]]
1362 foreach { class flag } { internal 1 hidden 2 protected 3 } {
1363 run_ld_link_tests [list \
1364 [list "MIPS $class symbol reference test 1" \
1365 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1366 "$abi_asflags(o32) --defsym defv=$flag" \
1367 { export-class-ref-f0.s export-class-ref-f1.s } \
1368 [list [list readelf --dyn-syms export-$class-ref.sd] \
1369 [list readelf --dyn-syms export-local-ref.sd]] \
1370 "export-$class-ref"] \
1371 [list "MIPS $class symbol reference test 2" \
1372 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1373 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
1374 { export-class-ref-f0.s export-class-ref-f1.s } \
1375 [list [list readelf --dyn-syms export-$class-ref.sd] \
1376 [list readelf --dyn-syms export-local-ref.sd]] \
1377 "export-$class-ref"]]
1378 }
1379 }
1380
1381 # PR ld/21334 GOT relocation in static binary test.
1382 if { $has_abi(o32) } {
1383 run_ld_link_tests [list \
1384 [list \
1385 "PR ld/21334 MIPS GOT16 relocation in static binary" \
1386 "$abi_ldflags(o32) -e foo -T pr21334.ld" "" "$abi_asflags(o32)" \
1387 {pr21334.s} \
1388 {{objdump {-d --prefix-addresses} pr21334.dd} \
1389 {readelf -A pr21334.gd}} \
1390 "pr21334"]]
1391 }
1392
1393 # Check that the ISA level is consistently II for the LSI 4010.
1394 run_dump_test_o32 "lsi-4010-isa" noarch
1395
1396 # PIC branch relaxation with offset tests. We need to use our version
1397 # of `prune_warnings' to get rid of GAS branch relaxation noise.
1398 if { $has_abi(o32) } {
1399 rename prune_warnings mips_old_prune_warnings
1400 proc prune_warnings { msg } {
1401 set msg1 "Assembler messages:"
1402 set msg2 "Warning: relaxed out-of-range branch into a jump"
1403 set msgx "(?:$msg1|$msg2)"
1404 regsub -all "(^|\[\n\r\]*)\[^\n\r\]*: $msgx\[\n\r\]*" $msg "\\1" msg
1405 return [mips_old_prune_warnings $msg]
1406 }
1407 run_ld_link_tests [list \
1408 [list \
1409 "MIPS link PIC branch relaxation with offset" \
1410 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1411 "$abi_asflags(o32) -relax-branch -mips2" \
1412 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1413 {{objdump \
1414 {-d --prefix-addresses --show-raw-insn} \
1415 relax-offset.dd} \
1416 {readelf -A relax-offset.gd}} \
1417 "relax-offset"] \
1418 [list \
1419 "microMIPS link PIC branch relaxation with offset" \
1420 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1421 "$abi_asflags(o32) -relax-branch -mmicromips" \
1422 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1423 {{objdump \
1424 {-d --prefix-addresses --show-raw-insn} \
1425 relax-offset-umips.dd} \
1426 {readelf -A relax-offset-umips.gd}} \
1427 "relax-offset-umips"]]
1428 rename prune_warnings ""
1429 rename mips_old_prune_warnings prune_warnings
1430 }
1431
1432 # Verify that we can link ELF input into the `binary' output format.
1433 run_dump_test "binary"
1434
1435 # Verify special section processing.
1436 if { $has_abi(o32) || $has_abi(n32) } {
1437 run_dump_test "reginfo-0"
1438 run_dump_test "reginfo-0r"
1439 run_dump_test "reginfo-1"
1440 run_dump_test "reginfo-1r"
1441 run_dump_test "reginfo-2"
1442 run_dump_test "reginfo-2r"
1443 }
1444 run_dump_test "mips-abiflags-0"
1445 run_dump_test "mips-abiflags-0r"
1446 run_dump_test "mips-abiflags-1"
1447 run_dump_test "mips-abiflags-1r"
1448 run_dump_test "mips-abiflags-2"
1449 run_dump_test "mips-abiflags-2r"
1450
1451 # Test that _gp_disp symbol is not present in symbol tables.
1452 run_dump_test_o32 "gp-disp-sym"
1453
1454 # PR ld/21375 undefined weak PIC references.
1455 proc run_mips_undefweak_test { name abi args } {
1456 global abi_asflags
1457 global abi_ldflags
1458 global irixemul
1459
1460 set name "PR ld/21375 in $name"
1461
1462 set pic 0
1463 set abisuf -noabi
1464 set srcsuf ""
1465 set scrsuf ""
1466 set binsuf ""
1467 set dsosuf ""
1468 set objsuf ""
1469 set rdesuf ""
1470 set asxtra ""
1471 set ldxtra ""
1472 foreach arg $args {
1473 switch -- $arg {
1474 dso {
1475 set pic 1
1476 set dsosuf .so
1477 append objsuf s
1478 append rdesuf s
1479 append ldxtra " -shared"
1480 }
1481 gc {
1482 set abisuf -noabi
1483 append binsuf g
1484 append objsuf g
1485 append rdesuf g
1486 append ldxtra " --gc-sections"
1487 }
1488 hidden {
1489 if { $pic && [istarget "*-*-*gnu*"] } { set abisuf -abi }
1490 append binsuf h
1491 append objsuf h
1492 append rdesuf h
1493 append asxtra " --defsym hidn=1"
1494 }
1495 internal {
1496 if { $pic && [istarget "*-*-*gnu*"] } { set abisuf -abi }
1497 append binsuf h
1498 append objsuf h
1499 append rdesuf h
1500 append asxtra " --defsym intr=1"
1501 }
1502 local {
1503 append binsuf l
1504 append rdesuf l
1505 append ldxtra " --version-script pr21375.ver"
1506 }
1507 mips16 {
1508 set srcsuf -mips16
1509 append binsuf m16
1510 append objsuf m16
1511 append asxtra " -mips16"
1512 }
1513 pie {
1514 set pic 1
1515 set dsosuf -pie
1516 append objsuf p
1517 append rdesuf p
1518 append ldxtra " -pie"
1519 }
1520 protected {
1521 if { $pic && [istarget "*-*-*gnu*"] } { set abisuf -abi }
1522 append binsuf h
1523 append objsuf h
1524 append rdesuf h
1525 append asxtra " --defsym prot=1"
1526 }
1527 umips {
1528 append binsuf u
1529 append objsuf u
1530 append asxtra " -mmicromips"
1531 }
1532 version {
1533 append binsuf v
1534 append rdesuf v
1535 append ldxtra " --version-script pr21375v.ver"
1536 }
1537 xgot {
1538 set srcsuf -xgot
1539 set scrsuf -xgot
1540 append binsuf x
1541 append objsuf x
1542 append rdesuf x
1543 }
1544 }
1545 }
1546 switch -- $abi {
1547 n32 {
1548 set srcsuf -n32
1549 append binsuf -n32
1550 append objsuf -n32
1551 append rdesuf -n32
1552 }
1553 n64 {
1554 set srcsuf -n64
1555 append binsuf -n64
1556 append objsuf -n64
1557 append rdesuf -n64
1558 }
1559 }
1560 if $irixemul {
1561 set irixsuf -irix
1562 } else {
1563 set irixsuf ""
1564 }
1565
1566 if { $pic && ![check_shared_lib_support] } {
1567 unsupported "$name"
1568 } else {
1569 run_ld_link_tests [list \
1570 [list \
1571 "$name" \
1572 "$abi_ldflags($abi) -e foo -T pr21375${scrsuf}.ld ${ldxtra}" \
1573 "" \
1574 "$abi_asflags($abi) ${asxtra}" \
1575 [list pr21375${srcsuf}.s] \
1576 [list \
1577 [list objdump -d pr21375${objsuf}.dd] \
1578 [list readelf -A pr21375${rdesuf}.gd] \
1579 [list readelf {--dyn-syms --wide} pr21375${rdesuf}${irixsuf}.sd] \
1580 [list readelf -h pr21375${abisuf}.hd]] \
1581 "pr21375${binsuf}${dsosuf}"]]
1582 }
1583 }
1584
1585 if $has_abi(o32) {
1586 run_mips_undefweak_test "SVR4 executable" \
1587 o32
1588 run_mips_undefweak_test "SVR4 executable (hidden)" \
1589 o32 hidden
1590 run_mips_undefweak_test "PIE executable" \
1591 o32 pie
1592 run_mips_undefweak_test "PIE executable (hidden)" \
1593 o32 pie hidden
1594 run_mips_undefweak_test "shared library" \
1595 o32 dso
1596 run_mips_undefweak_test "shared library (hidden)" \
1597 o32 dso hidden
1598 run_mips_undefweak_test "shared library (hidden, forced local)" \
1599 o32 dso hidden local
1600 run_mips_undefweak_test "shared library (hidden, versioned)" \
1601 o32 dso hidden version
1602 run_mips_undefweak_test "shared library (hidden, section GC)" \
1603 o32 dso hidden gc
1604 run_mips_undefweak_test "shared library (protected)" \
1605 o32 dso protected
1606 run_mips_undefweak_test "shared library (internal)" \
1607 o32 dso internal
1608 run_mips_undefweak_test "shared library (large GOT)" \
1609 o32 dso xgot
1610 run_mips_undefweak_test "shared library (large GOT, hidden)" \
1611 o32 dso xgot hidden
1612 run_mips_undefweak_test "shared library (MIPS16)" \
1613 o32 dso mips16
1614 run_mips_undefweak_test "shared library (MIPS16, hidden)" \
1615 o32 dso mips16 hidden
1616 run_mips_undefweak_test "shared library (microMIPS)" \
1617 o32 dso umips
1618 run_mips_undefweak_test "shared library (microMIPS, hidden)" \
1619 o32 dso umips hidden
1620 run_mips_undefweak_test "shared library (microMIPS, large GOT)" \
1621 o32 dso umips xgot
1622 run_mips_undefweak_test "shared library (microMIPS, large GOT, hidden)" \
1623 o32 dso umips xgot hidden
1624 }
1625 if $has_abi(n32) {
1626 run_mips_undefweak_test "shared library (n32)" \
1627 n32 dso
1628 run_mips_undefweak_test "shared library (n32, hidden)" \
1629 n32 dso hidden
1630 run_mips_undefweak_test "shared library (n32, microMIPS)" \
1631 n32 dso umips
1632 run_mips_undefweak_test "shared library (n32, microMIPS, hidden)" \
1633 n32 dso umips hidden
1634 }
1635 if $has_abi(n64) {
1636 run_mips_undefweak_test "shared library (n64)" \
1637 n64 dso
1638 run_mips_undefweak_test "shared library (n64, hidden)" \
1639 n64 dso hidden
1640 run_mips_undefweak_test "shared library (n64, microMIPS)" \
1641 n64 dso umips
1642 run_mips_undefweak_test "shared library (n64, microMIPS, hidden)" \
1643 n64 dso umips hidden
1644 }
1645
1646 # PIC relocation acceptance tests.
1647 run_dump_test "pic-reloc-0"
1648 run_dump_test "pic-reloc-1"
1649 run_dump_test "pic-reloc-2"
1650 run_dump_test "pic-reloc-3"
1651 run_dump_test "pic-reloc-4"
1652 run_dump_test_o32 "pic-reloc-5"
1653 run_dump_test_o32 "pic-reloc-5" [list [list name (microMIPS)] \
1654 [list as "-mmicromips"]]
1655 run_dump_test_o32 "pic-reloc-6"
1656 run_dump_test_n64 "pic-reloc-7"
1657 run_dump_test_n64 "pic-reloc-7" [list [list name (microMIPS)] \
1658 [list as "-mmicromips"]]
1659
1660 run_dump_test_o32 "reloc-pcrel-r6"
1661
1662 # Global/local symbol table split tests.
1663 run_dump_test_o32 "global-local-symtab-o32${tmips}"
1664 run_dump_test_n32 "global-local-symtab-n32${tmips}"
1665 run_dump_test_n64 "global-local-symtab-n64"
1666 run_dump_test_o32 "global-local-symtab-sort-o32${tmips}"
1667 run_dump_test_n32 "global-local-symtab-sort-n32${tmips}"
1668 run_dump_test_n64 "global-local-symtab-sort-n64${tmips}"
1669 run_dump_test_o32 "global-local-symtab-final-o32"
1670 run_dump_test_n32 "global-local-symtab-final-n32"
1671 run_dump_test_n64 "global-local-symtab-final-n64"