Commit | Line | Data |
---|---|---|
a657e7c1 | 1 | # Expect script for MIPS ELF linker tests |
aa820537 AM |
2 | # Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
3 | # Free Software Foundation, Inc. | |
a657e7c1 | 4 | # |
f96b4a7b NC |
5 | # This file is part of the GNU Binutils. |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
a657e7c1 | 8 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
a657e7c1 CD |
10 | # (at your option) any later version. |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
a657e7c1 CD |
21 | # |
22 | ||
0a44bf69 RS |
23 | if {[istarget "mips*-*-vxworks"]} { |
24 | set mipsvxtests { | |
897aea50 | 25 | {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" "" |
0a44bf69 RS |
26 | "-mips2" {vxworks1-lib.s} |
27 | {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd} | |
9e3313ae | 28 | {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}} |
0a44bf69 RS |
29 | "libvxworks1.so"} |
30 | {"VxWorks executable test 1 (dynamic)" \ | |
897aea50 | 31 | "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" "" |
0a44bf69 RS |
32 | "-mips2" {vxworks1.s} |
33 | {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}} | |
34 | "vxworks1"} | |
35 | {"VxWorks executable test 2 (dynamic)" \ | |
897aea50 | 36 | "-Tvxworks1.ld -q --force-dynamic" "" |
0a44bf69 RS |
37 | "-mips2" {vxworks2.s} |
38 | {{readelf --segments vxworks2.sd}} | |
39 | "vxworks2"} | |
40 | {"VxWorks executable test 2 (static)" | |
897aea50 | 41 | "-Tvxworks1.ld" "" |
0a44bf69 RS |
42 | "-mips2" {vxworks2.s} |
43 | {{readelf --segments vxworks2-static.sd}} | |
44 | "vxworks2"} | |
45 | } | |
46 | run_ld_link_tests $mipsvxtests | |
47 | run_dump_test "vxworks1-static" | |
8275b357 | 48 | run_dump_test "vxworks-forced-local-1" |
0a44bf69 RS |
49 | return |
50 | } | |
51 | ||
fbf18a5c TS |
52 | if {![istarget mips*-*-*] || ![is_elf_format]} { |
53 | return | |
54 | } | |
30a2f863 | 55 | |
ef2b5578 | 56 | set has_newabi [expr [istarget *-*-irix6*] \ |
99262e37 | 57 | || [istarget mips*-*-linux*] \ |
ef2b5578 | 58 | || [istarget mips*-sde-elf*]] |
fbf18a5c TS |
59 | set linux_gnu [expr [istarget mips*-*-linux*]] |
60 | set embedded_elf [expr [istarget mips*-*-elf]] | |
30a2f863 | 61 | |
ef2b5578 MR |
62 | # Set defaults. |
63 | set abi_asflags(o32) "" | |
99262e37 MR |
64 | set abi_asflags(n32) "-march=from-abi -n32 -EB" |
65 | set abi_asflags(n64) "-march=from-abi -64 -EB" | |
ef2b5578 MR |
66 | set abi_ldflags(o32) "" |
67 | set abi_ldflags(n32) -melf32bmipn32 | |
68 | set abi_ldflags(n64) -melf64bmip | |
69 | ||
70 | # Override as needed. | |
71 | if { [istarget *-*-irix6*] } { | |
72 | set abi_asflags(o32) "-32 -EB" | |
73 | set abi_ldflags(o32) -melf32bsmip | |
74 | } elseif { [istarget mips64*-linux*] } { | |
75 | set abi_asflags(o32) "-32 -EB" | |
76 | set abi_ldflags(o32) -melf32btsmip | |
77 | } elseif { [istarget mips64*-*freebsd*] } { | |
78 | set abi_asflags(o32) "-32 -EB" | |
79 | set abi_ldflags(o32) -melf32btsmip_fbsd | |
80 | } | |
81 | if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*] } { | |
82 | set abi_ldflags(n32) -melf32btsmipn32 | |
83 | set abi_ldflags(n64) -melf64btsmip | |
84 | } elseif { [istarget mips64*-*freebsd*] } { | |
85 | set abi_ldflags(n32) -melf32btsmipn32_fbsd | |
86 | set abi_ldflags(n64) -melf64btsmip_fbsd | |
87 | } | |
88 | ||
738e5348 RS |
89 | if { $linux_gnu } { |
90 | run_ld_link_tests [list \ | |
91 | [list "Dummy shared library for MIPS16 PIC test 1" \ | |
897aea50 | 92 | "-shared -melf32btsmip" "" \ |
3c0bfb2a RS |
93 | "-EB -32 -mips1" \ |
94 | { mips16-pic-1-dummy.s } \ | |
738e5348 RS |
95 | {} \ |
96 | "mips16-pic-1-dummy.so"] \ | |
97 | [list "MIPS16 PIC test 1" \ | |
897aea50 | 98 | "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \ |
3c0bfb2a RS |
99 | "-EB -32 -mips1 -I $srcdir/$subdir" \ |
100 | { mips16-pic-1a.s mips16-pic-1b.s } \ | |
738e5348 RS |
101 | { { objdump { -dr -j.text } mips16-pic-1.dd } |
102 | { readelf -A mips16-pic-1.gd } } \ | |
103 | "mips16-pic-1"] \ | |
104 | [list "MIPS16 PIC test 2" \ | |
897aea50 | 105 | "-melf32btsmip -T mips16-pic-1.ld -shared" "" \ |
3c0bfb2a RS |
106 | "-EB -32 -mips1 -I $srcdir/$subdir" \ |
107 | { mips16-pic-2a.s mips16-pic-2b.s } \ | |
738e5348 RS |
108 | { { objdump { -dr -j.text } mips16-pic-2.dd } \ |
109 | { readelf -A mips16-pic-2.gd } \ | |
110 | { readelf --symbols mips16-pic-2.nd } \ | |
111 | { readelf --relocs mips16-pic-2.rd } \ | |
112 | { readelf -d mips16-pic-2.ad } } \ | |
861fb55a DJ |
113 | "mips16-pic-2"] \ |
114 | [list "MIPS16 PIC test 3" \ | |
897aea50 | 115 | "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \ |
3c0bfb2a RS |
116 | "-EB -32 -mips1 -I $srcdir/$subdir" \ |
117 | { mips16-pic-3a.s mips16-pic-3b.s } \ | |
861fb55a DJ |
118 | { { objdump -dr mips16-pic-3.dd } \ |
119 | { readelf --relocs mips16-pic-3.rd } \ | |
120 | { readelf -A mips16-pic-3.gd } } \ | |
61b0a4af RS |
121 | "mips16-pic-3"] \ |
122 | [list "MIPS16 PIC test 4 (shared library)" \ | |
897aea50 | 123 | "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \ |
3c0bfb2a RS |
124 | "-EB -32 -mips1" \ |
125 | { mips16-pic-4a.s mips16-pic-4b.s } \ | |
61b0a4af RS |
126 | { { objdump -dr mips16-pic-4a.dd } \ |
127 | { readelf --symbols mips16-pic-4a.nd } \ | |
128 | { readelf -A mips16-pic-4a.gd } } \ | |
129 | "mips16-pic-4.so"] \ | |
130 | [list "MIPS16 PIC test 4 (executable)" \ | |
897aea50 | 131 | "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \ |
3c0bfb2a RS |
132 | "-EB -32 -mips1" \ |
133 | { mips16-pic-4c.s } \ | |
61b0a4af RS |
134 | { { objdump -dr mips16-pic-4b.dd } } \ |
135 | "mips16-pic-4"]] | |
738e5348 RS |
136 | } |
137 | ||
fbf18a5c TS |
138 | # Check MIPS16 markings being passed through link. |
139 | run_dump_test "mips16-1" | |
8914585c | 140 | |
fbf18a5c TS |
141 | # MIPS branch offset final link checking. |
142 | run_dump_test "branch-misc-1" | |
7d6c7577 | 143 | |
df58fc94 RS |
144 | # Jalx test |
145 | run_dump_test "jalx-1" | |
146 | ||
147 | if { $linux_gnu } { | |
148 | run_ld_link_tests [list \ | |
149 | [list "Dummy shared library for JALX test 2" \ | |
897aea50 | 150 | "-shared -nostdlib -melf32btsmip" "" \ |
df58fc94 RS |
151 | "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \ |
152 | { jalx-2-printf.s } \ | |
153 | {} \ | |
154 | "libjalx-2.so"] \ | |
155 | [list "Dummy external function for JALX test 2" \ | |
897aea50 | 156 | "-r -melf32btsmip" "" \ |
df58fc94 RS |
157 | "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \ |
158 | { jalx-2-ex.s } \ | |
159 | {} \ | |
160 | "jalx-2-ex.o.r"] \ | |
161 | [list "MIPS JALX test 2" \ | |
897aea50 | 162 | "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \ |
df58fc94 RS |
163 | "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \ |
164 | { jalx-2-main.s } \ | |
165 | { { objdump -d jalx-2.dd } } \ | |
166 | "jalx-2"]] | |
167 | } | |
168 | ||
732be173 DJ |
169 | # Test multi-got link. We only do this on GNU/Linux because it requires |
170 | # the "traditional" emulations. | |
171 | if { $linux_gnu } { | |
172 | run_dump_test "multi-got-1" | |
bbe506e8 | 173 | run_dump_test "multi-got-no-shared" |
2152e047 DJ |
174 | run_dump_test "multi-got-hidden-1" |
175 | run_dump_test "multi-got-hidden-2" | |
732be173 | 176 | } |
30a2f863 | 177 | |
0a61c8c2 RS |
178 | # Test __gnu_local_gp accesses |
179 | if { $linux_gnu } { | |
180 | run_dump_test "no-shared-1-o32" | |
181 | if { $has_newabi } { | |
182 | run_dump_test "no-shared-1-n32" | |
183 | run_dump_test "no-shared-1-n64" | |
184 | } | |
185 | } | |
186 | ||
fbf18a5c | 187 | if $has_newabi { |
ef2b5578 MR |
188 | if { $embedded_elf } { |
189 | run_dump_test "elf-rel-got-n32-embed" \ | |
190 | [list [list ld $abi_ldflags(n32)]] | |
191 | run_dump_test "elf-rel-xgot-n32-embed" \ | |
192 | [list [list ld $abi_ldflags(n32)]] | |
193 | } else { | |
194 | run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]] | |
195 | run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]] | |
196 | } | |
48fe7bda | 197 | if { $linux_gnu } { |
ef2b5578 MR |
198 | run_dump_test "elf-rel-got-n64-linux" \ |
199 | [list [list ld $abi_ldflags(n64)]] | |
200 | run_dump_test "elf-rel-xgot-n64-linux" \ | |
201 | [list [list ld $abi_ldflags(n64)]] | |
202 | } elseif { $embedded_elf } { | |
203 | run_dump_test "elf-rel-got-n64-embed" \ | |
204 | [list [list ld $abi_ldflags(n64)]] | |
205 | run_dump_test "elf-rel-xgot-n64-embed" \ | |
206 | [list [list ld $abi_ldflags(n64)]] | |
fbf18a5c | 207 | } else { |
ef2b5578 MR |
208 | run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]] |
209 | run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]] | |
48fe7bda AO |
210 | } |
211 | ||
fbf18a5c TS |
212 | run_dump_test "relax-jalr-n32" |
213 | run_dump_test "relax-jalr-n32-shared" | |
214 | run_dump_test "relax-jalr-n64" | |
215 | run_dump_test "relax-jalr-n64-shared" | |
216 | } | |
48fe7bda | 217 | |
fbf18a5c TS |
218 | if { $linux_gnu } { |
219 | run_dump_test "rel32-o32" | |
250826bd RS |
220 | if { $has_newabi } { |
221 | run_dump_test "rel32-n32" | |
222 | run_dump_test "rel64" | |
223 | } | |
861fb55a DJ |
224 | # The first test checks that a mixed PIC/non-PIC relocatable link |
225 | # will not introduce any stubs itself, but will flag PIC functions | |
226 | # for the final link. | |
227 | # | |
228 | # The second test checks that we insert stubs for calls from | |
229 | # non-PIC functions to PIC functions when linking the original | |
230 | # two objects together. | |
231 | # | |
232 | # The third test checks that we do the same when linking the | |
233 | # result of the first link (with no other source files). | |
234 | run_ld_link_tests { | |
897aea50 | 235 | {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" "" |
861fb55a DJ |
236 | "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s} |
237 | {{objdump -dr pic-and-nonpic-1-rel.dd} | |
238 | {readelf --symbols pic-and-nonpic-1-rel.nd}} | |
239 | "pic-and-nonpic-1-rel.o"} | |
240 | {"PIC and non-PIC test 1 (static 1)" | |
897aea50 | 241 | "-melf32btsmip -Tpic-and-nonpic-1.ld" "" |
861fb55a DJ |
242 | "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s} |
243 | {{objdump -dr pic-and-nonpic-1.dd} | |
244 | {readelf --symbols pic-and-nonpic-1.nd}} | |
245 | "pic-and-nonpic-1-static1.o"} | |
246 | {"PIC and non-PIC test 1 (static 2)" | |
897aea50 | 247 | "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" "" |
861fb55a DJ |
248 | "" {} |
249 | {{objdump -dr pic-and-nonpic-1.dd} | |
250 | {readelf --symbols pic-and-nonpic-1.nd}} | |
251 | "pic-and-nonpic-1-static2.o"} | |
252 | } | |
253 | run_dump_test "pic-and-nonpic-2" | |
254 | run_ld_link_tests { | |
255 | {"PIC and non-PIC test 3 (shared library)" | |
897aea50 | 256 | "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" "" |
861fb55a DJ |
257 | "-32 -EB -mips2" {pic-and-nonpic-3a.s} |
258 | {{readelf --segments pic-and-nonpic-3a.sd} | |
259 | {readelf -A pic-and-nonpic-3a.gd} | |
260 | {objdump -dr pic-and-nonpic-3a.dd}} | |
261 | "pic-and-nonpic-3a.so"} | |
262 | {"PIC and non-PIC test 3 (executable)" | |
897aea50 | 263 | "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" "" |
861fb55a DJ |
264 | "-32 -EB -mips2" {pic-and-nonpic-3b.s} |
265 | {{readelf --segments pic-and-nonpic-3b.sd} | |
266 | {objdump -dr pic-and-nonpic-3b.dd} | |
267 | {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd} | |
268 | {readelf -A pic-and-nonpic-3b.gd} | |
269 | {readelf --relocs pic-and-nonpic-3b.rd} | |
270 | {readelf --symbols pic-and-nonpic-3b.nd} | |
271 | {readelf -d pic-and-nonpic-3b.ad}} | |
272 | "pic-and-nonpic-3b"} | |
273 | } | |
274 | run_dump_test "pic-and-nonpic-3-error" | |
275 | run_ld_link_tests { | |
276 | {"PIC and non-PIC test 4 (shared library)" | |
897aea50 | 277 | "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" "" |
861fb55a DJ |
278 | "-32 -EB -mips2" {pic-and-nonpic-4a.s} |
279 | {} | |
280 | "pic-and-nonpic-4a.so"} | |
281 | {"PIC and non-PIC test 4 (executable)" | |
897aea50 | 282 | "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" "" |
861fb55a DJ |
283 | "-32 -EB -mips2" {pic-and-nonpic-4b.s} |
284 | {{readelf --segments pic-and-nonpic-4b.sd} | |
285 | {objdump -dr pic-and-nonpic-4b.dd} | |
286 | {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd} | |
287 | {readelf --relocs pic-and-nonpic-4b.rd} | |
288 | {readelf --symbols pic-and-nonpic-4b.nd} | |
289 | {readelf -d pic-and-nonpic-4b.ad}} | |
290 | "pic-and-nonpic-4b"} | |
291 | } | |
292 | run_dump_test "pic-and-nonpic-4-error" | |
293 | run_ld_link_tests { | |
294 | {"PIC and non-PIC test 5 (executable)" | |
897aea50 | 295 | "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" "" |
861fb55a DJ |
296 | "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s} |
297 | {{readelf --segments pic-and-nonpic-5b.sd} | |
298 | {objdump -dr pic-and-nonpic-5b.dd} | |
299 | {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd} | |
300 | {readelf -A pic-and-nonpic-5b.gd} | |
301 | {readelf --relocs pic-and-nonpic-5b.rd} | |
302 | {readelf --symbols pic-and-nonpic-5b.nd} | |
303 | {readelf -d pic-and-nonpic-5b.ad}} | |
304 | "pic-and-nonpic-5b"} | |
305 | } | |
306 | set abis { o32 -32 elf32btsmip } | |
307 | if $has_newabi { | |
308 | lappend abis n32 -n32 elf32btsmipn32 | |
309 | lappend abis n64 -64 elf64btsmip | |
310 | } | |
311 | foreach { abi flag emul } $abis { | |
312 | run_ld_link_tests [list \ | |
313 | [list "PIC and non-PIC test 6 ($abi shared library)" \ | |
897aea50 | 314 | "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \ |
861fb55a DJ |
315 | "$flag -EB -mips3" \ |
316 | [list "pic-and-nonpic-6-${abi}a.s"] {} \ | |
317 | "pic-and-nonpic-6-${abi}.so"] \ | |
318 | [list "PIC and non-PIC test 6 ($abi executable)" \ | |
897aea50 | 319 | "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \ |
861fb55a DJ |
320 | "$flag -EB -mips3" \ |
321 | [list "pic-and-nonpic-6-${abi}b.s" \ | |
322 | "pic-and-nonpic-6-${abi}c.s"] \ | |
323 | [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \ | |
324 | "objdump -dr pic-and-nonpic-6-${abi}.dd" \ | |
325 | "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \ | |
326 | "readelf -A pic-and-nonpic-6-${abi}.gd" \ | |
327 | "readelf --relocs pic-and-nonpic-6-${abi}.rd" \ | |
328 | "readelf --symbols pic-and-nonpic-6-${abi}.nd" \ | |
329 | "readelf -d pic-and-nonpic-6-${abi}.ad"] \ | |
330 | "pic-and-nonpic-6-${abi}"]] | |
43b5366b MR |
331 | |
332 | # This checks whether our linker scripts get the scope of _gp right, | |
333 | # and must therefore use default scripts. If they don't, then -- in | |
334 | # addition to dumps failing to match -- the final link fails with: | |
335 | # | |
336 | # ld: gp-hidden.o: undefined reference to symbol '_gp' | |
337 | # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so | |
338 | # so try adding it to the linker command line | |
339 | # | |
340 | set suff64 [string map {o32 "" n32 "" n64 -64} $abi] | |
341 | run_ld_link_tests [list \ | |
342 | [list \ | |
343 | "_gp scope test ($abi shared library)" \ | |
897aea50 | 344 | "$abi_ldflags($abi) -shared" "" \ |
43b5366b MR |
345 | "$abi_asflags($abi) -KPIC" \ |
346 | { gp-hidden-lib.s } \ | |
347 | [list \ | |
348 | "readelf --relocs gp-hidden-lib${suff64}.rd" \ | |
349 | "readelf --syms gp-hidden.sd"] \ | |
350 | "gp-hidden-lib-${abi}.so"] \ | |
351 | [list \ | |
352 | "_gp scope test ($abi versioned library)" \ | |
897aea50 | 353 | "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \ |
43b5366b MR |
354 | "$abi_asflags($abi) -KPIC" \ |
355 | { gp-hidden-ver.s } \ | |
356 | [list \ | |
357 | "readelf --relocs gp-hidden-ver${suff64}.rd" \ | |
358 | "readelf --syms gp-hidden.sd"] \ | |
359 | "gp-hidden-ver-${abi}.so"] \ | |
360 | [list \ | |
361 | "_gp scope test ($abi executable)" \ | |
897aea50 | 362 | "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \ |
43b5366b MR |
363 | "$abi_asflags($abi) -call_nonpic" \ |
364 | { gp-hidden.s } \ | |
365 | [list \ | |
366 | "readelf --relocs gp-hidden${suff64}.rd" \ | |
367 | "readelf --syms gp-hidden.sd"] \ | |
368 | "gp-hidden-${abi}"]] | |
861fb55a | 369 | } |
fbf18a5c | 370 | } |
a657e7c1 | 371 | |
fbf18a5c | 372 | if { $embedded_elf } { |
fbf18a5c | 373 | run_dump_test "region1" |
a657e7c1 | 374 | } |
18ab1921 RS |
375 | |
376 | if $embedded_elf { | |
377 | # This could work on other targets too, but would need the appropriate | |
378 | # ld -m switch. | |
379 | run_dump_test "reloc-1-rel" | |
380 | } | |
381 | if $has_newabi { | |
ef2b5578 MR |
382 | run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]] |
383 | run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]] | |
18ab1921 RS |
384 | } |
385 | run_dump_test "reloc-2" | |
17a6716a | 386 | run_dump_test "reloc-merge-lo16" |
3b788261 TS |
387 | run_dump_test "reloc-3" |
388 | if {$has_newabi} { | |
389 | run_dump_test "reloc-3-n32" | |
390 | } | |
43ec5bc0 AN |
391 | run_dump_test "reloc-4" |
392 | run_dump_test "reloc-5" | |
77c56f44 | 393 | if { $has_newabi } { |
ef2b5578 MR |
394 | run_ld_link_tests [list \ |
395 | [list \ | |
396 | "reloc test 6a" \ | |
897aea50 | 397 | "-shared $abi_ldflags(n32)" "" \ |
cde00cbb | 398 | "$abi_asflags(n32)" \ |
ef2b5578 MR |
399 | "reloc-6a.s" \ |
400 | {} \ | |
401 | "reloc-6a.so"] \ | |
402 | [list \ | |
403 | "reloc test 6b" \ | |
897aea50 | 404 | "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \ |
cde00cbb | 405 | "$abi_asflags(n32)" \ |
ef2b5578 MR |
406 | "reloc-6b.s" \ |
407 | {} \ | |
408 | "reloc-6b"]] | |
77c56f44 | 409 | } |
43ec5bc0 | 410 | |
353057a5 RS |
411 | if {$has_newabi && $linux_gnu} { |
412 | run_dump_test "eh-frame1-n32" | |
413 | run_dump_test "eh-frame1-n64" | |
dcf507a6 RS |
414 | run_dump_test "eh-frame2-n32" |
415 | run_dump_test "eh-frame2-n64" | |
353057a5 | 416 | } |
8c946ed5 RS |
417 | if {$embedded_elf} { |
418 | run_dump_test "eh-frame3" | |
419 | run_dump_test "eh-frame4" | |
420 | } | |
18e04883 RS |
421 | if {$linux_gnu} { |
422 | set eh_frame5_test { | |
423 | {"MIPS eh-frame 5" | |
897aea50 | 424 | "-melf32btsmip -shared -Teh-frame5.ld" "" |
18e04883 RS |
425 | "-32 -EB" |
426 | {eh-frame5.s} | |
427 | {{readelf {--relocs -wf} eh-frame5.d}} | |
428 | "eh-frame5.so"} | |
429 | } | |
430 | run_ld_link_tests $eh_frame5_test | |
431 | } | |
0efd4160 ILT |
432 | |
433 | run_dump_test "jaloverflow" | |
c314987d | 434 | run_dump_test "jaloverflow-2" |
1f0f3e9b | 435 | if {$has_newabi} { |
ef2b5578 | 436 | run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]] |
1f0f3e9b | 437 | } |
d6f16593 | 438 | |
776167e8 CM |
439 | run_dump_test "mode-change-error-1" |
440 | ||
d6f16593 MR |
441 | run_dump_test "mips16-hilo" |
442 | if {$has_newabi} { | |
443 | run_dump_test "mips16-hilo-n32" | |
444 | } | |
f4e584bd | 445 | |
cc27e1dc | 446 | if { $linux_gnu } { |
250826bd RS |
447 | if { $has_newabi } { |
448 | run_dump_test "textrel-1" | |
449 | } | |
c224138d RS |
450 | run_dump_test "got-page-1" |
451 | if $has_newabi { | |
452 | run_dump_test "got-page-2" | |
08b55522 | 453 | run_dump_test "dyn-sec64" |
c224138d RS |
454 | } |
455 | run_dump_test "got-page-3" | |
13db6b44 RS |
456 | run_ld_link_tests [subst { |
457 | {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld" | |
897aea50 | 458 | "" "$abi_asflags(o32) -mips2" {got-page-4b.s} |
13db6b44 RS |
459 | {{objdump -dr got-page-4a.d} |
460 | {readelf -A got-page-4a.got}} | |
461 | "got-page-4a.so"} | |
462 | {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld" | |
897aea50 | 463 | "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s} |
13db6b44 RS |
464 | {{objdump -dr got-page-4b.d} |
465 | {readelf -A got-page-4b.got}} | |
466 | "got-page-4b.so"} | |
467 | }] | |
468 | if $has_newabi { | |
469 | run_ld_link_tests [subst { | |
470 | {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld" | |
897aea50 | 471 | "" "$abi_asflags(n32)" {got-page-5.s} |
13db6b44 RS |
472 | {{objdump -dr got-page-5.d} |
473 | {readelf -A got-page-5.got}} | |
474 | "got-page-5.so"} | |
475 | {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld" | |
897aea50 | 476 | "" "$abi_asflags(n32)" {got-page-6.s} |
13db6b44 RS |
477 | {{objdump -dr got-page-6.d} |
478 | {readelf -A got-page-6.got}} | |
479 | "got-page-6.so"} | |
480 | {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld" | |
897aea50 | 481 | "" "$abi_asflags(n32)" |
13db6b44 RS |
482 | {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s |
483 | got-page-7e.s} | |
484 | {{objdump -dr got-page-7.d} | |
485 | {readelf -A got-page-7.got}} | |
486 | "got-page-7a.so"} | |
487 | {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld" | |
897aea50 | 488 | "" "$abi_asflags(n32)" |
13db6b44 RS |
489 | {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s |
490 | got-page-7d.s} | |
491 | {{objdump -dr got-page-7.d} | |
492 | {readelf -A got-page-7.got}} | |
493 | "got-page-7b.so"} | |
494 | }] | |
495 | } | |
ccb4c951 RS |
496 | run_dump_test "got-dump-1" |
497 | if $has_newabi { | |
498 | run_dump_test "got-dump-2" | |
499 | } | |
63897e2c | 500 | run_dump_test "reloc-estimate-1" |
cc27e1dc EC |
501 | } |
502 | ||
81d43bff RS |
503 | if $has_newabi { |
504 | run_dump_test "emit-relocs-1" | |
505 | } | |
506 | ||
73934d31 RS |
507 | run_dump_test "hash1a" |
508 | run_dump_test "hash1b" | |
509 | run_dump_test "hash1c" | |
510 | ||
5108fc1b RS |
511 | if {[istarget mips*-*-linux*]} { |
512 | # The number of symbols that are always included in the symbol table | |
74541ad4 | 513 | # for these tests. The 4 are: |
5108fc1b RS |
514 | # |
515 | # the null symbol entry | |
516 | # the .MIPS.stubs section symbol | |
5108fc1b | 517 | # _GLOBAL_OFFSET_TABLE_ |
889acb80 | 518 | set base_syms 3 |
5108fc1b RS |
519 | foreach dynsym { 7fff 8000 fff0 10000 2fe80 } { |
520 | run_ld_link_tests \ | |
521 | [list [list \ | |
522 | "Stub for dynsym 0x$dynsym" \ | |
897aea50 | 523 | "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \ |
5108fc1b RS |
524 | [concat \ |
525 | "-EB -march=mips1 -32 -KPIC" \ | |
526 | "--defsym base_syms=$base_syms" \ | |
527 | "--defsym dynsym=0x$dynsym"] \ | |
528 | [list "stub-dynsym-1.s"] \ | |
529 | [list [list \ | |
530 | "objdump" "-dz" \ | |
531 | "stub-dynsym-1-$dynsym.d"]] \ | |
532 | "stub-dynsym-1-$dynsym"]] | |
533 | } | |
534 | } | |
535 | ||
f4e584bd DJ |
536 | # For tests which may involve multiple files, use run_ld_link_tests. |
537 | ||
538 | # List contains test-items with 3 items followed by 2 lists: | |
897aea50 MR |
539 | # 0:name 1:ld early options 2:ld late options 3:assembler options |
540 | # 4:filenames of assembler files 5: action and options. 6: name of output file | |
f4e584bd DJ |
541 | |
542 | # Actions: | |
543 | # objdump: Apply objdump options on result. Compare with regex (last arg). | |
544 | # nm: Apply nm options on result. Compare with regex (last arg). | |
545 | # readelf: Apply readelf options on result. Compare with regex (last arg). | |
546 | ||
547 | set mips_tls_tests { | |
897aea50 | 548 | {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" "" |
f4e584bd DJ |
549 | "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s} |
550 | {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}} | |
551 | "tls-static-o32"} | |
897aea50 | 552 | {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" "" |
f4e584bd DJ |
553 | "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s} |
554 | {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}} | |
555 | "tlslib-o32.so"} | |
556 | {"Dynamic executable with TLS" | |
897aea50 | 557 | "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" "" |
f4e584bd DJ |
558 | "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s} |
559 | {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}} | |
560 | "tls-dynamic-o32"} | |
561 | {"Shared library with multiple GOTs and TLS" | |
897aea50 | 562 | "-shared -melf32btsmip -T mips-lib.ld" "" |
f4e584bd DJ |
563 | "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s} |
564 | {{readelf {-d -r} tls-multi-got-1.r} | |
565 | {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d} | |
566 | {objdump -Rsj.got tls-multi-got-1.got}} | |
567 | "tlslib-multi.so"} | |
568 | {"Shared library with TLS and versioning" | |
897aea50 | 569 | "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" "" |
f4e584bd DJ |
570 | "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s} |
571 | {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}} | |
572 | "tlslib-o32-ver.so"} | |
573 | {"Dynamic executable with TLS and versioning" | |
897aea50 | 574 | "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" "" |
f4e584bd DJ |
575 | "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s} |
576 | {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}} | |
577 | "tls-dynamic-o32-ver"} | |
578 | {"Dynamic executable with TLS and versioning (order 2)" | |
897aea50 | 579 | "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" "" |
f4e584bd DJ |
580 | "-EB -march=mips1 -32 -KPIC" {} |
581 | {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}} | |
582 | "tls-dynamic-o32-ver-2"} | |
583 | {"Dynamic executable with TLS and versioning (order 3)" | |
897aea50 | 584 | "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" "" |
f4e584bd DJ |
585 | "-EB -march=mips1 -32 -KPIC" {} |
586 | {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}} | |
587 | "tls-dynamic-o32-ver-3"} | |
588 | {"Shared library with TLS and hidden symbols" | |
897aea50 | 589 | "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" "" |
f4e584bd DJ |
590 | "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s} |
591 | {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}} | |
592 | "tlslib-o32-hidden.so"} | |
4005427f | 593 | {"Shared library with TLS and hidden symbols (2)" |
897aea50 | 594 | "-shared -melf32btsmip -T mips-lib.ld" "" |
4005427f RS |
595 | "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s} |
596 | {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}} | |
597 | "tls-hidden2.so"} | |
ead49a57 | 598 | {"Shared library with TLS and hidden symbols (3)" |
897aea50 | 599 | "-shared -melf32btsmip -T tls-hidden3.ld" "" |
ead49a57 RS |
600 | "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s} |
601 | {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got} | |
602 | {readelf --relocs tls-hidden3.r}} | |
603 | "tls-hidden3.so"} | |
604 | {"Shared library with TLS and hidden symbols (4)" | |
897aea50 | 605 | "-shared -melf32btsmip -T tls-hidden3.ld" "" |
ead49a57 RS |
606 | "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s} |
607 | {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}} | |
608 | "tls-hidden4.so"} | |
f4e584bd DJ |
609 | } |
610 | ||
611 | if {[istarget mips*-*-linux*]} { | |
612 | run_ld_link_tests $mips_tls_tests | |
613 | } | |
614 | ||
08e8dfaf RS |
615 | set mips16_call_global_test [list \ |
616 | [list "Global calls from mips16" \ | |
897aea50 | 617 | "$abi_ldflags(o32) -T no-shared-1.ld" "" \ |
ef2b5578 | 618 | "$abi_asflags(o32) -mips32r2" \ |
08e8dfaf RS |
619 | {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \ |
620 | {{objdump -dr mips16-call-global.d}} \ | |
621 | "mips16-call-global"]] | |
35d3d567 TS |
622 | |
623 | run_ld_link_tests $mips16_call_global_test | |
b9d58d71 | 624 | |
08e8dfaf RS |
625 | set mips16_intermix_test [list \ |
626 | [list "Intermixing mips32 and mips16 functions" \ | |
897aea50 | 627 | "$abi_ldflags(o32)" "" \ |
ef2b5578 | 628 | "$abi_asflags(o32) -mips32r2" \ |
08e8dfaf RS |
629 | {mips16-intermix-1.s mips16-intermix-2.s} \ |
630 | {{objdump -t mips16-intermix.d}} \ | |
631 | "mips16-intermix"]] | |
b9d58d71 TS |
632 | |
633 | run_ld_link_tests $mips16_intermix_test | |
b314ec0e RS |
634 | |
635 | run_dump_test "mips16-local-stubs-1" | |
2cf19d5c JM |
636 | |
637 | run_dump_test "attr-gnu-4-00" | |
638 | run_dump_test "attr-gnu-4-01" | |
639 | run_dump_test "attr-gnu-4-02" | |
640 | run_dump_test "attr-gnu-4-03" | |
42554f6a TS |
641 | run_dump_test "attr-gnu-4-04" |
642 | run_dump_test "attr-gnu-4-05" | |
2cf19d5c JM |
643 | run_dump_test "attr-gnu-4-10" |
644 | run_dump_test "attr-gnu-4-11" | |
645 | run_dump_test "attr-gnu-4-12" | |
646 | run_dump_test "attr-gnu-4-13" | |
647 | run_dump_test "attr-gnu-4-14" | |
42554f6a | 648 | run_dump_test "attr-gnu-4-15" |
2cf19d5c JM |
649 | run_dump_test "attr-gnu-4-20" |
650 | run_dump_test "attr-gnu-4-21" | |
651 | run_dump_test "attr-gnu-4-22" | |
652 | run_dump_test "attr-gnu-4-23" | |
42554f6a TS |
653 | run_dump_test "attr-gnu-4-24" |
654 | run_dump_test "attr-gnu-4-25" | |
2cf19d5c JM |
655 | run_dump_test "attr-gnu-4-30" |
656 | run_dump_test "attr-gnu-4-31" | |
657 | run_dump_test "attr-gnu-4-32" | |
658 | run_dump_test "attr-gnu-4-33" | |
42554f6a TS |
659 | run_dump_test "attr-gnu-4-34" |
660 | run_dump_test "attr-gnu-4-35" | |
661 | run_dump_test "attr-gnu-4-40" | |
2cf19d5c | 662 | run_dump_test "attr-gnu-4-41" |
42554f6a TS |
663 | run_dump_test "attr-gnu-4-42" |
664 | run_dump_test "attr-gnu-4-43" | |
665 | run_dump_test "attr-gnu-4-44" | |
666 | run_dump_test "attr-gnu-4-45" | |
667 | run_dump_test "attr-gnu-4-51" | |
634835ae RS |
668 | |
669 | if { $linux_gnu } { | |
670 | run_ld_link_tests { | |
671 | {"GOT and versioning 1" | |
897aea50 | 672 | "-shared -melf32btsmip --version-script got-vers-1.ver" "" |
634835ae RS |
673 | "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s} |
674 | {{readelf -d got-vers-1.dd} | |
675 | {readelf --symbols got-vers-1.sd} | |
676 | {readelf --relocs got-vers-1.rd}} | |
677 | "got-vers-1.so"} | |
678 | } | |
679 | } | |
e7e2196d MR |
680 | |
681 | run_dump_test "undefined" | |
1063d8cf CF |
682 | |
683 | # Test the conversion from jr to b | |
684 | if { $linux_gnu } { | |
685 | run_dump_test "jr-to-b-1" | |
686 | run_dump_test "jr-to-b-2" | |
687 | } | |
df58fc94 RS |
688 | |
689 | # MIPS16 and microMIPS interlinking test. | |
690 | run_dump_test "mips16-and-micromips" | |
9b11fa1a MR |
691 | |
692 | # Export class call relocation tests. | |
693 | set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]] | |
694 | foreach { abi } $abis { | |
695 | set loadaddr [string map \ | |
696 | {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi] | |
697 | set suff [subst \ | |
698 | [expr { [istarget *-*-irix*] \ | |
699 | ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \ | |
700 | : $abi }]] | |
701 | run_ld_link_tests [list \ | |
702 | [list \ | |
703 | "MIPS export class call relocation test ($abi)" \ | |
897aea50 | 704 | "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \ |
9b11fa1a MR |
705 | "$abi_asflags($abi) -mips3 -KPIC" \ |
706 | [list export-class-call16-${abi}.s export-class-call16-def.s] \ | |
707 | [list \ | |
708 | "objdump -d export-class-call16-${suff}.dd" \ | |
709 | "readelf -A export-class-call16-${abi}.gd"] \ | |
710 | "export-class-call16-${abi}.so"]] | |
711 | } | |
cde7cb01 MR |
712 | |
713 | # Magic __ehdr_start symbol tests. | |
714 | set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]] | |
715 | foreach { abi } $abis { | |
716 | set suff [string map {o32 o32 n32 new n64 new} $abi] | |
717 | run_ld_link_tests [list \ | |
718 | [list \ | |
719 | "MIPS magic __ehdr_start symbol test 1 ($abi)" \ | |
720 | "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \ | |
721 | "$abi_asflags($abi)" \ | |
722 | [list ehdr_start-${suff}.s] \ | |
723 | [list "readelf -s ehdr_start-1.nd"] \ | |
724 | "ehdr_start-1-${abi}"]] | |
725 | if [regexp "(?:n32|n64)" "$abi"] { | |
726 | setup_kfail "mips*-*-*" "ld/15428" | |
727 | } | |
728 | run_ld_link_tests [list \ | |
729 | [list \ | |
730 | "MIPS magic __ehdr_start symbol test 2 ($abi)" \ | |
731 | "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \ | |
732 | "$abi_asflags($abi)" \ | |
733 | [list ehdr_start-${suff}.s] \ | |
734 | [list "readelf -s ehdr_start-2.nd"] \ | |
735 | "ehdr_start-2-${abi}"]] | |
736 | } | |
d6101ac2 MR |
737 | |
738 | # R_MIPS_JALR reloc tests. | |
739 | set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]] | |
740 | foreach { abi } $abis { | |
741 | run_ld_link_tests [list \ | |
742 | [list \ | |
743 | "MIPS JALR reloc test ($abi)" \ | |
744 | "$abi_ldflags($abi) -T jalr3.ld" "" \ | |
745 | "$abi_asflags($abi)" \ | |
746 | [list ../../../gas/testsuite/gas/mips/jalr3.s] \ | |
747 | [list "objdump -d jalr3.dd"] \ | |
748 | "jalr3-${abi}"]] | |
749 | } |