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