[MIPS] Add Loongson 2K1000 proccessor support.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
CommitLineData
a657e7c1 1# Expect script for MIPS ELF linker tests
219d1afa 2# Copyright (C) 2002-2018 Free Software Foundation, Inc.
a657e7c1 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
a657e7c1 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
a657e7c1
CD
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
a657e7c1
CD
20#
21
0a44bf69
RS
22if {[istarget "mips*-*-vxworks"]} {
23 set mipsvxtests {
897aea50 24 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" ""
0a44bf69
RS
25 "-mips2" {vxworks1-lib.s}
26 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
9e3313ae 27 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
0a44bf69
RS
28 "libvxworks1.so"}
29 {"VxWorks executable test 1 (dynamic)" \
897aea50 30 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" ""
0a44bf69
RS
31 "-mips2" {vxworks1.s}
32 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
33 "vxworks1"}
34 {"VxWorks executable test 2 (dynamic)" \
897aea50 35 "-Tvxworks1.ld -q --force-dynamic" ""
0a44bf69
RS
36 "-mips2" {vxworks2.s}
37 {{readelf --segments vxworks2.sd}}
38 "vxworks2"}
39 {"VxWorks executable test 2 (static)"
897aea50 40 "-Tvxworks1.ld" ""
0a44bf69
RS
41 "-mips2" {vxworks2.s}
42 {{readelf --segments vxworks2-static.sd}}
43 "vxworks2"}
44 }
45 run_ld_link_tests $mipsvxtests
46 run_dump_test "vxworks1-static"
8275b357 47 run_dump_test "vxworks-forced-local-1"
0a44bf69
RS
48 return
49}
50
fbf18a5c
TS
51if {![istarget mips*-*-*] || ![is_elf_format]} {
52 return
53}
30a2f863 54
78da84f9
MR
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.
63proc 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.
91proc 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.
99proc 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.
107proc 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.
115proc run_dump_test_eabi { name args } {
116 run_dump_test_abi eabi $name [lindex $args 0]
117}
118
119set has_abi(o32) [expr ![istarget *-*-openbsd*] \
120 && ![istarget mips64*el-ps2-elf*]]
121set 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*]]
129set has_abi(n64) [expr [istarget *-*-freebsd*] \
130 || [istarget *-*-irix6*] \
131 || [istarget *-*-kfreebsd*-gnu] \
132 || [istarget *-*-linux*] \
133 || [istarget *-*-netbsd*] \
134 || [istarget *-*-openbsd*]]
135set has_abi(eabi) [expr [istarget *-*-elf] \
136 && $has_abi(o32)]
7153abac 137set irix [expr [istarget *-*-irix*]]
fbf18a5c
TS
138set linux_gnu [expr [istarget mips*-*-linux*]]
139set embedded_elf [expr [istarget mips*-*-elf]]
30a2f863 140
ef2b5578 141# Set defaults.
78da84f9
MR
142set abi_asflags(o32) ""
143set abi_asflags(n32) ""
144set abi_asflags(n64) ""
145set abi_asflags(eabi) ""
ef2b5578 146set abi_ldflags(o32) ""
78da84f9
MR
147set abi_ldflags(n32) ""
148set abi_ldflags(n64) ""
149set abi_ldflags(eabi) ""
ef2b5578
MR
150
151# Override as needed.
78da84f9
MR
152if {[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"
ef2b5578 244 set abi_ldflags(o32) -melf32bsmip
78da84f9
MR
245 set abi_ldflags(n64) -melf64bmip
246 set irixemul 1
247} else {
248 set abi_asflags(o32) -32
249 set irixemul 1
ef2b5578
MR
250}
251
738e5348
RS
252if { $linux_gnu } {
253 run_ld_link_tests [list \
254 [list "Dummy shared library for MIPS16 PIC test 1" \
897aea50 255 "-shared -melf32btsmip" "" \
3c0bfb2a
RS
256 "-EB -32 -mips1" \
257 { mips16-pic-1-dummy.s } \
738e5348
RS
258 {} \
259 "mips16-pic-1-dummy.so"] \
260 [list "MIPS16 PIC test 1" \
897aea50 261 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
262 "-EB -32 -mips1 -I $srcdir/$subdir" \
263 { mips16-pic-1a.s mips16-pic-1b.s } \
738e5348
RS
264 { { objdump { -dr -j.text } mips16-pic-1.dd }
265 { readelf -A mips16-pic-1.gd } } \
266 "mips16-pic-1"] \
267 [list "MIPS16 PIC test 2" \
897aea50 268 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
3c0bfb2a
RS
269 "-EB -32 -mips1 -I $srcdir/$subdir" \
270 { mips16-pic-2a.s mips16-pic-2b.s } \
738e5348
RS
271 { { objdump { -dr -j.text } mips16-pic-2.dd } \
272 { readelf -A mips16-pic-2.gd } \
273 { readelf --symbols mips16-pic-2.nd } \
274 { readelf --relocs mips16-pic-2.rd } \
275 { readelf -d mips16-pic-2.ad } } \
861fb55a
DJ
276 "mips16-pic-2"] \
277 [list "MIPS16 PIC test 3" \
897aea50 278 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
3c0bfb2a
RS
279 "-EB -32 -mips1 -I $srcdir/$subdir" \
280 { mips16-pic-3a.s mips16-pic-3b.s } \
861fb55a
DJ
281 { { objdump -dr mips16-pic-3.dd } \
282 { readelf --relocs mips16-pic-3.rd } \
283 { readelf -A mips16-pic-3.gd } } \
61b0a4af
RS
284 "mips16-pic-3"] \
285 [list "MIPS16 PIC test 4 (shared library)" \
897aea50 286 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
3c0bfb2a
RS
287 "-EB -32 -mips1" \
288 { mips16-pic-4a.s mips16-pic-4b.s } \
61b0a4af
RS
289 { { objdump -dr mips16-pic-4a.dd } \
290 { readelf --symbols mips16-pic-4a.nd } \
291 { readelf -A mips16-pic-4a.gd } } \
292 "mips16-pic-4.so"] \
293 [list "MIPS16 PIC test 4 (executable)" \
897aea50 294 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
3c0bfb2a
RS
295 "-EB -32 -mips1" \
296 { mips16-pic-4c.s } \
61b0a4af
RS
297 { { objdump -dr mips16-pic-4b.dd } } \
298 "mips16-pic-4"]]
738e5348
RS
299}
300
fbf18a5c
TS
301# Check MIPS16 markings being passed through link.
302run_dump_test "mips16-1"
8914585c 303
fbf18a5c
TS
304# MIPS branch offset final link checking.
305run_dump_test "branch-misc-1"
6f50d611 306run_dump_test "branch-misc-2"
78da84f9
MR
307run_dump_test_o32 "branch-absolute"
308run_dump_test_o32 "branch-absolute-addend"
309run_dump_test_n32 "branch-absolute-n32"
310run_dump_test_n32 "branch-absolute-addend-n32"
311run_dump_test_n64 "branch-absolute-n64"
312run_dump_test_n64 "branch-absolute-addend-n64"
313
314run_dump_test_o32 "mips16-pcrel-0"
315run_dump_test_o32 "mips16-pcrel-1" noarch
316run_dump_test_o32 "mips16e2-pcrel-0" noarch
317run_dump_test_o32 "mips16e2-pcrel-1" noarch
318run_dump_test_o32 "mips16-pcrel-addend-2"
319run_dump_test_o32 "mips16-pcrel-addend-6"
320run_dump_test_o32 "mips16e2-pcrel-addend-2" noarch
321run_dump_test_o32 "mips16e2-pcrel-addend-6" noarch
322run_dump_test_n32 "mips16-pcrel-n32-0"
323run_dump_test_n32 "mips16-pcrel-n32-1"
324run_dump_test_n64 "mips16-pcrel-n64-sym32-0"
325run_dump_test_n64 "mips16-pcrel-n64-sym32-1"
326run_dump_test_n32 "mips16e2-pcrel-n32-0" noarch
327run_dump_test_n32 "mips16e2-pcrel-n32-1" noarch
328run_dump_test_n64 "mips16e2-pcrel-n64-sym32-0" noarch
329run_dump_test_n64 "mips16e2-pcrel-n64-sym32-1" noarch
330
331run_dump_test_o32 "mips16-branch-2"
332run_dump_test_o32 "mips16-branch-3"
333run_dump_test_o32 "mips16-branch-addend-2"
334run_dump_test_o32 "mips16-branch-addend-3"
335run_dump_test_o32 "mips16-branch-absolute"
336run_dump_test_o32 "mips16-branch-absolute-1"
337run_dump_test_o32 "mips16-branch-absolute-2"
338run_dump_test_o32 "mips16-branch-absolute-addend"
339run_dump_test_o32 "mips16-branch-absolute-addend-1"
340run_dump_test_n32 "mips16-branch-absolute-n32"
341run_dump_test_n32 "mips16-branch-absolute-n32-1"
342run_dump_test_n32 "mips16-branch-absolute-n32-2"
343run_dump_test_n32 "mips16-branch-absolute-addend-n32"
344run_dump_test_n32 "mips16-branch-absolute-addend-n32-1"
345run_dump_test_n64 "mips16-branch-absolute-n64"
346run_dump_test_n64 "mips16-branch-absolute-n64-1"
347run_dump_test_n64 "mips16-branch-absolute-n64-2"
348run_dump_test_n64 "mips16-branch-absolute-addend-n64"
349run_dump_test_n64 "mips16-branch-absolute-addend-n64-1"
350
351run_dump_test_o32 "micromips-branch-absolute"
352run_dump_test_o32 "micromips-branch-absolute-addend"
353run_dump_test_n32 "micromips-branch-absolute-n32"
354run_dump_test_n32 "micromips-branch-absolute-addend-n32"
355run_dump_test_n64 "micromips-branch-absolute-n64"
356run_dump_test_n64 "micromips-branch-absolute-addend-n64"
0c117286 357
df58fc94
RS
358# Jalx test
359run_dump_test "jalx-1"
360
361if { $linux_gnu } {
362 run_ld_link_tests [list \
363 [list "Dummy shared library for JALX test 2" \
897aea50 364 "-shared -nostdlib -melf32btsmip" "" \
df58fc94
RS
365 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
366 { jalx-2-printf.s } \
367 {} \
368 "libjalx-2.so"] \
369 [list "Dummy external function for JALX test 2" \
897aea50 370 "-r -melf32btsmip" "" \
df58fc94
RS
371 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
372 { jalx-2-ex.s } \
373 {} \
374 "jalx-2-ex.o.r"] \
375 [list "MIPS JALX test 2" \
897aea50 376 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
df58fc94
RS
377 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
378 { jalx-2-main.s } \
379 { { objdump -d jalx-2.dd } } \
380 "jalx-2"]]
381}
382
78da84f9
MR
383run_dump_test_o32 "jalx-addend"
384run_dump_test_o32 "jalx-local"
385run_dump_test_o32 "bal-jalx-addend"
386run_dump_test_o32 "bal-jalx-addend-micromips"
387run_dump_test_o32 "bal-jalx-local"
388run_dump_test_o32 "bal-jalx-local-micromips"
389run_dump_test_o32 "bal-jalx-pic"
390run_dump_test_o32 "bal-jalx-pic-micromips"
391run_dump_test_o32 "bal-jalx-pic-ignore"
392run_dump_test_o32 "bal-jalx-pic-ignore-micromips"
393run_dump_test_n32 "jalx-addend-n32"
394run_dump_test_n32 "jalx-local-n32"
395run_dump_test_n32 "bal-jalx-addend-n32"
396run_dump_test_n32 "bal-jalx-addend-micromips-n32"
397run_dump_test_n32 "bal-jalx-local-n32"
398run_dump_test_n32 "bal-jalx-local-micromips-n32"
399run_dump_test_n32 "bal-jalx-pic-n32"
400run_dump_test_n32 "bal-jalx-pic-micromips-n32"
401run_dump_test_n32 "bal-jalx-pic-ignore-n32"
402run_dump_test_n32 "bal-jalx-pic-ignore-micromips-n32"
403run_dump_test_n64 "jalx-addend-n64"
404run_dump_test_n64 "jalx-local-n64"
405run_dump_test_n64 "bal-jalx-addend-n64"
406run_dump_test_n64 "bal-jalx-addend-micromips-n64"
407run_dump_test_n64 "bal-jalx-local-n64"
408run_dump_test_n64 "bal-jalx-local-micromips-n64"
409run_dump_test_n64 "bal-jalx-pic-n64"
410run_dump_test_n64 "bal-jalx-pic-micromips-n64"
411run_dump_test_n64 "bal-jalx-pic-ignore-n64"
412run_dump_test_n64 "bal-jalx-pic-ignore-micromips-n64"
17c6c9d9 413
de341542
MR
414run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
415run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
a6ebf616
MR
416run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
417run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
de341542
MR
418run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
419run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
de341542
MR
420run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
421run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
de341542 422
78da84f9
MR
423run_dump_test_n32 "unaligned-jalx-addend-0"
424run_dump_test_n32 "unaligned-jalx-addend-1"
425run_dump_test_n32 "unaligned-jalx-addend-2"
426run_dump_test_n32 "unaligned-jalx-addend-3"
427run_dump_test_n32 "unaligned-jalx-addend-mips16-0"
428run_dump_test_n32 "unaligned-jalx-addend-mips16-1"
429run_dump_test_n32 "unaligned-jalx-addend-micromips-0"
430run_dump_test_n32 "unaligned-jalx-addend-micromips-1"
431
432run_dump_test_o32 "unaligned-branch" noarch
433
434run_dump_test_n32 "unaligned-branch-2"
435run_dump_test_n32 "unaligned-branch-ignore-2"
436run_dump_test_n32 "unaligned-branch-r6-1"
437run_dump_test_n32 "unaligned-branch-ignore-r6-1"
438run_dump_test_n32 "unaligned-branch-r6-2" noarch
439run_dump_test_n32 "unaligned-branch-mips16"
440run_dump_test_n32 "unaligned-branch-ignore-mips16"
441run_dump_test_n32 "unaligned-branch-micromips"
442run_dump_test_n32 "unaligned-branch-ignore-micromips"
443run_dump_test_n32 "unaligned-jump"
444run_dump_test_n32 "unaligned-jump-mips16"
445run_dump_test_n32 "unaligned-jump-micromips"
446
447run_dump_test_o32 "unaligned-lwpc-0" noarch
448run_dump_test_o32 "unaligned-lwpc-1" noarch
449run_dump_test_o32 "unaligned-ldpc-0" noarch
450run_dump_test_o32 "unaligned-ldpc-1" noarch
de341542 451
732be173
DJ
452# Test multi-got link. We only do this on GNU/Linux because it requires
453# the "traditional" emulations.
454if { $linux_gnu } {
78da84f9
MR
455 run_dump_test_o32 "multi-got-1"
456 run_dump_test_o32 "multi-got-no-shared"
457 run_dump_test_o32 "multi-got-hidden-1"
458 run_dump_test_o32 "multi-got-hidden-2"
732be173 459}
30a2f863 460
0a61c8c2
RS
461# Test __gnu_local_gp accesses
462if { $linux_gnu } {
78da84f9
MR
463 run_dump_test_o32 "no-shared-1-o32"
464 run_dump_test_n32 "no-shared-1-n32"
465 run_dump_test_n64 "no-shared-1-n64" {{as -EB} {ld -EB}}
0a61c8c2
RS
466}
467
a5499fa4
MF
468# Test PIE debug dynamic tags
469if { $linux_gnu } {
78da84f9
MR
470 run_dump_test_o32 "pie-o32"
471 run_dump_test_n32 "pie-n32"
472 run_dump_test_n64 "pie-n64"
a5499fa4
MF
473}
474
78da84f9
MR
475if { $embedded_elf } {
476 run_dump_test_n32 "elf-rel-got-n32-embed" {{as -EB} {ld -EB}}
477 run_dump_test_n32 "elf-rel-xgot-n32-embed" {{as -EB} {ld -EB}}
478} else {
479 run_dump_test_n32 "elf-rel-got-n32" {{as -EB} {ld -EB}}
480 run_dump_test_n32 "elf-rel-xgot-n32" {{as -EB} {ld -EB}}
fbf18a5c 481}
78da84f9
MR
482if { $irix } {
483 run_dump_test_n64 "elf-rel-got-n64-irix"
484 run_dump_test_n64 "elf-rel-xgot-n64-irix"
485} elseif { $embedded_elf } {
486 run_dump_test_n64 "elf-rel-got-n64-embed" {{as -EB} {ld -EB}}
487 run_dump_test_n64 "elf-rel-xgot-n64-embed" {{as -EB} {ld -EB}}
488} else {
489 run_dump_test_n64 "elf-rel-got-n64" {{as -EB} {ld -EB}}
490 run_dump_test_n64 "elf-rel-xgot-n64" {{as -EB} {ld -EB}}
491}
492
493run_dump_test_n32 "relax-jalr-n32" {{as -EB} {ld -EB}}
494run_dump_test_n32 "relax-jalr-n32-shared" {{as -EB} {ld -EB}}
495run_dump_test_n64 "relax-jalr-n64" {{as -EB} {ld -EB}}
496run_dump_test_n64 "relax-jalr-n64-shared" {{as -EB} {ld -EB}}
48fe7bda 497
fbf18a5c 498if { $linux_gnu } {
78da84f9
MR
499 run_dump_test_o32 "rel32-o32" {{as -EB} {ld -EB}}
500 run_dump_test_n32 "rel32-n32" {{as -EB} {ld -EB}}
501 run_dump_test_n64 "rel64" {{as -EB} {ld -EB}}
861fb55a
DJ
502 # The first test checks that a mixed PIC/non-PIC relocatable link
503 # will not introduce any stubs itself, but will flag PIC functions
504 # for the final link.
505 #
506 # The second test checks that we insert stubs for calls from
507 # non-PIC functions to PIC functions when linking the original
508 # two objects together.
509 #
510 # The third test checks that we do the same when linking the
511 # result of the first link (with no other source files).
0375b0a5
MR
512 #
513 # We then repeat the same three tests for microMIPS stubs.
861fb55a 514 run_ld_link_tests {
897aea50 515 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
861fb55a
DJ
516 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
517 {{objdump -dr pic-and-nonpic-1-rel.dd}
518 {readelf --symbols pic-and-nonpic-1-rel.nd}}
519 "pic-and-nonpic-1-rel.o"}
520 {"PIC and non-PIC test 1 (static 1)"
897aea50 521 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
861fb55a
DJ
522 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
523 {{objdump -dr pic-and-nonpic-1.dd}
524 {readelf --symbols pic-and-nonpic-1.nd}}
525 "pic-and-nonpic-1-static1.o"}
526 {"PIC and non-PIC test 1 (static 2)"
897aea50 527 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
861fb55a
DJ
528 "" {}
529 {{objdump -dr pic-and-nonpic-1.dd}
530 {readelf --symbols pic-and-nonpic-1.nd}}
531 "pic-and-nonpic-1-static2.o"}
0375b0a5
MR
532 {"PIC and non-PIC test 1, microMIPS (relocatable)"
533 "-r -melf32btsmip" ""
534 "-32 -EB -mips2"
535 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
536 {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
537 {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
538 "pic-and-nonpic-1-micromips-rel.o"}
539 {"PIC and non-PIC test 1, microMIPS (static 1)"
540 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
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.dd}
544 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
545 "pic-and-nonpic-1-micromips-static1.o"}
546 }
547 # The final executable produced with the following test is supposed
548 # to be the same as one produced with the preceding test, however
549 # as noted in PR ld/20453 it is not. Consequently output from
550 # `objdump -dr' is not the same either. Expect:
551 #
552 # regexp_diff match failure
553 # regexp "^ 4103c: f001 0415 jalx 41054 <f3>$"
554 # line " 4103c: f001 0400 jalx 41000 <.pic.f3>"
555 #
556 # from the test below due to this problem.
557 setup_kfail "mips*-*-*" "ld/20453"
558 # The final check below should be folded into the `run_ld_link_tests'
559 # call above once `setup_kfail' has been removed.
560 run_ld_link_tests {
561 {"PIC and non-PIC test 1, microMIPS (static 2)"
562 "-melf32btsmip -Tpic-and-nonpic-1.ld \
563 tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
564 "" {}
565 {{objdump -dr pic-and-nonpic-1-micromips.dd}
566 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
567 "pic-and-nonpic-1-micromips-static2.o"}
861fb55a 568 }
78da84f9 569 run_dump_test_o32 "pic-and-nonpic-2"
861fb55a
DJ
570 run_ld_link_tests {
571 {"PIC and non-PIC test 3 (shared library)"
897aea50 572 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
573 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
574 {{readelf --segments pic-and-nonpic-3a.sd}
575 {readelf -A pic-and-nonpic-3a.gd}
576 {objdump -dr pic-and-nonpic-3a.dd}}
577 "pic-and-nonpic-3a.so"}
578 {"PIC and non-PIC test 3 (executable)"
897aea50 579 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
861fb55a
DJ
580 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
581 {{readelf --segments pic-and-nonpic-3b.sd}
582 {objdump -dr pic-and-nonpic-3b.dd}
583 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
584 {readelf -A pic-and-nonpic-3b.gd}
585 {readelf --relocs pic-and-nonpic-3b.rd}
586 {readelf --symbols pic-and-nonpic-3b.nd}
587 {readelf -d pic-and-nonpic-3b.ad}}
588 "pic-and-nonpic-3b"}
589 }
78da84f9 590 run_dump_test_o32 "pic-and-nonpic-3-error" {noarch {as -EB} {ld -EB}}
861fb55a
DJ
591 run_ld_link_tests {
592 {"PIC and non-PIC test 4 (shared library)"
897aea50 593 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
861fb55a
DJ
594 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
595 {}
596 "pic-and-nonpic-4a.so"}
597 {"PIC and non-PIC test 4 (executable)"
897aea50 598 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
599 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
600 {{readelf --segments pic-and-nonpic-4b.sd}
601 {objdump -dr pic-and-nonpic-4b.dd}
602 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
603 {readelf --relocs pic-and-nonpic-4b.rd}
604 {readelf --symbols pic-and-nonpic-4b.nd}
605 {readelf -d pic-and-nonpic-4b.ad}}
606 "pic-and-nonpic-4b"}
607 }
78da84f9 608 run_dump_test_o32 "pic-and-nonpic-4-error" {noarch {as -EB} {ld -EB}}
861fb55a
DJ
609 run_ld_link_tests {
610 {"PIC and non-PIC test 5 (executable)"
897aea50 611 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
861fb55a
DJ
612 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
613 {{readelf --segments pic-and-nonpic-5b.sd}
614 {objdump -dr pic-and-nonpic-5b.dd}
615 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
616 {readelf -A pic-and-nonpic-5b.gd}
617 {readelf --relocs pic-and-nonpic-5b.rd}
618 {readelf --symbols pic-and-nonpic-5b.nd}
619 {readelf -d pic-and-nonpic-5b.ad}}
620 "pic-and-nonpic-5b"}
621 }
78da84f9
MR
622 set abis {}
623 if $has_abi(o32) {
624 lappend abis o32 -32 elf32btsmip
625 }
626 if $has_abi(n32) {
861fb55a 627 lappend abis n32 -n32 elf32btsmipn32
78da84f9
MR
628 }
629 if $has_abi(n64) {
861fb55a
DJ
630 lappend abis n64 -64 elf64btsmip
631 }
632 foreach { abi flag emul } $abis {
633 run_ld_link_tests [list \
634 [list "PIC and non-PIC test 6 ($abi shared library)" \
897aea50 635 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
861fb55a
DJ
636 "$flag -EB -mips3" \
637 [list "pic-and-nonpic-6-${abi}a.s"] {} \
638 "pic-and-nonpic-6-${abi}.so"] \
639 [list "PIC and non-PIC test 6 ($abi executable)" \
897aea50 640 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
861fb55a
DJ
641 "$flag -EB -mips3" \
642 [list "pic-and-nonpic-6-${abi}b.s" \
643 "pic-and-nonpic-6-${abi}c.s"] \
644 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
645 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
646 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
647 "readelf -A pic-and-nonpic-6-${abi}.gd" \
648 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
649 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
650 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
651 "pic-and-nonpic-6-${abi}"]]
43b5366b
MR
652
653 # This checks whether our linker scripts get the scope of _gp right,
654 # and must therefore use default scripts. If they don't, then -- in
655 # addition to dumps failing to match -- the final link fails with:
656 #
657 # ld: gp-hidden.o: undefined reference to symbol '_gp'
658 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
659 # so try adding it to the linker command line
660 #
661 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
662 run_ld_link_tests [list \
663 [list \
664 "_gp scope test ($abi shared library)" \
897aea50 665 "$abi_ldflags($abi) -shared" "" \
43b5366b
MR
666 "$abi_asflags($abi) -KPIC" \
667 { gp-hidden-lib.s } \
668 [list \
669 "readelf --relocs gp-hidden-lib${suff64}.rd" \
670 "readelf --syms gp-hidden.sd"] \
671 "gp-hidden-lib-${abi}.so"] \
672 [list \
673 "_gp scope test ($abi versioned library)" \
897aea50 674 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
43b5366b
MR
675 "$abi_asflags($abi) -KPIC" \
676 { gp-hidden-ver.s } \
677 [list \
678 "readelf --relocs gp-hidden-ver${suff64}.rd" \
679 "readelf --syms gp-hidden.sd"] \
680 "gp-hidden-ver-${abi}.so"] \
681 [list \
682 "_gp scope test ($abi executable)" \
897aea50 683 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
43b5366b
MR
684 "$abi_asflags($abi) -call_nonpic" \
685 { gp-hidden.s } \
686 [list \
687 "readelf --relocs gp-hidden${suff64}.rd" \
688 "readelf --syms gp-hidden.sd"] \
689 "gp-hidden-${abi}"]]
861fb55a 690 }
fbf18a5c 691}
a657e7c1 692
78da84f9 693run_dump_test_eabi "region1"
18ab1921 694
78da84f9
MR
695run_dump_test_o32 "reloc-1-rel"
696run_dump_test_n32 "reloc-1-n32"
697run_dump_test_n64 "reloc-1-n64"
698run_dump_test_o32 "reloc-2" [list [list objdump [expr { [istarget *el-*-*] \
699 ? "--endian=little" \
700 : "--endian=big" }]]]
17a6716a 701run_dump_test "reloc-merge-lo16"
3b788261 702run_dump_test "reloc-3"
78da84f9 703run_dump_test_n32 "reloc-3-n32" noarch
43ec5bc0
AN
704run_dump_test "reloc-4"
705run_dump_test "reloc-5"
78da84f9 706if { $has_abi(n32) && [check_shared_lib_support] } {
ef2b5578
MR
707 run_ld_link_tests [list \
708 [list \
709 "reloc test 6a" \
897aea50 710 "-shared $abi_ldflags(n32)" "" \
cde00cbb 711 "$abi_asflags(n32)" \
ef2b5578
MR
712 "reloc-6a.s" \
713 {} \
714 "reloc-6a.so"] \
715 [list \
716 "reloc test 6b" \
897aea50 717 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
cde00cbb 718 "$abi_asflags(n32)" \
ef2b5578
MR
719 "reloc-6b.s" \
720 {} \
721 "reloc-6b"]]
77c56f44 722}
43ec5bc0 723
78da84f9
MR
724run_dump_test_o32 "reloc-local-overflow"
725if { $has_abi(o32) } {
726 run_ld_link_tests [list \
727 [list \
728 "MIPS link ELF o32 PIC comdat GOT16/LO16 relocation pairing" \
729 "$abi_ldflags(o32) -e bar" "" "$abi_asflags(o32) -mno-pdr" \
730 "../../../gas/testsuite/gas/mips/comdat-reloc.s" \
731 {} \
732 "comdat-reloc"]]
353057a5 733}
78da84f9
MR
734
735if {$linux_gnu} {
736 run_dump_test_n32 "eh-frame1-n32"
737 run_dump_test_n64 "eh-frame1-n64"
738 run_dump_test_n32 "eh-frame2-n32"
739 run_dump_test_n64 "eh-frame2-n64"
8c946ed5 740}
78da84f9
MR
741run_dump_test_eabi "eh-frame3"
742run_dump_test_eabi "eh-frame4"
18e04883
RS
743if {$linux_gnu} {
744 set eh_frame5_test {
745 {"MIPS eh-frame 5"
897aea50 746 "-melf32btsmip -shared -Teh-frame5.ld" ""
18e04883
RS
747 "-32 -EB"
748 {eh-frame5.s}
749 {{readelf {--relocs -wf} eh-frame5.d}}
750 "eh-frame5.so"}
751 }
752 run_ld_link_tests $eh_frame5_test
753}
0efd4160 754
2f0c68f2
CM
755if {$embedded_elf} {
756 run_dump_test "compact-eh1"
757 run_dump_test "compact-eh2"
758 run_dump_test "compact-eh3"
759}
760
761if {$linux_gnu} {
762 run_dump_test "compact-eh4"
763 run_dump_test "compact-eh5"
764 run_dump_test "compact-eh6"
765}
766
0efd4160 767run_dump_test "jaloverflow"
c314987d 768run_dump_test "jaloverflow-2"
77434823 769
78da84f9
MR
770run_dump_test_o32 "jal-global-overflow-0"
771run_dump_test_o32 "jal-global-overflow-1"
772run_dump_test_o32 "jal-local-overflow-0"
773run_dump_test_o32 "jal-local-overflow-1"
538baf8b 774
78da84f9
MR
775run_dump_test_o32 "undefweak-overflow"
776
777run_dump_test_n32 "undefweak-overflow" [list [list name (n32)]]
778run_dump_test_n64 "undefweak-overflow" [list [list name (n64)]]
779
780run_dump_test_n32 "jalbal" noarch
d6f16593 781
776167e8
CM
782run_dump_test "mode-change-error-1"
783
78da84f9
MR
784run_dump_test_o32 "mips16-hilo"
785run_dump_test_n32 "mips16-hilo-n32"
f4e584bd 786
cc27e1dc 787if { $linux_gnu } {
78da84f9 788 run_dump_test_n32 "textrel-1"
c224138d 789 run_dump_test "got-page-1"
78da84f9
MR
790 run_dump_test_n32 "got-page-2"
791 run_dump_test_n64 "dyn-sec64" noarch
c224138d 792 run_dump_test "got-page-3"
78da84f9
MR
793 if $has_abi(o32) {
794 run_ld_link_tests [subst {
795 {"GOT page 4 (one file)"
796 "-shared $abi_ldflags(o32) -T got-page-1.ld"
797 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
798 {{objdump -dr got-page-4a.d}
799 {readelf -A got-page-4a.got}}
800 "got-page-4a.so"}
801 {"GOT page 4 (two files)"
802 "-shared $abi_ldflags(o32) -T got-page-1.ld"
803 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
804 {{objdump -dr got-page-4b.d}
805 {readelf -A got-page-4b.got}}
806 "got-page-4b.so"}
807 }]
808 }
809 if $has_abi(n32) {
13db6b44
RS
810 run_ld_link_tests [subst {
811 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 812 "" "$abi_asflags(n32)" {got-page-5.s}
13db6b44
RS
813 {{objdump -dr got-page-5.d}
814 {readelf -A got-page-5.got}}
815 "got-page-5.so"}
816 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 817 "" "$abi_asflags(n32)" {got-page-6.s}
13db6b44
RS
818 {{objdump -dr got-page-6.d}
819 {readelf -A got-page-6.got}}
820 "got-page-6.so"}
821 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 822 "" "$abi_asflags(n32)"
13db6b44
RS
823 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
824 got-page-7e.s}
825 {{objdump -dr got-page-7.d}
826 {readelf -A got-page-7.got}}
827 "got-page-7a.so"}
828 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
897aea50 829 "" "$abi_asflags(n32)"
13db6b44
RS
830 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
831 got-page-7d.s}
832 {{objdump -dr got-page-7.d}
833 {readelf -A got-page-7.got}}
834 "got-page-7b.so"}
835 }]
836 }
ccb4c951 837 run_dump_test "got-dump-1"
78da84f9 838 run_dump_test_n64 "got-dump-2" noarch
63897e2c 839 run_dump_test "reloc-estimate-1"
cc27e1dc
EC
840}
841
78da84f9 842run_dump_test_n32 "emit-relocs-1" {{as -EB} {ld -EB}}
81d43bff 843
73934d31
RS
844run_dump_test "hash1a"
845run_dump_test "hash1b"
846run_dump_test "hash1c"
847
78da84f9 848if { $linux_gnu && $has_abi(o32) } {
d68033ea 849 # The number of symbols that are always included in the symbol table
7f923b7f 850 # for these tests.
d68033ea 851 # the null symbol entry
7f923b7f 852 set base_syms 1
d68033ea
MR
853 foreach { isa aflag lflag suffix } \
854 { MIPS -march=mips1 "" "" \
855 microMIPS -mmicromips "" -micromips \
856 "microMIPS insn32" "-mmicromips -minsn32" --insn32 \
857 -micromips-insn32 } {
858 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
859 run_ld_link_tests \
860 [list [list \
861 "Stub for dynsym 0x$dynsym ($isa)" \
862 "-shared -melf32btsmip -T stub-dynsym-1.ld $lflag" \
863 "" \
864 [concat \
865 "-EB $aflag -32 -KPIC" \
866 "--defsym base_syms=$base_syms" \
867 "--defsym dynsym=0x$dynsym"] \
868 [list "stub-dynsym-1.s"] \
869 [list [list \
870 "objdump" "-dz" \
871 "stub-dynsym$suffix-1-$dynsym.d"]] \
872 "stub-dynsym$suffix-1-$dynsym"]]
873 }
4b8377e7
MR
874 run_ld_link_tests [list \
875 [list \
876 "Retained stubs for dynsyms ($isa)" \
877 "-shared -melf32btsmip -T stub-dynsym-2.ld $lflag" "" \
878 "-EB $aflag -32 -KPIC" \
879 [list "stub-dynsym-2.s"] \
880 [list \
881 [list \
882 "objdump" \
883 "-dz -j .MIPS.stubs" \
884 "stub-dynsym$suffix-2.dd"] \
885 [list \
886 "readelf" \
887 "--dyn-syms" \
888 "stub-dynsym$suffix-2.sd"] \
889 [list \
890 "readelf" \
891 "-A" \
892 "stub-dynsym$suffix-2.gd"]] \
893 "stub-dynsym$suffix-2"] \
894 [list \
895 "Discarded stubs for dynsyms ($isa)" \
896 "-shared -melf32btsmip -T stub-dynsym-discard-2.ld $lflag" \
897 "" \
898 "-EB $aflag -32 -KPIC" \
899 [list "stub-dynsym-2.s"] \
900 [list \
901 [list \
902 "readelf" \
903 "--dyn-syms" \
904 "stub-dynsym-discard-2.sd"] \
905 [list \
906 "readelf" \
907 "-A" \
908 "stub-dynsym-discard-2.gd"]] \
909 "stub-dynsym-discard$suffix-2"]]
d68033ea
MR
910 }
911}
5108fc1b 912
f4e584bd
DJ
913# For tests which may involve multiple files, use run_ld_link_tests.
914
915# List contains test-items with 3 items followed by 2 lists:
897aea50
MR
916# 0:name 1:ld early options 2:ld late options 3:assembler options
917# 4:filenames of assembler files 5: action and options. 6: name of output file
f4e584bd
DJ
918
919# Actions:
920# objdump: Apply objdump options on result. Compare with regex (last arg).
921# nm: Apply nm options on result. Compare with regex (last arg).
922# readelf: Apply readelf options on result. Compare with regex (last arg).
923
924set mips_tls_tests {
897aea50 925 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
f4e584bd
DJ
926 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
927 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
928 "tls-static-o32"}
9143e72c
MR
929 {"Static PIE executable with TLS"
930 "-static -pie -melf32btsmip -T mips-dyn.ld" ""
931 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
932 {{objdump {-dr -m mips:isa32r2} tlsbin-pie-o32.d}
933 {objdump -Rsj.got tlsbin-pie-o32.got}}
934 "tls-static-pie-o32"}
897aea50 935 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
936 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
937 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
938 "tlslib-o32.so"}
939 {"Dynamic executable with TLS"
897aea50 940 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
f4e584bd
DJ
941 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
942 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
943 "tls-dynamic-o32"}
9143e72c
MR
944 {"Dynamic PIE executable with TLS"
945 "-pie -melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
946 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
947 {{objdump {-dr -m mips:isa32r2} tlsdyn-pie-o32.d}
948 {objdump -Rsj.got tlsdyn-pie-o32.got}}
949 "tls-dynamic-pie-o32"}
f4e584bd 950 {"Shared library with multiple GOTs and TLS"
897aea50 951 "-shared -melf32btsmip -T mips-lib.ld" ""
f4e584bd
DJ
952 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
953 {{readelf {-d -r} tls-multi-got-1.r}
954 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
955 {objdump -Rsj.got tls-multi-got-1.got}}
956 "tlslib-multi.so"}
957 {"Shared library with TLS and versioning"
897aea50 958 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
f4e584bd
DJ
959 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
960 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
961 "tlslib-o32-ver.so"}
962 {"Dynamic executable with TLS and versioning"
897aea50 963 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
f4e584bd
DJ
964 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
965 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
966 "tls-dynamic-o32-ver"}
967 {"Dynamic executable with TLS and versioning (order 2)"
897aea50 968 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
f4e584bd
DJ
969 "-EB -march=mips1 -32 -KPIC" {}
970 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
971 "tls-dynamic-o32-ver-2"}
972 {"Dynamic executable with TLS and versioning (order 3)"
897aea50 973 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
f4e584bd
DJ
974 "-EB -march=mips1 -32 -KPIC" {}
975 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
976 "tls-dynamic-o32-ver-3"}
977 {"Shared library with TLS and hidden symbols"
897aea50 978 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
f4e584bd
DJ
979 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
980 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
981 "tlslib-o32-hidden.so"}
4005427f 982 {"Shared library with TLS and hidden symbols (2)"
897aea50 983 "-shared -melf32btsmip -T mips-lib.ld" ""
4005427f
RS
984 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
985 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
986 "tls-hidden2.so"}
ead49a57 987 {"Shared library with TLS and hidden symbols (3)"
897aea50 988 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
989 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
990 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
991 {readelf --relocs tls-hidden3.r}}
992 "tls-hidden3.so"}
993 {"Shared library with TLS and hidden symbols (4)"
897aea50 994 "-shared -melf32btsmip -T tls-hidden3.ld" ""
ead49a57
RS
995 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
996 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
997 "tls-hidden4.so"}
f4e584bd
DJ
998}
999
78da84f9 1000if { $linux_gnu && $has_abi(o32) } {
f4e584bd
DJ
1001 run_ld_link_tests $mips_tls_tests
1002}
1003
08e8dfaf
RS
1004set mips16_call_global_test [list \
1005 [list "Global calls from mips16" \
897aea50 1006 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
ef2b5578 1007 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
1008 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
1009 {{objdump -dr mips16-call-global.d}} \
1010 "mips16-call-global"]]
35d3d567 1011
78da84f9
MR
1012if { $has_abi(o32) } {
1013 run_ld_link_tests $mips16_call_global_test
1014}
b9d58d71 1015
08e8dfaf
RS
1016set mips16_intermix_test [list \
1017 [list "Intermixing mips32 and mips16 functions" \
897aea50 1018 "$abi_ldflags(o32)" "" \
ef2b5578 1019 "$abi_asflags(o32) -mips32r2" \
08e8dfaf
RS
1020 {mips16-intermix-1.s mips16-intermix-2.s} \
1021 {{objdump -t mips16-intermix.d}} \
1022 "mips16-intermix"]]
b9d58d71 1023
78da84f9
MR
1024if { $has_abi(o32) } {
1025 run_ld_link_tests $mips16_intermix_test
1026}
b314ec0e
RS
1027
1028run_dump_test "mips16-local-stubs-1"
2cf19d5c 1029
ca9584fb
CM
1030set mips16_fp_stub_test [list \
1031 [list "Floating-point stub for mips16 functions" \
1032 "$abi_ldflags(o32)" "" \
1033 "$abi_asflags(o32) -mips32r2" \
1034 {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
1035 {{readelf --debug-dump=frames mips16-fp-stub.d}} \
1036 "mips16-fp-stub"]]
1037
78da84f9
MR
1038if { $has_abi(o32) } {
1039 run_ld_link_tests $mips16_fp_stub_test
1040}
e319abb4 1041
351cdf24 1042foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
e319abb4 1043 foreach secondfpabi [list 4 5 6 7 ] {
78da84f9 1044 run_dump_test_o32 "attr-gnu-4-${firstfpabi}${secondfpabi}"
e319abb4
MF
1045 }
1046}
1047foreach firstfpabi [list 4 5 6 7 ] {
3350cc01 1048 foreach secondfpabi [list 0 1 2 3 8 9] {
78da84f9 1049 run_dump_test_o32 "attr-gnu-4-${firstfpabi}${secondfpabi}"
e319abb4
MF
1050 }
1051}
1052foreach firstfpabi [list 0 1 2 3 ] {
3350cc01 1053 foreach secondfpabi [list 0 1 2 3 8 9] {
351cdf24
MF
1054 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
1055 }
1056}
e319abb4 1057
351cdf24
MF
1058run_dump_test "attr-gnu-4-81"
1059
1060run_dump_test "attr-gnu-8-00"
1061run_dump_test "attr-gnu-8-01"
1062run_dump_test "attr-gnu-8-02"
1063run_dump_test "attr-gnu-8-10"
1064run_dump_test "attr-gnu-8-11"
1065run_dump_test "attr-gnu-8-12"
1066run_dump_test "attr-gnu-8-20"
1067run_dump_test "attr-gnu-8-21"
1068run_dump_test "attr-gnu-8-22"
1069
78da84f9
MR
1070run_dump_test_o32 "attr-gnu-4-0-ph"
1071run_dump_test_o32 "attr-gnu-4-1-ph"
1072run_dump_test_o32 "attr-gnu-4-2-ph"
1073run_dump_test_o32 "attr-gnu-4-3-ph"
1074run_dump_test_o32 "attr-gnu-4-4-ph"
1075run_dump_test_o32 "attr-gnu-4-5-ph"
1076run_dump_test_o32 "attr-gnu-4-6-ph"
1077run_dump_test_o32 "attr-gnu-4-7-ph"
1078
1079run_dump_test_n32 "attr-gnu-4-0-n32-ph" noarch
1080run_dump_test_n32 "attr-gnu-4-1-n32-ph" noarch
1081run_dump_test_n32 "attr-gnu-4-2-n32-ph" noarch
1082run_dump_test_n32 "attr-gnu-4-3-n32-ph" noarch
1083run_dump_test_n64 "attr-gnu-4-0-n64-ph" noarch
1084run_dump_test_n64 "attr-gnu-4-1-n64-ph" noarch
1085run_dump_test_n64 "attr-gnu-4-2-n64-ph" noarch
1086run_dump_test_n64 "attr-gnu-4-3-n64-ph" noarch
1087
1088run_dump_test_o32 "abiflags-strip1-ph"
1089run_dump_test_o32 "abiflags-strip2-ph"
1090run_dump_test_o32 "abiflags-strip3-ph"
1091run_dump_test_o32 "abiflags-strip4-ph"
1092run_dump_test_o32 "abiflags-strip5-ph"
1093run_dump_test_o32 "abiflags-strip6-ph"
1094run_dump_test_o32 "abiflags-strip7-ph"
1095run_dump_test_o32 "abiflags-strip8-ph"
1096run_dump_test_o32 "abiflags-strip9-ph"
1097run_dump_test_o32 "abiflags-strip10-ph"
634835ae 1098
ba92f887
MR
1099run_dump_test "nan-legacy"
1100run_dump_test "nan-2008"
1101run_dump_test "nan-mixed-1"
1102run_dump_test "nan-mixed-2"
1103
78da84f9 1104if { $linux_gnu && $has_abi(o32) } {
634835ae
RS
1105 run_ld_link_tests {
1106 {"GOT and versioning 1"
897aea50 1107 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
634835ae
RS
1108 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
1109 {{readelf -d got-vers-1.dd}
1110 {readelf --symbols got-vers-1.sd}
1111 {readelf --relocs got-vers-1.rd}}
1112 "got-vers-1.so"}
1113 }
1114}
e7e2196d
MR
1115
1116run_dump_test "undefined"
dfb93f11 1117run_dump_test "undefined-warn"
1063d8cf
CF
1118
1119# Test the conversion from jr to b
1120if { $linux_gnu } {
78da84f9
MR
1121 run_dump_test_o32 "jr-to-b-1" noarch
1122 run_dump_test_o32 "jr-to-b-2" noarch
1063d8cf 1123}
df58fc94
RS
1124
1125# MIPS16 and microMIPS interlinking test.
1126run_dump_test "mips16-and-micromips"
9b11fa1a 1127
78da84f9
MR
1128set abis {}
1129if $has_abi(o32) {
1130 lappend abis o32
1131}
1132if $has_abi(n32) {
1133 lappend abis n32
1134}
1135if $has_abi(n64) {
1136 lappend abis n64
1137}
1138
9b11fa1a 1139# Export class call relocation tests.
500c05dd
MR
1140if [check_shared_lib_support] {
1141 foreach { abi } $abis {
1142 set loadaddr [string map \
1143 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
1144 set suff [subst \
1145 [expr { $irix \
1146 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
1147 : $abi }]]
1148 run_ld_link_tests [list \
9b11fa1a 1149 [list \
500c05dd
MR
1150 "MIPS export class call relocation test ($abi)" \
1151 "$abi_ldflags($abi) -shared -Ttext $loadaddr\
1152 -T export-class-call16.ld" \
1153 "" \
1154 "$abi_asflags($abi) -mips3 -KPIC" \
1155 [list export-class-call16-${abi}.s export-class-call16-def.s] \
1156 [list \
1157 "objdump -d export-class-call16-${suff}.dd" \
1158 "readelf -A export-class-call16-${abi}.gd"] \
1159 "export-class-call16-${abi}.so"]]
1160 }
9b11fa1a 1161}
cde7cb01
MR
1162
1163# Magic __ehdr_start symbol tests.
cde7cb01
MR
1164foreach { abi } $abis {
1165 set suff [string map {o32 o32 n32 new n64 new} $abi]
1166 run_ld_link_tests [list \
1167 [list \
1168 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
1169 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
1170 "$abi_asflags($abi)" \
1171 [list ehdr_start-${suff}.s] \
1172 [list "readelf -s ehdr_start-1.nd"] \
31321c80 1173 "ehdr_start-1-${abi}"] \
cde7cb01
MR
1174 [list \
1175 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
1176 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
1177 "$abi_asflags($abi)" \
1178 [list ehdr_start-${suff}.s] \
1179 [list "readelf -s ehdr_start-2.nd"] \
1180 "ehdr_start-2-${abi}"]]
1181}
d6101ac2
MR
1182
1183# R_MIPS_JALR reloc tests.
d6101ac2
MR
1184foreach { abi } $abis {
1185 run_ld_link_tests [list \
1186 [list \
1187 "MIPS JALR reloc test ($abi)" \
1188 "$abi_ldflags($abi) -T jalr3.ld" "" \
1189 "$abi_asflags($abi)" \
1190 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
1191 [list "objdump -d jalr3.dd"] \
c1556ecd
MR
1192 "jalr3-${abi}"] \
1193 [list \
1194 "MIPS JALR reloc unaligned/cross-mode link test ($abi)" \
1195 "$abi_ldflags($abi) -T jalr3.ld" "" \
1196 "$abi_asflags($abi)" \
1197 [list ../../../gas/testsuite/gas/mips/jalr4.s] \
1198 [list "objdump {-d --prefix-addresses --show-raw-insn} jalr4.dd"] \
0e392101
MR
1199 "jalr4-${abi}"] \
1200 [list \
1201 "MIPSr6 JALR reloc unaligned/cross-mode link test ($abi)" \
1202 "$abi_ldflags($abi) -T jalr3.ld" "" \
78da84f9
MR
1203 "[string map\
1204 [list o32 -mips32r6\
1205 n32 -mips64r6\
1206 n64 -mips64r6] $abi ]\
1207 [regsub -- {-march=[^[:blank:]]*} $abi_asflags($abi) {}]" \
0e392101
MR
1208 {../../../gas/testsuite/gas/mips/jalr4.s} \
1209 {{objdump {-d --prefix-addresses --show-raw-insn} jalr4-r6.dd}} \
c1556ecd 1210 "jalr4-${abi}"]]
d6101ac2 1211}
690f47bf
RS
1212
1213proc build_mips_plt_lib { abi } {
1214 global abi_asflags
1215 global abi_ldflags
1216
1217 run_ld_link_tests [list \
1218 [list "Shared $abi library for compressed PLT tests" \
1219 "-shared $abi_ldflags($abi)" "" \
1220 "$abi_asflags($abi)" \
1221 { compressed-plt-1-dyn.s } \
1222 {} \
1223 "compressed-plt-1-${abi}-dyn.so"]]
1224}
1225
1226proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
1227 global abi_asflags
1228 global abi_ldflags
1229
1230 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
1231 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
1232 if {[string equal $abi o32]} {
1233 append as_flags " -march=mips2"
1234 }
1235 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
1236 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
1237 set files [list]
54806ffa 1238 if { $filter & 7 } {
690f47bf
RS
1239 lappend files compressed-plt-1a.s
1240 }
54806ffa 1241 if { $filter & 56 } {
690f47bf
RS
1242 lappend files compressed-plt-1b.s
1243 }
54806ffa 1244 if { $filter & 64 } {
690f47bf
RS
1245 lappend files compressed-plt-1c.s
1246 }
1247 eval [list lappend files] $extra
1248 set readelf_flags "-A --syms --relocs -d"
1249 if { [string match "*word*" $suffix] } {
1250 append readelf_flags " -x.data"
1251 }
1252 set objdump_flags "-d -Mgpr-names=numeric"
1253 set basename "compressed-plt-1-${abi}-${suffix}"
1254 run_ld_link_tests [list \
1255 [list "$name" $ld_flags $dynobj \
1256 "$as_flags" $files \
1257 [list [list readelf $readelf_flags ${basename}.rd] \
1258 [list objdump $objdump_flags ${basename}.od]] \
1259 $basename]]
1260}
1261
78da84f9 1262if { $linux_gnu && $has_abi(o32) } {
690f47bf 1263 build_mips_plt_lib o32
54806ffa
MR
1264 run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
1265 run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
1266 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
1267 run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
1268 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
1269 run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
690f47bf 1270 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
54806ffa
MR
1271 o32 109 0 mips16
1272 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
1273 o32 18 0 mips16-branch
690f47bf 1274 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
54806ffa 1275 o32 109 0 mips16-got compressed-plt-1d.s
690f47bf 1276 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
54806ffa 1277 o32 109 0 mips16-word compressed-plt-1e.s
690f47bf 1278 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
54806ffa
MR
1279 o32 109 1 umips
1280 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
1281 o32 18 1 umips-branch
690f47bf 1282 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
54806ffa 1283 o32 109 1 umips-got compressed-plt-1d.s
690f47bf 1284 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
54806ffa 1285 o32 109 1 umips-word compressed-plt-1e.s
78da84f9 1286}
690f47bf 1287
78da84f9
MR
1288if { $linux_gnu && $has_abi(n32) } {
1289 build_mips_plt_lib n32
1290 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
1291 n32 109 0 mips16
1292 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
1293 n32 109 1 umips
690f47bf 1294}
1f599d0e 1295
789ff5b6
MR
1296# Verify graceful handling of n64 PLT 32-bit range overflows. Given
1297# that the alignment of `.got.plt' is 8 the highest usable positive
1298# address is 0x7fff7ff8 and the lowest usable negative address is
1299# 0xffffffff7fff8000.
78da84f9 1300if { $linux_gnu && $has_abi(n64) } {
789ff5b6
MR
1301 run_ld_link_tests [list \
1302 [list "Shared library for MIPS n64 PLT 32-bit range tests" \
1303 "-shared $abi_ldflags(n64)" "" \
1304 "$abi_asflags(n64)" \
1305 { n64-plt-lib.s } \
1306 {} \
1307 "n64-plt-lib.so"] \
1308 [list "MIPS n64 PLT 32-bit range test 1" \
1309 "$abi_ldflags(n64) -T n64-plt-1.ld -e foo" \
1310 "tmpdir/n64-plt-lib.so" \
1311 "$abi_asflags(n64)" \
1312 { n64-plt.s } \
1313 { { objdump -d n64-plt-1.dd } \
1314 { readelf -A n64-plt-1.gd } } \
1315 "n64-plt-1"] \
1316 [list "MIPS n64 PLT 32-bit range test 2" \
1317 "$abi_ldflags(n64) -T n64-plt-2.ld -e foo" \
1318 "tmpdir/n64-plt-lib.so" \
1319 "$abi_asflags(n64)" \
1320 { n64-plt.s } \
1321 { { ld n64-plt-2.ed } } \
1322 "n64-plt-2"] \
1323 [list "MIPS n64 PLT 32-bit range test 3" \
1324 "$abi_ldflags(n64) -T n64-plt-3.ld -e foo" \
1325 "tmpdir/n64-plt-lib.so" \
1326 "$abi_asflags(n64)" \
1327 { n64-plt.s } \
1328 { { ld n64-plt-3.ed } } \
1329 "n64-plt-3"] \
1330 [list "MIPS n64 PLT 32-bit range test 4" \
1331 "$abi_ldflags(n64) -T n64-plt-4.ld -e foo" \
1332 "tmpdir/n64-plt-lib.so" \
1333 "$abi_asflags(n64)" \
1334 { n64-plt.s } \
1335 { { objdump -d n64-plt-4.dd } \
1336 { readelf -A n64-plt-4.gd } } \
1337 "n64-plt-4"]]
1338}
1339
1f599d0e 1340# PR ld/19908 export class tests.
78da84f9 1341if { $linux_gnu && $has_abi(o32) } {
1f599d0e
MR
1342 run_ld_link_tests [list \
1343 [list "Shared library for MIPS export class symbol reference tests" \
1344 "$abi_ldflags(o32) -shared" "" \
1345 "$abi_asflags(o32)" \
1346 { export-class-ref-f2.s } \
1347 { { readelf --dyn-syms export-class-ref-lib.sd } } \
1348 "export-class-ref-lib.so"]]
1349 foreach { class flag } { internal 1 hidden 2 protected 3 } {
1350 run_ld_link_tests [list \
1351 [list "MIPS $class symbol reference test 1" \
1352 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1353 "$abi_asflags(o32) --defsym defv=$flag" \
1354 { export-class-ref-f0.s export-class-ref-f1.s } \
1355 [list [list readelf --dyn-syms export-$class-ref.sd] \
1356 [list readelf --dyn-syms export-local-ref.sd]] \
1357 "export-$class-ref"] \
1358 [list "MIPS $class symbol reference test 2" \
1359 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1360 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
1361 { export-class-ref-f0.s export-class-ref-f1.s } \
1362 [list [list readelf --dyn-syms export-$class-ref.sd] \
1363 [list readelf --dyn-syms export-local-ref.sd]] \
1364 "export-$class-ref"]]
1365 }
1366}
23ec1e32
MR
1367
1368# PR ld/21334 GOT relocation in static binary test.
78da84f9
MR
1369if { $has_abi(o32) } {
1370 run_ld_link_tests [list \
1371 [list \
1372 "PR ld/21334 MIPS GOT16 relocation in static binary" \
1373 "$abi_ldflags(o32) -e foo -T pr21334.ld" "" "$abi_asflags(o32)" \
1374 {pr21334.s} \
1375 {{objdump {-d --prefix-addresses} pr21334.dd} \
1376 {readelf -A pr21334.gd}} \
1377 "pr21334"]]
1378}
b417536f
MR
1379
1380# Check that the ISA level is consistently II for the LSI 4010.
78da84f9 1381run_dump_test_o32 "lsi-4010-isa" noarch
9f00292e
MR
1382
1383# PIC branch relaxation with offset tests. We need to use our version
1384# of `prune_warnings' to get rid of GAS branch relaxation noise.
78da84f9
MR
1385if { $has_abi(o32) } {
1386 rename prune_warnings mips_old_prune_warnings
1387 proc prune_warnings { msg } {
1388 set msg1 "Assembler messages:"
1389 set msg2 "Warning: relaxed out-of-range branch into a jump"
1390 set msgx "(?:$msg1|$msg2)"
1391 regsub -all "(^|\[\n\r\]*)\[^\n\r\]*: $msgx\[\n\r\]*" $msg "\\1" msg
1392 return [mips_old_prune_warnings $msg]
1393 }
1394 run_ld_link_tests [list \
1395 [list \
1396 "MIPS link PIC branch relaxation with offset" \
1397 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1398 "$abi_asflags(o32) -relax-branch -mips2" \
1399 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1400 {{objdump \
1401 {-d --prefix-addresses --show-raw-insn} \
1402 relax-offset.dd} \
1403 {readelf -A relax-offset.gd}} \
1404 "relax-offset"] \
1405 [list \
1406 "microMIPS link PIC branch relaxation with offset" \
1407 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1408 "$abi_asflags(o32) -relax-branch -mmicromips" \
1409 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1410 {{objdump \
1411 {-d --prefix-addresses --show-raw-insn} \
1412 relax-offset-umips.dd} \
1413 {readelf -A relax-offset-umips.gd}} \
1414 "relax-offset-umips"]]
1415 rename prune_warnings ""
1416 rename mips_old_prune_warnings prune_warnings
9f00292e 1417}
e54cb31a
MR
1418
1419# Verify that we can link ELF input into the `binary' output format.
1420run_dump_test "binary"
6798f8bf
MR
1421
1422# Verify special section processing.
78da84f9 1423if { $has_abi(o32) || $has_abi(n32) } {
6798f8bf
MR
1424 run_dump_test "reginfo-0"
1425 run_dump_test "reginfo-0r"
1426 run_dump_test "reginfo-1"
1427 run_dump_test "reginfo-1r"
1428 run_dump_test "reginfo-2"
1429 run_dump_test "reginfo-2r"
1430}
1431run_dump_test "mips-abiflags-0"
1432run_dump_test "mips-abiflags-0r"
1433run_dump_test "mips-abiflags-1"
1434run_dump_test "mips-abiflags-1r"
1435run_dump_test "mips-abiflags-2"
1436run_dump_test "mips-abiflags-2r"
3be08ea4
SA
1437
1438# Test that _gp_disp symbol is not present in symbol tables.
78da84f9 1439run_dump_test_o32 "gp-disp-sym"
This page took 0.81103 seconds and 4 git commands to generate.