]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-mips-elf/mips-elf.exp
MIPS16e2: Add new MIPS16e2 relaxation GAS and LD tests
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
1 # Expect script for MIPS ELF linker tests
2 # Copyright (C) 2002-2017 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 if {[istarget "mips*-*-vxworks"]} {
23 set mipsvxtests {
24 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" ""
25 "-mips2" {vxworks1-lib.s}
26 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
27 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
28 "libvxworks1.so"}
29 {"VxWorks executable test 1 (dynamic)" \
30 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" ""
31 "-mips2" {vxworks1.s}
32 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
33 "vxworks1"}
34 {"VxWorks executable test 2 (dynamic)" \
35 "-Tvxworks1.ld -q --force-dynamic" ""
36 "-mips2" {vxworks2.s}
37 {{readelf --segments vxworks2.sd}}
38 "vxworks2"}
39 {"VxWorks executable test 2 (static)"
40 "-Tvxworks1.ld" ""
41 "-mips2" {vxworks2.s}
42 {{readelf --segments vxworks2-static.sd}}
43 "vxworks2"}
44 }
45 run_ld_link_tests $mipsvxtests
46 run_dump_test "vxworks1-static"
47 run_dump_test "vxworks-forced-local-1"
48 return
49 }
50
51 if {![istarget mips*-*-*] || ![is_elf_format]} {
52 return
53 }
54
55 set has_newabi [expr [istarget *-*-irix6*] \
56 || [istarget mips*-*-linux*] \
57 || [istarget mips*-sde-elf*] \
58 || [istarget mips*-mti-elf*] \
59 || [istarget mips*-img-elf*]]
60 set linux_gnu [expr [istarget mips*-*-linux*]]
61 set embedded_elf [expr [istarget mips*-*-elf]]
62
63 # Set defaults.
64 set abi_asflags(o32) "-32"
65 set abi_asflags(n32) "-march=from-abi -n32 -EB"
66 set abi_asflags(n64) "-march=from-abi -64 -EB"
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 }
82 if { [istarget mips*-*-linux*] || [istarget mips*-sde-elf*]
83 || [istarget mips*-mti-elf*] || [istarget mips*-img-elf*]} {
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
91 if { $linux_gnu } {
92 run_ld_link_tests [list \
93 [list "Dummy shared library for MIPS16 PIC test 1" \
94 "-shared -melf32btsmip" "" \
95 "-EB -32 -mips1" \
96 { mips16-pic-1-dummy.s } \
97 {} \
98 "mips16-pic-1-dummy.so"] \
99 [list "MIPS16 PIC test 1" \
100 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
101 "-EB -32 -mips1 -I $srcdir/$subdir" \
102 { mips16-pic-1a.s mips16-pic-1b.s } \
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" \
107 "-melf32btsmip -T mips16-pic-1.ld -shared" "" \
108 "-EB -32 -mips1 -I $srcdir/$subdir" \
109 { mips16-pic-2a.s mips16-pic-2b.s } \
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 } } \
115 "mips16-pic-2"] \
116 [list "MIPS16 PIC test 3" \
117 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" "" \
118 "-EB -32 -mips1 -I $srcdir/$subdir" \
119 { mips16-pic-3a.s mips16-pic-3b.s } \
120 { { objdump -dr mips16-pic-3.dd } \
121 { readelf --relocs mips16-pic-3.rd } \
122 { readelf -A mips16-pic-3.gd } } \
123 "mips16-pic-3"] \
124 [list "MIPS16 PIC test 4 (shared library)" \
125 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" "" \
126 "-EB -32 -mips1" \
127 { mips16-pic-4a.s mips16-pic-4b.s } \
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)" \
133 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" "" \
134 "-EB -32 -mips1" \
135 { mips16-pic-4c.s } \
136 { { objdump -dr mips16-pic-4b.dd } } \
137 "mips16-pic-4"]]
138 }
139
140 # Check MIPS16 markings being passed through link.
141 run_dump_test "mips16-1"
142
143 # MIPS branch offset final link checking.
144 run_dump_test "branch-misc-1"
145 run_dump_test "branch-misc-2"
146 run_dump_test "branch-absolute" [list [list ld $abi_ldflags(o32)]]
147 run_dump_test "branch-absolute-addend" [list [list ld $abi_ldflags(o32)]]
148 if $has_newabi {
149 run_dump_test "branch-absolute-n32" [list [list ld $abi_ldflags(n32)]]
150 run_dump_test "branch-absolute-addend-n32" \
151 [list [list ld $abi_ldflags(n32)]]
152 run_dump_test "branch-absolute-n64" [list [list ld $abi_ldflags(n64)]]
153 run_dump_test "branch-absolute-addend-n64" \
154 [list [list ld $abi_ldflags(n64)]]
155 }
156
157 run_dump_test "mips16-pcrel-0" [list [list ld $abi_ldflags(o32)]]
158 run_dump_test "mips16-pcrel-1" [list [list ld $abi_ldflags(o32)]]
159 run_dump_test "mips16e2-pcrel-0" [list [list ld $abi_ldflags(o32)]]
160 run_dump_test "mips16e2-pcrel-1" [list [list ld $abi_ldflags(o32)]]
161 run_dump_test "mips16-pcrel-addend-2" [list [list ld $abi_ldflags(o32)]]
162 run_dump_test "mips16-pcrel-addend-6" [list [list ld $abi_ldflags(o32)]]
163 run_dump_test "mips16e2-pcrel-addend-2" [list [list ld $abi_ldflags(o32)]]
164 run_dump_test "mips16e2-pcrel-addend-6" [list [list ld $abi_ldflags(o32)]]
165 if $has_newabi {
166 run_dump_test "mips16-pcrel-n32-0" [list [list ld $abi_ldflags(n32)]]
167 run_dump_test "mips16-pcrel-n32-1" [list [list ld $abi_ldflags(n32)]]
168 run_dump_test "mips16-pcrel-n64-sym32-0" [list [list ld $abi_ldflags(n64)]]
169 run_dump_test "mips16-pcrel-n64-sym32-1" [list [list ld $abi_ldflags(n64)]]
170 run_dump_test "mips16e2-pcrel-n32-0" [list [list ld $abi_ldflags(n32)]]
171 run_dump_test "mips16e2-pcrel-n32-1" [list [list ld $abi_ldflags(n32)]]
172 run_dump_test "mips16e2-pcrel-n64-sym32-0" \
173 [list [list ld $abi_ldflags(n64)]]
174 run_dump_test "mips16e2-pcrel-n64-sym32-1" \
175 [list [list ld $abi_ldflags(n64)]]
176 }
177
178 run_dump_test "mips16-branch-2" [list [list ld $abi_ldflags(o32)]]
179 run_dump_test "mips16-branch-3" [list [list ld $abi_ldflags(o32)]]
180 run_dump_test "mips16-branch-addend-2" [list [list ld $abi_ldflags(o32)]]
181 run_dump_test "mips16-branch-addend-3" [list [list ld $abi_ldflags(o32)]]
182 run_dump_test "mips16-branch-absolute" [list [list ld $abi_ldflags(o32)]]
183 run_dump_test "mips16-branch-absolute-1" [list [list ld $abi_ldflags(o32)]]
184 run_dump_test "mips16-branch-absolute-2" [list [list ld $abi_ldflags(o32)]]
185 run_dump_test "mips16-branch-absolute-addend" \
186 [list [list ld $abi_ldflags(o32)]]
187 run_dump_test "mips16-branch-absolute-addend-1" \
188 [list [list ld $abi_ldflags(o32)]]
189 if $has_newabi {
190 run_dump_test "mips16-branch-absolute-n32" \
191 [list [list ld $abi_ldflags(n32)]]
192 run_dump_test "mips16-branch-absolute-n32-1" \
193 [list [list ld $abi_ldflags(n32)]]
194 run_dump_test "mips16-branch-absolute-n32-2" \
195 [list [list ld $abi_ldflags(n32)]]
196 run_dump_test "mips16-branch-absolute-addend-n32" \
197 [list [list ld $abi_ldflags(n32)]]
198 run_dump_test "mips16-branch-absolute-addend-n32-1" \
199 [list [list ld $abi_ldflags(n32)]]
200 run_dump_test "mips16-branch-absolute-n64" \
201 [list [list ld $abi_ldflags(n64)]]
202 run_dump_test "mips16-branch-absolute-n64-1" \
203 [list [list ld $abi_ldflags(n64)]]
204 run_dump_test "mips16-branch-absolute-n64-2" \
205 [list [list ld $abi_ldflags(n64)]]
206 run_dump_test "mips16-branch-absolute-addend-n64" \
207 [list [list ld $abi_ldflags(n64)]]
208 run_dump_test "mips16-branch-absolute-addend-n64-1" \
209 [list [list ld $abi_ldflags(n64)]]
210 }
211
212 run_dump_test "micromips-branch-absolute" [list [list ld $abi_ldflags(o32)]]
213 run_dump_test "micromips-branch-absolute-addend" \
214 [list [list ld $abi_ldflags(o32)]]
215 if $has_newabi {
216 run_dump_test "micromips-branch-absolute-n32" \
217 [list [list ld $abi_ldflags(n32)]]
218 run_dump_test "micromips-branch-absolute-addend-n32" \
219 [list [list ld $abi_ldflags(n32)]]
220 run_dump_test "micromips-branch-absolute-n64" \
221 [list [list ld $abi_ldflags(n64)]]
222 run_dump_test "micromips-branch-absolute-addend-n64" \
223 [list [list ld $abi_ldflags(n64)]]
224 }
225
226 # Jalx test
227 run_dump_test "jalx-1"
228
229 if { $linux_gnu } {
230 run_ld_link_tests [list \
231 [list "Dummy shared library for JALX test 2" \
232 "-shared -nostdlib -melf32btsmip" "" \
233 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -KPIC" \
234 { jalx-2-printf.s } \
235 {} \
236 "libjalx-2.so"] \
237 [list "Dummy external function for JALX test 2" \
238 "-r -melf32btsmip" "" \
239 "-G0 -EB -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
240 { jalx-2-ex.s } \
241 {} \
242 "jalx-2-ex.o.r"] \
243 [list "MIPS JALX test 2" \
244 "-nostdlib -T jalx-2.ld tmpdir/libjalx-2.so tmpdir/jalx-2-ex.o.r -melf32btsmip" "" \
245 "-G0 -EB -mmicromips -no-mdebug -mabi=32 -march=mips32r2 -mno-shared -call_nonpic" \
246 { jalx-2-main.s } \
247 { { objdump -d jalx-2.dd } } \
248 "jalx-2"]]
249 }
250
251 run_dump_test "jalx-addend" [list [list ld $abi_ldflags(o32)]]
252 run_dump_test "jalx-local" [list [list ld $abi_ldflags(o32)]]
253 run_dump_test "bal-jalx-addend" [list [list ld $abi_ldflags(o32)]]
254 run_dump_test "bal-jalx-local" [list [list ld $abi_ldflags(o32)]]
255 run_dump_test "bal-jalx-pic" [list [list ld $abi_ldflags(o32)]]
256 run_dump_test "bal-jalx-pic-ignore" [list [list ld $abi_ldflags(o32)]]
257 if $has_newabi {
258 run_dump_test "jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
259 run_dump_test "jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
260 run_dump_test "bal-jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
261 run_dump_test "bal-jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
262 run_dump_test "bal-jalx-pic-n32" [list [list ld $abi_ldflags(n32)]]
263 run_dump_test "bal-jalx-pic-ignore-n32" [list [list ld $abi_ldflags(n32)]]
264 run_dump_test "jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
265 run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
266 run_dump_test "bal-jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
267 run_dump_test "bal-jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
268 run_dump_test "bal-jalx-pic-n64" [list [list ld $abi_ldflags(n64)]]
269 run_dump_test "bal-jalx-pic-ignore-n64" [list [list ld $abi_ldflags(n64)]]
270 }
271
272 run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
273 run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
274 run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
275 run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
276 run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
277 run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
278 run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
279 run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
280
281 if $has_newabi {
282 run_dump_test "unaligned-jalx-addend-0" \
283 [list [list ld $abi_ldflags(n32)]]
284 run_dump_test "unaligned-jalx-addend-1" \
285 [list [list ld $abi_ldflags(n32)]]
286 run_dump_test "unaligned-jalx-addend-2" \
287 [list [list ld $abi_ldflags(n32)]]
288 run_dump_test "unaligned-jalx-addend-3" \
289 [list [list ld $abi_ldflags(n32)]]
290 run_dump_test "unaligned-jalx-addend-mips16-0" \
291 [list [list ld $abi_ldflags(n32)]]
292 run_dump_test "unaligned-jalx-addend-mips16-1" \
293 [list [list ld $abi_ldflags(n32)]]
294 run_dump_test "unaligned-jalx-addend-micromips-0" \
295 [list [list ld $abi_ldflags(n32)]]
296 run_dump_test "unaligned-jalx-addend-micromips-1" \
297 [list [list ld $abi_ldflags(n32)]]
298 }
299
300 run_dump_test "unaligned-branch" [list [list ld $abi_ldflags(o32)]]
301
302 if $has_newabi {
303 run_dump_test "unaligned-branch-2" \
304 [list [list ld $abi_ldflags(n32)]]
305 run_dump_test "unaligned-branch-ignore-2" \
306 [list [list ld $abi_ldflags(n32)]]
307 run_dump_test "unaligned-branch-r6-1" \
308 [list [list ld $abi_ldflags(n32)]]
309 run_dump_test "unaligned-branch-ignore-r6-1" \
310 [list [list ld $abi_ldflags(n32)]]
311 run_dump_test "unaligned-branch-r6-2" \
312 [list [list ld $abi_ldflags(n32)]]
313 run_dump_test "unaligned-branch-mips16" \
314 [list [list ld $abi_ldflags(n32)]]
315 run_dump_test "unaligned-branch-ignore-mips16" \
316 [list [list ld $abi_ldflags(n32)]]
317 run_dump_test "unaligned-branch-micromips" \
318 [list [list ld $abi_ldflags(n32)]]
319 run_dump_test "unaligned-branch-ignore-micromips" \
320 [list [list ld $abi_ldflags(n32)]]
321 run_dump_test "unaligned-jump" \
322 [list [list ld $abi_ldflags(n32)]]
323 run_dump_test "unaligned-jump-mips16" \
324 [list [list ld $abi_ldflags(n32)]]
325 run_dump_test "unaligned-jump-micromips" \
326 [list [list ld $abi_ldflags(n32)]]
327 }
328
329 run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]]
330 run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]]
331 run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]]
332 run_dump_test "unaligned-ldpc-1" [list [list ld $abi_ldflags(o32)]]
333
334 # Test multi-got link. We only do this on GNU/Linux because it requires
335 # the "traditional" emulations.
336 if { $linux_gnu } {
337 run_dump_test "multi-got-1"
338 run_dump_test "multi-got-no-shared"
339 run_dump_test "multi-got-hidden-1"
340 run_dump_test "multi-got-hidden-2"
341 }
342
343 # Test __gnu_local_gp accesses
344 if { $linux_gnu } {
345 run_dump_test "no-shared-1-o32"
346 if { $has_newabi } {
347 run_dump_test "no-shared-1-n32"
348 run_dump_test "no-shared-1-n64"
349 }
350 }
351
352 # Test PIE debug dynamic tags
353 if { $linux_gnu } {
354 run_dump_test "pie-o32"
355 if { $has_newabi } {
356 run_dump_test "pie-n32"
357 run_dump_test "pie-n64"
358 }
359 }
360
361 if $has_newabi {
362 if { $embedded_elf } {
363 run_dump_test "elf-rel-got-n32-embed" \
364 [list [list ld $abi_ldflags(n32)]]
365 run_dump_test "elf-rel-xgot-n32-embed" \
366 [list [list ld $abi_ldflags(n32)]]
367 } else {
368 run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]]
369 run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]]
370 }
371 if { $linux_gnu } {
372 run_dump_test "elf-rel-got-n64-linux" \
373 [list [list ld $abi_ldflags(n64)]]
374 run_dump_test "elf-rel-xgot-n64-linux" \
375 [list [list ld $abi_ldflags(n64)]]
376 } elseif { $embedded_elf } {
377 run_dump_test "elf-rel-got-n64-embed" \
378 [list [list ld $abi_ldflags(n64)]]
379 run_dump_test "elf-rel-xgot-n64-embed" \
380 [list [list ld $abi_ldflags(n64)]]
381 } else {
382 run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]]
383 run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]]
384 }
385
386 run_dump_test "relax-jalr-n32"
387 run_dump_test "relax-jalr-n32-shared"
388 run_dump_test "relax-jalr-n64"
389 run_dump_test "relax-jalr-n64-shared"
390 }
391
392 if { $linux_gnu } {
393 run_dump_test "rel32-o32"
394 if { $has_newabi } {
395 run_dump_test "rel32-n32"
396 run_dump_test "rel64"
397 }
398 # The first test checks that a mixed PIC/non-PIC relocatable link
399 # will not introduce any stubs itself, but will flag PIC functions
400 # for the final link.
401 #
402 # The second test checks that we insert stubs for calls from
403 # non-PIC functions to PIC functions when linking the original
404 # two objects together.
405 #
406 # The third test checks that we do the same when linking the
407 # result of the first link (with no other source files).
408 #
409 # We then repeat the same three tests for microMIPS stubs.
410 run_ld_link_tests {
411 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
412 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
413 {{objdump -dr pic-and-nonpic-1-rel.dd}
414 {readelf --symbols pic-and-nonpic-1-rel.nd}}
415 "pic-and-nonpic-1-rel.o"}
416 {"PIC and non-PIC test 1 (static 1)"
417 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
418 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
419 {{objdump -dr pic-and-nonpic-1.dd}
420 {readelf --symbols pic-and-nonpic-1.nd}}
421 "pic-and-nonpic-1-static1.o"}
422 {"PIC and non-PIC test 1 (static 2)"
423 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
424 "" {}
425 {{objdump -dr pic-and-nonpic-1.dd}
426 {readelf --symbols pic-and-nonpic-1.nd}}
427 "pic-and-nonpic-1-static2.o"}
428 {"PIC and non-PIC test 1, microMIPS (relocatable)"
429 "-r -melf32btsmip" ""
430 "-32 -EB -mips2"
431 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
432 {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
433 {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
434 "pic-and-nonpic-1-micromips-rel.o"}
435 {"PIC and non-PIC test 1, microMIPS (static 1)"
436 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
437 "-32 -EB -mips2"
438 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
439 {{objdump -dr pic-and-nonpic-1-micromips.dd}
440 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
441 "pic-and-nonpic-1-micromips-static1.o"}
442 }
443 # The final executable produced with the following test is supposed
444 # to be the same as one produced with the preceding test, however
445 # as noted in PR ld/20453 it is not. Consequently output from
446 # `objdump -dr' is not the same either. Expect:
447 #
448 # regexp_diff match failure
449 # regexp "^ 4103c: f001 0415 jalx 41054 <f3>$"
450 # line " 4103c: f001 0400 jalx 41000 <.pic.f3>"
451 #
452 # from the test below due to this problem.
453 setup_kfail "mips*-*-*" "ld/20453"
454 # The final check below should be folded into the `run_ld_link_tests'
455 # call above once `setup_kfail' has been removed.
456 run_ld_link_tests {
457 {"PIC and non-PIC test 1, microMIPS (static 2)"
458 "-melf32btsmip -Tpic-and-nonpic-1.ld \
459 tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
460 "" {}
461 {{objdump -dr pic-and-nonpic-1-micromips.dd}
462 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
463 "pic-and-nonpic-1-micromips-static2.o"}
464 }
465 run_dump_test "pic-and-nonpic-2"
466 run_ld_link_tests {
467 {"PIC and non-PIC test 3 (shared library)"
468 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
469 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
470 {{readelf --segments pic-and-nonpic-3a.sd}
471 {readelf -A pic-and-nonpic-3a.gd}
472 {objdump -dr pic-and-nonpic-3a.dd}}
473 "pic-and-nonpic-3a.so"}
474 {"PIC and non-PIC test 3 (executable)"
475 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
476 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
477 {{readelf --segments pic-and-nonpic-3b.sd}
478 {objdump -dr pic-and-nonpic-3b.dd}
479 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
480 {readelf -A pic-and-nonpic-3b.gd}
481 {readelf --relocs pic-and-nonpic-3b.rd}
482 {readelf --symbols pic-and-nonpic-3b.nd}
483 {readelf -d pic-and-nonpic-3b.ad}}
484 "pic-and-nonpic-3b"}
485 }
486 run_dump_test "pic-and-nonpic-3-error"
487 run_ld_link_tests {
488 {"PIC and non-PIC test 4 (shared library)"
489 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
490 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
491 {}
492 "pic-and-nonpic-4a.so"}
493 {"PIC and non-PIC test 4 (executable)"
494 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
495 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
496 {{readelf --segments pic-and-nonpic-4b.sd}
497 {objdump -dr pic-and-nonpic-4b.dd}
498 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
499 {readelf --relocs pic-and-nonpic-4b.rd}
500 {readelf --symbols pic-and-nonpic-4b.nd}
501 {readelf -d pic-and-nonpic-4b.ad}}
502 "pic-and-nonpic-4b"}
503 }
504 run_dump_test "pic-and-nonpic-4-error"
505 run_ld_link_tests {
506 {"PIC and non-PIC test 5 (executable)"
507 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
508 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
509 {{readelf --segments pic-and-nonpic-5b.sd}
510 {objdump -dr pic-and-nonpic-5b.dd}
511 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
512 {readelf -A pic-and-nonpic-5b.gd}
513 {readelf --relocs pic-and-nonpic-5b.rd}
514 {readelf --symbols pic-and-nonpic-5b.nd}
515 {readelf -d pic-and-nonpic-5b.ad}}
516 "pic-and-nonpic-5b"}
517 }
518 set abis { o32 -32 elf32btsmip }
519 if $has_newabi {
520 lappend abis n32 -n32 elf32btsmipn32
521 lappend abis n64 -64 elf64btsmip
522 }
523 foreach { abi flag emul } $abis {
524 run_ld_link_tests [list \
525 [list "PIC and non-PIC test 6 ($abi shared library)" \
526 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
527 "$flag -EB -mips3" \
528 [list "pic-and-nonpic-6-${abi}a.s"] {} \
529 "pic-and-nonpic-6-${abi}.so"] \
530 [list "PIC and non-PIC test 6 ($abi executable)" \
531 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
532 "$flag -EB -mips3" \
533 [list "pic-and-nonpic-6-${abi}b.s" \
534 "pic-and-nonpic-6-${abi}c.s"] \
535 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
536 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
537 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
538 "readelf -A pic-and-nonpic-6-${abi}.gd" \
539 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
540 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
541 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
542 "pic-and-nonpic-6-${abi}"]]
543
544 # This checks whether our linker scripts get the scope of _gp right,
545 # and must therefore use default scripts. If they don't, then -- in
546 # addition to dumps failing to match -- the final link fails with:
547 #
548 # ld: gp-hidden.o: undefined reference to symbol '_gp'
549 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
550 # so try adding it to the linker command line
551 #
552 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
553 run_ld_link_tests [list \
554 [list \
555 "_gp scope test ($abi shared library)" \
556 "$abi_ldflags($abi) -shared" "" \
557 "$abi_asflags($abi) -KPIC" \
558 { gp-hidden-lib.s } \
559 [list \
560 "readelf --relocs gp-hidden-lib${suff64}.rd" \
561 "readelf --syms gp-hidden.sd"] \
562 "gp-hidden-lib-${abi}.so"] \
563 [list \
564 "_gp scope test ($abi versioned library)" \
565 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
566 "$abi_asflags($abi) -KPIC" \
567 { gp-hidden-ver.s } \
568 [list \
569 "readelf --relocs gp-hidden-ver${suff64}.rd" \
570 "readelf --syms gp-hidden.sd"] \
571 "gp-hidden-ver-${abi}.so"] \
572 [list \
573 "_gp scope test ($abi executable)" \
574 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
575 "$abi_asflags($abi) -call_nonpic" \
576 { gp-hidden.s } \
577 [list \
578 "readelf --relocs gp-hidden${suff64}.rd" \
579 "readelf --syms gp-hidden.sd"] \
580 "gp-hidden-${abi}"]]
581 }
582 }
583
584 if { $embedded_elf } {
585 run_dump_test "region1"
586 }
587
588 if $embedded_elf {
589 # This could work on other targets too, but would need the appropriate
590 # ld -m switch.
591 run_dump_test "reloc-1-rel"
592 }
593 if $has_newabi {
594 run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]]
595 run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]]
596 }
597 run_dump_test "reloc-2"
598 run_dump_test "reloc-merge-lo16"
599 run_dump_test "reloc-3"
600 if {$has_newabi} {
601 run_dump_test "reloc-3-n32"
602 }
603 run_dump_test "reloc-4"
604 run_dump_test "reloc-5"
605 if { $has_newabi } {
606 run_ld_link_tests [list \
607 [list \
608 "reloc test 6a" \
609 "-shared $abi_ldflags(n32)" "" \
610 "$abi_asflags(n32)" \
611 "reloc-6a.s" \
612 {} \
613 "reloc-6a.so"] \
614 [list \
615 "reloc test 6b" \
616 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
617 "$abi_asflags(n32)" \
618 "reloc-6b.s" \
619 {} \
620 "reloc-6b"]]
621 }
622
623 run_dump_test "reloc-local-overflow" [list [list ld $abi_ldflags(o32)]]
624 run_ld_link_tests [list \
625 [list \
626 "MIPS link ELF o32 PIC comdat GOT16/LO16 relocation pairing" \
627 "$abi_ldflags(o32) -e bar" "" "$abi_asflags(o32) -mno-pdr" \
628 "../../../gas/testsuite/gas/mips/comdat-reloc.s" \
629 {} \
630 "comdat-reloc"]]
631
632 if {$has_newabi && $linux_gnu} {
633 run_dump_test "eh-frame1-n32"
634 run_dump_test "eh-frame1-n64"
635 run_dump_test "eh-frame2-n32"
636 run_dump_test "eh-frame2-n64"
637 }
638 if {$embedded_elf} {
639 run_dump_test "eh-frame3"
640 run_dump_test "eh-frame4"
641 }
642 if {$linux_gnu} {
643 set eh_frame5_test {
644 {"MIPS eh-frame 5"
645 "-melf32btsmip -shared -Teh-frame5.ld" ""
646 "-32 -EB"
647 {eh-frame5.s}
648 {{readelf {--relocs -wf} eh-frame5.d}}
649 "eh-frame5.so"}
650 }
651 run_ld_link_tests $eh_frame5_test
652 }
653
654 if {$embedded_elf} {
655 run_dump_test "compact-eh1"
656 run_dump_test "compact-eh2"
657 run_dump_test "compact-eh3"
658 }
659
660 if {$linux_gnu} {
661 run_dump_test "compact-eh4"
662 run_dump_test "compact-eh5"
663 run_dump_test "compact-eh6"
664 }
665
666 run_dump_test "jaloverflow"
667 run_dump_test "jaloverflow-2"
668
669 run_dump_test "jal-global-overflow-0" [list [list ld $abi_ldflags(o32)]]
670 run_dump_test "jal-global-overflow-1" [list [list ld $abi_ldflags(o32)]]
671 run_dump_test "jal-local-overflow-0" [list [list ld $abi_ldflags(o32)]]
672 run_dump_test "jal-local-overflow-1" [list [list ld $abi_ldflags(o32)]]
673
674 run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \
675 [list ld $abi_ldflags(o32)]]
676
677 if {$has_newabi} {
678 run_dump_test "undefweak-overflow" [list [list name (n32)] \
679 [list as $abi_asflags(n32)] \
680 [list ld $abi_ldflags(n32)]]
681 run_dump_test "undefweak-overflow" [list [list name (n64)] \
682 [list as $abi_asflags(n64)] \
683 [list ld $abi_ldflags(n64)]]
684 }
685
686 if {$has_newabi} {
687 run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]]
688 }
689
690 run_dump_test "mode-change-error-1"
691
692 run_dump_test "mips16-hilo"
693 if {$has_newabi} {
694 run_dump_test "mips16-hilo-n32"
695 }
696
697 if { $linux_gnu } {
698 if { $has_newabi } {
699 run_dump_test "textrel-1"
700 }
701 run_dump_test "got-page-1"
702 if $has_newabi {
703 run_dump_test "got-page-2"
704 run_dump_test "dyn-sec64"
705 }
706 run_dump_test "got-page-3"
707 run_ld_link_tests [subst {
708 {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
709 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
710 {{objdump -dr got-page-4a.d}
711 {readelf -A got-page-4a.got}}
712 "got-page-4a.so"}
713 {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
714 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
715 {{objdump -dr got-page-4b.d}
716 {readelf -A got-page-4b.got}}
717 "got-page-4b.so"}
718 }]
719 if $has_newabi {
720 run_ld_link_tests [subst {
721 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
722 "" "$abi_asflags(n32)" {got-page-5.s}
723 {{objdump -dr got-page-5.d}
724 {readelf -A got-page-5.got}}
725 "got-page-5.so"}
726 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
727 "" "$abi_asflags(n32)" {got-page-6.s}
728 {{objdump -dr got-page-6.d}
729 {readelf -A got-page-6.got}}
730 "got-page-6.so"}
731 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
732 "" "$abi_asflags(n32)"
733 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
734 got-page-7e.s}
735 {{objdump -dr got-page-7.d}
736 {readelf -A got-page-7.got}}
737 "got-page-7a.so"}
738 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
739 "" "$abi_asflags(n32)"
740 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
741 got-page-7d.s}
742 {{objdump -dr got-page-7.d}
743 {readelf -A got-page-7.got}}
744 "got-page-7b.so"}
745 }]
746 }
747 run_dump_test "got-dump-1"
748 if $has_newabi {
749 run_dump_test "got-dump-2"
750 }
751 run_dump_test "reloc-estimate-1"
752 }
753
754 if $has_newabi {
755 run_dump_test "emit-relocs-1"
756 }
757
758 run_dump_test "hash1a"
759 run_dump_test "hash1b"
760 run_dump_test "hash1c"
761
762 if {[istarget mips*-*-linux*]} {
763 # The number of symbols that are always included in the symbol table
764 # for these tests. The 4 are:
765 #
766 # the null symbol entry
767 # the .MIPS.stubs section symbol
768 set base_syms 2
769 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
770 run_ld_link_tests \
771 [list [list \
772 "Stub for dynsym 0x$dynsym" \
773 "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \
774 [concat \
775 "-EB -march=mips1 -32 -KPIC" \
776 "--defsym base_syms=$base_syms" \
777 "--defsym dynsym=0x$dynsym"] \
778 [list "stub-dynsym-1.s"] \
779 [list [list \
780 "objdump" "-dz" \
781 "stub-dynsym-1-$dynsym.d"]] \
782 "stub-dynsym-1-$dynsym"]]
783 }
784 }
785
786 # For tests which may involve multiple files, use run_ld_link_tests.
787
788 # List contains test-items with 3 items followed by 2 lists:
789 # 0:name 1:ld early options 2:ld late options 3:assembler options
790 # 4:filenames of assembler files 5: action and options. 6: name of output file
791
792 # Actions:
793 # objdump: Apply objdump options on result. Compare with regex (last arg).
794 # nm: Apply nm options on result. Compare with regex (last arg).
795 # readelf: Apply readelf options on result. Compare with regex (last arg).
796
797 set mips_tls_tests {
798 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
799 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
800 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
801 "tls-static-o32"}
802 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
803 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
804 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
805 "tlslib-o32.so"}
806 {"Dynamic executable with TLS"
807 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
808 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
809 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
810 "tls-dynamic-o32"}
811 {"Shared library with multiple GOTs and TLS"
812 "-shared -melf32btsmip -T mips-lib.ld" ""
813 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
814 {{readelf {-d -r} tls-multi-got-1.r}
815 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
816 {objdump -Rsj.got tls-multi-got-1.got}}
817 "tlslib-multi.so"}
818 {"Shared library with TLS and versioning"
819 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
820 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
821 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
822 "tlslib-o32-ver.so"}
823 {"Dynamic executable with TLS and versioning"
824 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
825 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
826 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
827 "tls-dynamic-o32-ver"}
828 {"Dynamic executable with TLS and versioning (order 2)"
829 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
830 "-EB -march=mips1 -32 -KPIC" {}
831 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
832 "tls-dynamic-o32-ver-2"}
833 {"Dynamic executable with TLS and versioning (order 3)"
834 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
835 "-EB -march=mips1 -32 -KPIC" {}
836 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
837 "tls-dynamic-o32-ver-3"}
838 {"Shared library with TLS and hidden symbols"
839 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
840 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
841 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
842 "tlslib-o32-hidden.so"}
843 {"Shared library with TLS and hidden symbols (2)"
844 "-shared -melf32btsmip -T mips-lib.ld" ""
845 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
846 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
847 "tls-hidden2.so"}
848 {"Shared library with TLS and hidden symbols (3)"
849 "-shared -melf32btsmip -T tls-hidden3.ld" ""
850 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
851 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
852 {readelf --relocs tls-hidden3.r}}
853 "tls-hidden3.so"}
854 {"Shared library with TLS and hidden symbols (4)"
855 "-shared -melf32btsmip -T tls-hidden3.ld" ""
856 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
857 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
858 "tls-hidden4.so"}
859 }
860
861 if {[istarget mips*-*-linux*]} {
862 run_ld_link_tests $mips_tls_tests
863 }
864
865 set mips16_call_global_test [list \
866 [list "Global calls from mips16" \
867 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
868 "$abi_asflags(o32) -mips32r2" \
869 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
870 {{objdump -dr mips16-call-global.d}} \
871 "mips16-call-global"]]
872
873 run_ld_link_tests $mips16_call_global_test
874
875 set mips16_intermix_test [list \
876 [list "Intermixing mips32 and mips16 functions" \
877 "$abi_ldflags(o32)" "" \
878 "$abi_asflags(o32) -mips32r2" \
879 {mips16-intermix-1.s mips16-intermix-2.s} \
880 {{objdump -t mips16-intermix.d}} \
881 "mips16-intermix"]]
882
883 run_ld_link_tests $mips16_intermix_test
884
885 run_dump_test "mips16-local-stubs-1"
886
887 set mips16_fp_stub_test [list \
888 [list "Floating-point stub for mips16 functions" \
889 "$abi_ldflags(o32)" "" \
890 "$abi_asflags(o32) -mips32r2" \
891 {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
892 {{readelf --debug-dump=frames mips16-fp-stub.d}} \
893 "mips16-fp-stub"]]
894
895 run_ld_link_tests $mips16_fp_stub_test
896
897 set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
898
899 foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
900 foreach secondfpabi [list 4 5 6 7 ] {
901 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
902 }
903 }
904 foreach firstfpabi [list 4 5 6 7 ] {
905 foreach secondfpabi [list 0 1 2 3 8 9] {
906 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
907 }
908 }
909 foreach firstfpabi [list 0 1 2 3 ] {
910 foreach secondfpabi [list 0 1 2 3 8 9] {
911 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
912 }
913 }
914
915 run_dump_test "attr-gnu-4-81"
916
917 run_dump_test "attr-gnu-8-00"
918 run_dump_test "attr-gnu-8-01"
919 run_dump_test "attr-gnu-8-02"
920 run_dump_test "attr-gnu-8-10"
921 run_dump_test "attr-gnu-8-11"
922 run_dump_test "attr-gnu-8-12"
923 run_dump_test "attr-gnu-8-20"
924 run_dump_test "attr-gnu-8-21"
925 run_dump_test "attr-gnu-8-22"
926
927 run_dump_test "attr-gnu-4-0-ph" $o32flagslist
928 run_dump_test "attr-gnu-4-1-ph" $o32flagslist
929 run_dump_test "attr-gnu-4-2-ph" $o32flagslist
930 run_dump_test "attr-gnu-4-3-ph" $o32flagslist
931 run_dump_test "attr-gnu-4-4-ph" $o32flagslist
932 run_dump_test "attr-gnu-4-5-ph" $o32flagslist
933 run_dump_test "attr-gnu-4-6-ph" $o32flagslist
934 run_dump_test "attr-gnu-4-7-ph" $o32flagslist
935
936 if $has_newabi {
937 run_dump_test "attr-gnu-4-0-n32-ph"
938 run_dump_test "attr-gnu-4-1-n32-ph"
939 run_dump_test "attr-gnu-4-2-n32-ph"
940 run_dump_test "attr-gnu-4-3-n32-ph"
941 run_dump_test "attr-gnu-4-0-n64-ph"
942 run_dump_test "attr-gnu-4-1-n64-ph"
943 run_dump_test "attr-gnu-4-2-n64-ph"
944 run_dump_test "attr-gnu-4-3-n64-ph"
945 }
946
947 run_dump_test "abiflags-strip1-ph" $o32flagslist
948 run_dump_test "abiflags-strip2-ph" $o32flagslist
949 run_dump_test "abiflags-strip3-ph" $o32flagslist
950 run_dump_test "abiflags-strip4-ph" $o32flagslist
951 run_dump_test "abiflags-strip5-ph" $o32flagslist
952 run_dump_test "abiflags-strip6-ph" $o32flagslist
953 run_dump_test "abiflags-strip7-ph" $o32flagslist
954 run_dump_test "abiflags-strip8-ph" $o32flagslist
955 run_dump_test "abiflags-strip9-ph" $o32flagslist
956 run_dump_test "abiflags-strip10-ph" $o32flagslist
957
958 run_dump_test "nan-legacy"
959 run_dump_test "nan-2008"
960 run_dump_test "nan-mixed-1"
961 run_dump_test "nan-mixed-2"
962
963 if { $linux_gnu } {
964 run_ld_link_tests {
965 {"GOT and versioning 1"
966 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
967 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
968 {{readelf -d got-vers-1.dd}
969 {readelf --symbols got-vers-1.sd}
970 {readelf --relocs got-vers-1.rd}}
971 "got-vers-1.so"}
972 }
973 }
974
975 run_dump_test "undefined"
976
977 # Test the conversion from jr to b
978 if { $linux_gnu } {
979 run_dump_test "jr-to-b-1"
980 run_dump_test "jr-to-b-2"
981 }
982
983 # MIPS16 and microMIPS interlinking test.
984 run_dump_test "mips16-and-micromips"
985
986 # Export class call relocation tests.
987 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
988 foreach { abi } $abis {
989 set loadaddr [string map \
990 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
991 set suff [subst \
992 [expr { [istarget *-*-irix*] \
993 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
994 : $abi }]]
995 run_ld_link_tests [list \
996 [list \
997 "MIPS export class call relocation test ($abi)" \
998 "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \
999 "$abi_asflags($abi) -mips3 -KPIC" \
1000 [list export-class-call16-${abi}.s export-class-call16-def.s] \
1001 [list \
1002 "objdump -d export-class-call16-${suff}.dd" \
1003 "readelf -A export-class-call16-${abi}.gd"] \
1004 "export-class-call16-${abi}.so"]]
1005 }
1006
1007 # Magic __ehdr_start symbol tests.
1008 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
1009 foreach { abi } $abis {
1010 set suff [string map {o32 o32 n32 new n64 new} $abi]
1011 run_ld_link_tests [list \
1012 [list \
1013 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
1014 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
1015 "$abi_asflags($abi)" \
1016 [list ehdr_start-${suff}.s] \
1017 [list "readelf -s ehdr_start-1.nd"] \
1018 "ehdr_start-1-${abi}"] \
1019 [list \
1020 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
1021 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
1022 "$abi_asflags($abi)" \
1023 [list ehdr_start-${suff}.s] \
1024 [list "readelf -s ehdr_start-2.nd"] \
1025 "ehdr_start-2-${abi}"]]
1026 }
1027
1028 # R_MIPS_JALR reloc tests.
1029 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
1030 foreach { abi } $abis {
1031 run_ld_link_tests [list \
1032 [list \
1033 "MIPS JALR reloc test ($abi)" \
1034 "$abi_ldflags($abi) -T jalr3.ld" "" \
1035 "$abi_asflags($abi)" \
1036 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
1037 [list "objdump -d jalr3.dd"] \
1038 "jalr3-${abi}"] \
1039 [list \
1040 "MIPS JALR reloc unaligned/cross-mode link test ($abi)" \
1041 "$abi_ldflags($abi) -T jalr3.ld" "" \
1042 "$abi_asflags($abi)" \
1043 [list ../../../gas/testsuite/gas/mips/jalr4.s] \
1044 [list "objdump {-d --prefix-addresses --show-raw-insn} jalr4.dd"] \
1045 "jalr4-${abi}"] \
1046 [list \
1047 "MIPSr6 JALR reloc unaligned/cross-mode link test ($abi)" \
1048 "$abi_ldflags($abi) -T jalr3.ld" "" \
1049 [string map \
1050 [list -32 "-mips32r6 -32" \
1051 -n32 "-mips64r6 -n32" \
1052 -64 "-mips64r6 -64"] \
1053 [regsub -- -march=from-abi $abi_asflags($abi) ""]] \
1054 {../../../gas/testsuite/gas/mips/jalr4.s} \
1055 {{objdump {-d --prefix-addresses --show-raw-insn} jalr4-r6.dd}} \
1056 "jalr4-${abi}"]]
1057 }
1058
1059 proc build_mips_plt_lib { abi } {
1060 global abi_asflags
1061 global abi_ldflags
1062
1063 run_ld_link_tests [list \
1064 [list "Shared $abi library for compressed PLT tests" \
1065 "-shared $abi_ldflags($abi)" "" \
1066 "$abi_asflags($abi)" \
1067 { compressed-plt-1-dyn.s } \
1068 {} \
1069 "compressed-plt-1-${abi}-dyn.so"]]
1070 }
1071
1072 proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
1073 global abi_asflags
1074 global abi_ldflags
1075
1076 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
1077 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
1078 if {[string equal $abi o32]} {
1079 append as_flags " -march=mips2"
1080 }
1081 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
1082 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
1083 set files [list]
1084 if { $filter & 7 } {
1085 lappend files compressed-plt-1a.s
1086 }
1087 if { $filter & 56 } {
1088 lappend files compressed-plt-1b.s
1089 }
1090 if { $filter & 64 } {
1091 lappend files compressed-plt-1c.s
1092 }
1093 eval [list lappend files] $extra
1094 set readelf_flags "-A --syms --relocs -d"
1095 if { [string match "*word*" $suffix] } {
1096 append readelf_flags " -x.data"
1097 }
1098 set objdump_flags "-d -Mgpr-names=numeric"
1099 set basename "compressed-plt-1-${abi}-${suffix}"
1100 run_ld_link_tests [list \
1101 [list "$name" $ld_flags $dynobj \
1102 "$as_flags" $files \
1103 [list [list readelf $readelf_flags ${basename}.rd] \
1104 [list objdump $objdump_flags ${basename}.od]] \
1105 $basename]]
1106 }
1107
1108 if { $linux_gnu } {
1109 build_mips_plt_lib o32
1110 run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
1111 run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
1112 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
1113 run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
1114 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
1115 run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
1116 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
1117 o32 109 0 mips16
1118 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
1119 o32 18 0 mips16-branch
1120 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
1121 o32 109 0 mips16-got compressed-plt-1d.s
1122 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
1123 o32 109 0 mips16-word compressed-plt-1e.s
1124 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
1125 o32 109 1 umips
1126 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
1127 o32 18 1 umips-branch
1128 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
1129 o32 109 1 umips-got compressed-plt-1d.s
1130 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
1131 o32 109 1 umips-word compressed-plt-1e.s
1132
1133 if $has_newabi {
1134 build_mips_plt_lib n32
1135 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
1136 n32 109 0 mips16
1137 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
1138 n32 109 1 umips
1139 }
1140 }
1141
1142 # PR ld/19908 export class tests.
1143 if { $linux_gnu } {
1144 run_ld_link_tests [list \
1145 [list "Shared library for MIPS export class symbol reference tests" \
1146 "$abi_ldflags(o32) -shared" "" \
1147 "$abi_asflags(o32)" \
1148 { export-class-ref-f2.s } \
1149 { { readelf --dyn-syms export-class-ref-lib.sd } } \
1150 "export-class-ref-lib.so"]]
1151 foreach { class flag } { internal 1 hidden 2 protected 3 } {
1152 run_ld_link_tests [list \
1153 [list "MIPS $class symbol reference test 1" \
1154 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1155 "$abi_asflags(o32) --defsym defv=$flag" \
1156 { export-class-ref-f0.s export-class-ref-f1.s } \
1157 [list [list readelf --dyn-syms export-$class-ref.sd] \
1158 [list readelf --dyn-syms export-local-ref.sd]] \
1159 "export-$class-ref"] \
1160 [list "MIPS $class symbol reference test 2" \
1161 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1162 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
1163 { export-class-ref-f0.s export-class-ref-f1.s } \
1164 [list [list readelf --dyn-syms export-$class-ref.sd] \
1165 [list readelf --dyn-syms export-local-ref.sd]] \
1166 "export-$class-ref"]]
1167 }
1168 }
1169
1170 # PR ld/21334 GOT relocation in static binary test.
1171 run_ld_link_tests [list \
1172 [list \
1173 "PR ld/21233 MIPS GOT16 relocation in static binary" \
1174 "$abi_ldflags(o32) -e foo -T pr21334.ld" "" "$abi_asflags(o32)" \
1175 {pr21334.s} \
1176 {{objdump {-d --prefix-addresses} pr21334.dd} \
1177 {readelf -A pr21334.gd}} \
1178 "pr21334"]]