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