Update year range in copyright notice of binutils files
[deliverable/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
1 # Expect script for MIPS ELF linker tests
2 # Copyright (C) 2002-2018 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-addend-micromips" [list [list ld $abi_ldflags(o32)]]
255 run_dump_test "bal-jalx-local" [list [list ld $abi_ldflags(o32)]]
256 run_dump_test "bal-jalx-local-micromips" [list [list ld $abi_ldflags(o32)]]
257 run_dump_test "bal-jalx-pic" [list [list ld $abi_ldflags(o32)]]
258 run_dump_test "bal-jalx-pic-micromips" [list [list ld $abi_ldflags(o32)]]
259 run_dump_test "bal-jalx-pic-ignore" [list [list ld $abi_ldflags(o32)]]
260 run_dump_test "bal-jalx-pic-ignore-micromips" \
261 [list [list ld $abi_ldflags(o32)]]
262 if $has_newabi {
263 run_dump_test "jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
264 run_dump_test "jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
265 run_dump_test "bal-jalx-addend-n32" [list [list ld $abi_ldflags(n32)]]
266 run_dump_test "bal-jalx-addend-micromips-n32" \
267 [list [list ld $abi_ldflags(n32)]]
268 run_dump_test "bal-jalx-local-n32" [list [list ld $abi_ldflags(n32)]]
269 run_dump_test "bal-jalx-local-micromips-n32" \
270 [list [list ld $abi_ldflags(n32)]]
271 run_dump_test "bal-jalx-pic-n32" [list [list ld $abi_ldflags(n32)]]
272 run_dump_test "bal-jalx-pic-micromips-n32" \
273 [list [list ld $abi_ldflags(n32)]]
274 run_dump_test "bal-jalx-pic-ignore-n32" [list [list ld $abi_ldflags(n32)]]
275 run_dump_test "bal-jalx-pic-ignore-micromips-n32" \
276 [list [list ld $abi_ldflags(n32)]]
277 run_dump_test "jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
278 run_dump_test "jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
279 run_dump_test "bal-jalx-addend-n64" [list [list ld $abi_ldflags(n64)]]
280 run_dump_test "bal-jalx-addend-micromips-n64" \
281 [list [list ld $abi_ldflags(n64)]]
282 run_dump_test "bal-jalx-local-n64" [list [list ld $abi_ldflags(n64)]]
283 run_dump_test "bal-jalx-local-micromips-n64" \
284 [list [list ld $abi_ldflags(n64)]]
285 run_dump_test "bal-jalx-pic-n64" [list [list ld $abi_ldflags(n64)]]
286 run_dump_test "bal-jalx-pic-micromips-n64" \
287 [list [list ld $abi_ldflags(n64)]]
288 run_dump_test "bal-jalx-pic-ignore-n64" [list [list ld $abi_ldflags(n64)]]
289 run_dump_test "bal-jalx-pic-ignore-micromips-n64" \
290 [list [list ld $abi_ldflags(n64)]]
291 }
292
293 run_dump_test "unaligned-jalx-0" [list [list ld $abi_ldflags(o32)]]
294 run_dump_test "unaligned-jalx-1" [list [list ld $abi_ldflags(o32)]]
295 run_dump_test "unaligned-jalx-2" [list [list ld $abi_ldflags(o32)]]
296 run_dump_test "unaligned-jalx-3" [list [list ld $abi_ldflags(o32)]]
297 run_dump_test "unaligned-jalx-mips16-0" [list [list ld $abi_ldflags(o32)]]
298 run_dump_test "unaligned-jalx-mips16-1" [list [list ld $abi_ldflags(o32)]]
299 run_dump_test "unaligned-jalx-micromips-0" [list [list ld $abi_ldflags(o32)]]
300 run_dump_test "unaligned-jalx-micromips-1" [list [list ld $abi_ldflags(o32)]]
301
302 if $has_newabi {
303 run_dump_test "unaligned-jalx-addend-0" \
304 [list [list ld $abi_ldflags(n32)]]
305 run_dump_test "unaligned-jalx-addend-1" \
306 [list [list ld $abi_ldflags(n32)]]
307 run_dump_test "unaligned-jalx-addend-2" \
308 [list [list ld $abi_ldflags(n32)]]
309 run_dump_test "unaligned-jalx-addend-3" \
310 [list [list ld $abi_ldflags(n32)]]
311 run_dump_test "unaligned-jalx-addend-mips16-0" \
312 [list [list ld $abi_ldflags(n32)]]
313 run_dump_test "unaligned-jalx-addend-mips16-1" \
314 [list [list ld $abi_ldflags(n32)]]
315 run_dump_test "unaligned-jalx-addend-micromips-0" \
316 [list [list ld $abi_ldflags(n32)]]
317 run_dump_test "unaligned-jalx-addend-micromips-1" \
318 [list [list ld $abi_ldflags(n32)]]
319 }
320
321 run_dump_test "unaligned-branch" [list [list ld $abi_ldflags(o32)]]
322
323 if $has_newabi {
324 run_dump_test "unaligned-branch-2" \
325 [list [list ld $abi_ldflags(n32)]]
326 run_dump_test "unaligned-branch-ignore-2" \
327 [list [list ld $abi_ldflags(n32)]]
328 run_dump_test "unaligned-branch-r6-1" \
329 [list [list ld $abi_ldflags(n32)]]
330 run_dump_test "unaligned-branch-ignore-r6-1" \
331 [list [list ld $abi_ldflags(n32)]]
332 run_dump_test "unaligned-branch-r6-2" \
333 [list [list ld $abi_ldflags(n32)]]
334 run_dump_test "unaligned-branch-mips16" \
335 [list [list ld $abi_ldflags(n32)]]
336 run_dump_test "unaligned-branch-ignore-mips16" \
337 [list [list ld $abi_ldflags(n32)]]
338 run_dump_test "unaligned-branch-micromips" \
339 [list [list ld $abi_ldflags(n32)]]
340 run_dump_test "unaligned-branch-ignore-micromips" \
341 [list [list ld $abi_ldflags(n32)]]
342 run_dump_test "unaligned-jump" \
343 [list [list ld $abi_ldflags(n32)]]
344 run_dump_test "unaligned-jump-mips16" \
345 [list [list ld $abi_ldflags(n32)]]
346 run_dump_test "unaligned-jump-micromips" \
347 [list [list ld $abi_ldflags(n32)]]
348 }
349
350 run_dump_test "unaligned-lwpc-0" [list [list ld $abi_ldflags(o32)]]
351 run_dump_test "unaligned-lwpc-1" [list [list ld $abi_ldflags(o32)]]
352 run_dump_test "unaligned-ldpc-0" [list [list ld $abi_ldflags(o32)]]
353 run_dump_test "unaligned-ldpc-1" [list [list ld $abi_ldflags(o32)]]
354
355 # Test multi-got link. We only do this on GNU/Linux because it requires
356 # the "traditional" emulations.
357 if { $linux_gnu } {
358 run_dump_test "multi-got-1"
359 run_dump_test "multi-got-no-shared"
360 run_dump_test "multi-got-hidden-1"
361 run_dump_test "multi-got-hidden-2"
362 }
363
364 # Test __gnu_local_gp accesses
365 if { $linux_gnu } {
366 run_dump_test "no-shared-1-o32"
367 if { $has_newabi } {
368 run_dump_test "no-shared-1-n32"
369 run_dump_test "no-shared-1-n64"
370 }
371 }
372
373 # Test PIE debug dynamic tags
374 if { $linux_gnu } {
375 run_dump_test "pie-o32"
376 if { $has_newabi } {
377 run_dump_test "pie-n32"
378 run_dump_test "pie-n64"
379 }
380 }
381
382 if $has_newabi {
383 if { $embedded_elf } {
384 run_dump_test "elf-rel-got-n32-embed" \
385 [list [list ld $abi_ldflags(n32)]]
386 run_dump_test "elf-rel-xgot-n32-embed" \
387 [list [list ld $abi_ldflags(n32)]]
388 } else {
389 run_dump_test "elf-rel-got-n32" [list [list ld $abi_ldflags(n32)]]
390 run_dump_test "elf-rel-xgot-n32" [list [list ld $abi_ldflags(n32)]]
391 }
392 if { $linux_gnu } {
393 run_dump_test "elf-rel-got-n64-linux" \
394 [list [list ld $abi_ldflags(n64)]]
395 run_dump_test "elf-rel-xgot-n64-linux" \
396 [list [list ld $abi_ldflags(n64)]]
397 } elseif { $embedded_elf } {
398 run_dump_test "elf-rel-got-n64-embed" \
399 [list [list ld $abi_ldflags(n64)]]
400 run_dump_test "elf-rel-xgot-n64-embed" \
401 [list [list ld $abi_ldflags(n64)]]
402 } else {
403 run_dump_test "elf-rel-got-n64" [list [list ld $abi_ldflags(n64)]]
404 run_dump_test "elf-rel-xgot-n64" [list [list ld $abi_ldflags(n64)]]
405 }
406
407 run_dump_test "relax-jalr-n32"
408 run_dump_test "relax-jalr-n32-shared"
409 run_dump_test "relax-jalr-n64"
410 run_dump_test "relax-jalr-n64-shared"
411 }
412
413 if { $linux_gnu } {
414 run_dump_test "rel32-o32"
415 if { $has_newabi } {
416 run_dump_test "rel32-n32"
417 run_dump_test "rel64"
418 }
419 # The first test checks that a mixed PIC/non-PIC relocatable link
420 # will not introduce any stubs itself, but will flag PIC functions
421 # for the final link.
422 #
423 # The second test checks that we insert stubs for calls from
424 # non-PIC functions to PIC functions when linking the original
425 # two objects together.
426 #
427 # The third test checks that we do the same when linking the
428 # result of the first link (with no other source files).
429 #
430 # We then repeat the same three tests for microMIPS stubs.
431 run_ld_link_tests {
432 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip" ""
433 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
434 {{objdump -dr pic-and-nonpic-1-rel.dd}
435 {readelf --symbols pic-and-nonpic-1-rel.nd}}
436 "pic-and-nonpic-1-rel.o"}
437 {"PIC and non-PIC test 1 (static 1)"
438 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
439 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
440 {{objdump -dr pic-and-nonpic-1.dd}
441 {readelf --symbols pic-and-nonpic-1.nd}}
442 "pic-and-nonpic-1-static1.o"}
443 {"PIC and non-PIC test 1 (static 2)"
444 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o" ""
445 "" {}
446 {{objdump -dr pic-and-nonpic-1.dd}
447 {readelf --symbols pic-and-nonpic-1.nd}}
448 "pic-and-nonpic-1-static2.o"}
449 {"PIC and non-PIC test 1, microMIPS (relocatable)"
450 "-r -melf32btsmip" ""
451 "-32 -EB -mips2"
452 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
453 {{objdump -dr pic-and-nonpic-1-micromips-rel.dd}
454 {readelf --symbols pic-and-nonpic-1-micromips-rel.nd}}
455 "pic-and-nonpic-1-micromips-rel.o"}
456 {"PIC and non-PIC test 1, microMIPS (static 1)"
457 "-melf32btsmip -Tpic-and-nonpic-1.ld" ""
458 "-32 -EB -mips2"
459 {pic-and-nonpic-1a-micromips.s pic-and-nonpic-1b-micromips.s}
460 {{objdump -dr pic-and-nonpic-1-micromips.dd}
461 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
462 "pic-and-nonpic-1-micromips-static1.o"}
463 }
464 # The final executable produced with the following test is supposed
465 # to be the same as one produced with the preceding test, however
466 # as noted in PR ld/20453 it is not. Consequently output from
467 # `objdump -dr' is not the same either. Expect:
468 #
469 # regexp_diff match failure
470 # regexp "^ 4103c: f001 0415 jalx 41054 <f3>$"
471 # line " 4103c: f001 0400 jalx 41000 <.pic.f3>"
472 #
473 # from the test below due to this problem.
474 setup_kfail "mips*-*-*" "ld/20453"
475 # The final check below should be folded into the `run_ld_link_tests'
476 # call above once `setup_kfail' has been removed.
477 run_ld_link_tests {
478 {"PIC and non-PIC test 1, microMIPS (static 2)"
479 "-melf32btsmip -Tpic-and-nonpic-1.ld \
480 tmpdir/pic-and-nonpic-1-micromips-rel.o" ""
481 "" {}
482 {{objdump -dr pic-and-nonpic-1-micromips.dd}
483 {readelf --symbols pic-and-nonpic-1-micromips.nd}}
484 "pic-and-nonpic-1-micromips-static2.o"}
485 }
486 run_dump_test "pic-and-nonpic-2"
487 run_ld_link_tests {
488 {"PIC and non-PIC test 3 (shared library)"
489 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
490 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
491 {{readelf --segments pic-and-nonpic-3a.sd}
492 {readelf -A pic-and-nonpic-3a.gd}
493 {objdump -dr pic-and-nonpic-3a.dd}}
494 "pic-and-nonpic-3a.so"}
495 {"PIC and non-PIC test 3 (executable)"
496 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so" ""
497 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
498 {{readelf --segments pic-and-nonpic-3b.sd}
499 {objdump -dr pic-and-nonpic-3b.dd}
500 {objdump {-s -j.got.plt} pic-and-nonpic-3b.pd}
501 {readelf -A pic-and-nonpic-3b.gd}
502 {readelf --relocs pic-and-nonpic-3b.rd}
503 {readelf --symbols pic-and-nonpic-3b.nd}
504 {readelf -d pic-and-nonpic-3b.ad}}
505 "pic-and-nonpic-3b"}
506 }
507 run_dump_test "pic-and-nonpic-3-error"
508 run_ld_link_tests {
509 {"PIC and non-PIC test 4 (shared library)"
510 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld" ""
511 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
512 {}
513 "pic-and-nonpic-4a.so"}
514 {"PIC and non-PIC test 4 (executable)"
515 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so" ""
516 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
517 {{readelf --segments pic-and-nonpic-4b.sd}
518 {objdump -dr pic-and-nonpic-4b.dd}
519 {objdump {-s -j.got -j.data} pic-and-nonpic-4b.gd}
520 {readelf --relocs pic-and-nonpic-4b.rd}
521 {readelf --symbols pic-and-nonpic-4b.nd}
522 {readelf -d pic-and-nonpic-4b.ad}}
523 "pic-and-nonpic-4b"}
524 }
525 run_dump_test "pic-and-nonpic-4-error"
526 run_ld_link_tests {
527 {"PIC and non-PIC test 5 (executable)"
528 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so" ""
529 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
530 {{readelf --segments pic-and-nonpic-5b.sd}
531 {objdump -dr pic-and-nonpic-5b.dd}
532 {objdump {-s -j.got.plt -j.data} pic-and-nonpic-5b.pd}
533 {readelf -A pic-and-nonpic-5b.gd}
534 {readelf --relocs pic-and-nonpic-5b.rd}
535 {readelf --symbols pic-and-nonpic-5b.nd}
536 {readelf -d pic-and-nonpic-5b.ad}}
537 "pic-and-nonpic-5b"}
538 }
539 set abis { o32 -32 elf32btsmip }
540 if $has_newabi {
541 lappend abis n32 -n32 elf32btsmipn32
542 lappend abis n64 -64 elf64btsmip
543 }
544 foreach { abi flag emul } $abis {
545 run_ld_link_tests [list \
546 [list "PIC and non-PIC test 6 ($abi shared library)" \
547 "-m$emul -shared -Tpic-and-nonpic-3a.ld" "" \
548 "$flag -EB -mips3" \
549 [list "pic-and-nonpic-6-${abi}a.s"] {} \
550 "pic-and-nonpic-6-${abi}.so"] \
551 [list "PIC and non-PIC test 6 ($abi executable)" \
552 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" "" \
553 "$flag -EB -mips3" \
554 [list "pic-and-nonpic-6-${abi}b.s" \
555 "pic-and-nonpic-6-${abi}c.s"] \
556 [list "readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
557 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
558 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
559 "readelf -A pic-and-nonpic-6-${abi}.gd" \
560 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
561 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
562 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
563 "pic-and-nonpic-6-${abi}"]]
564
565 # This checks whether our linker scripts get the scope of _gp right,
566 # and must therefore use default scripts. If they don't, then -- in
567 # addition to dumps failing to match -- the final link fails with:
568 #
569 # ld: gp-hidden.o: undefined reference to symbol '_gp'
570 # ld: note: '_gp' is defined in DSO ./tmpdir/gp-hidden-lib-${abi}.so
571 # so try adding it to the linker command line
572 #
573 set suff64 [string map {o32 "" n32 "" n64 -64} $abi]
574 run_ld_link_tests [list \
575 [list \
576 "_gp scope test ($abi shared library)" \
577 "$abi_ldflags($abi) -shared" "" \
578 "$abi_asflags($abi) -KPIC" \
579 { gp-hidden-lib.s } \
580 [list \
581 "readelf --relocs gp-hidden-lib${suff64}.rd" \
582 "readelf --syms gp-hidden.sd"] \
583 "gp-hidden-lib-${abi}.so"] \
584 [list \
585 "_gp scope test ($abi versioned library)" \
586 "$abi_ldflags($abi) -shared -version-script gp-hidden-ver.ver tmpdir/gp-hidden-lib-${abi}.so" "" \
587 "$abi_asflags($abi) -KPIC" \
588 { gp-hidden-ver.s } \
589 [list \
590 "readelf --relocs gp-hidden-ver${suff64}.rd" \
591 "readelf --syms gp-hidden.sd"] \
592 "gp-hidden-ver-${abi}.so"] \
593 [list \
594 "_gp scope test ($abi executable)" \
595 "$abi_ldflags($abi) -e 0 -rpath-link . tmpdir/gp-hidden-ver-${abi}.so" "" \
596 "$abi_asflags($abi) -call_nonpic" \
597 { gp-hidden.s } \
598 [list \
599 "readelf --relocs gp-hidden${suff64}.rd" \
600 "readelf --syms gp-hidden.sd"] \
601 "gp-hidden-${abi}"]]
602 }
603 }
604
605 if { $embedded_elf } {
606 run_dump_test "region1"
607 }
608
609 if $embedded_elf {
610 # This could work on other targets too, but would need the appropriate
611 # ld -m switch.
612 run_dump_test "reloc-1-rel"
613 }
614 if $has_newabi {
615 run_dump_test "reloc-1-n32" [list [list ld $abi_ldflags(n32)]]
616 run_dump_test "reloc-1-n64" [list [list ld $abi_ldflags(n64)]]
617 }
618 run_dump_test "reloc-2"
619 run_dump_test "reloc-merge-lo16"
620 run_dump_test "reloc-3"
621 if {$has_newabi} {
622 run_dump_test "reloc-3-n32"
623 }
624 run_dump_test "reloc-4"
625 run_dump_test "reloc-5"
626 if { $has_newabi } {
627 run_ld_link_tests [list \
628 [list \
629 "reloc test 6a" \
630 "-shared $abi_ldflags(n32)" "" \
631 "$abi_asflags(n32)" \
632 "reloc-6a.s" \
633 {} \
634 "reloc-6a.so"] \
635 [list \
636 "reloc test 6b" \
637 "$abi_ldflags(n32) tmpdir/reloc-6a.so" "" \
638 "$abi_asflags(n32)" \
639 "reloc-6b.s" \
640 {} \
641 "reloc-6b"]]
642 }
643
644 run_dump_test "reloc-local-overflow" [list [list ld $abi_ldflags(o32)]]
645 run_ld_link_tests [list \
646 [list \
647 "MIPS link ELF o32 PIC comdat GOT16/LO16 relocation pairing" \
648 "$abi_ldflags(o32) -e bar" "" "$abi_asflags(o32) -mno-pdr" \
649 "../../../gas/testsuite/gas/mips/comdat-reloc.s" \
650 {} \
651 "comdat-reloc"]]
652
653 if {$has_newabi && $linux_gnu} {
654 run_dump_test "eh-frame1-n32"
655 run_dump_test "eh-frame1-n64"
656 run_dump_test "eh-frame2-n32"
657 run_dump_test "eh-frame2-n64"
658 }
659 if {$embedded_elf} {
660 run_dump_test "eh-frame3"
661 run_dump_test "eh-frame4"
662 }
663 if {$linux_gnu} {
664 set eh_frame5_test {
665 {"MIPS eh-frame 5"
666 "-melf32btsmip -shared -Teh-frame5.ld" ""
667 "-32 -EB"
668 {eh-frame5.s}
669 {{readelf {--relocs -wf} eh-frame5.d}}
670 "eh-frame5.so"}
671 }
672 run_ld_link_tests $eh_frame5_test
673 }
674
675 if {$embedded_elf} {
676 run_dump_test "compact-eh1"
677 run_dump_test "compact-eh2"
678 run_dump_test "compact-eh3"
679 }
680
681 if {$linux_gnu} {
682 run_dump_test "compact-eh4"
683 run_dump_test "compact-eh5"
684 run_dump_test "compact-eh6"
685 }
686
687 run_dump_test "jaloverflow"
688 run_dump_test "jaloverflow-2"
689
690 run_dump_test "jal-global-overflow-0" [list [list ld $abi_ldflags(o32)]]
691 run_dump_test "jal-global-overflow-1" [list [list ld $abi_ldflags(o32)]]
692 run_dump_test "jal-local-overflow-0" [list [list ld $abi_ldflags(o32)]]
693 run_dump_test "jal-local-overflow-1" [list [list ld $abi_ldflags(o32)]]
694
695 run_dump_test "undefweak-overflow" [list [list as $abi_asflags(o32)] \
696 [list ld $abi_ldflags(o32)]]
697
698 if {$has_newabi} {
699 run_dump_test "undefweak-overflow" [list [list name (n32)] \
700 [list as $abi_asflags(n32)] \
701 [list ld $abi_ldflags(n32)]]
702 run_dump_test "undefweak-overflow" [list [list name (n64)] \
703 [list as $abi_asflags(n64)] \
704 [list ld $abi_ldflags(n64)]]
705 }
706
707 if {$has_newabi} {
708 run_dump_test "jalbal" [list [list ld $abi_ldflags(n32)]]
709 }
710
711 run_dump_test "mode-change-error-1"
712
713 run_dump_test "mips16-hilo"
714 if {$has_newabi} {
715 run_dump_test "mips16-hilo-n32"
716 }
717
718 if { $linux_gnu } {
719 if { $has_newabi } {
720 run_dump_test "textrel-1"
721 }
722 run_dump_test "got-page-1"
723 if $has_newabi {
724 run_dump_test "got-page-2"
725 run_dump_test "dyn-sec64"
726 }
727 run_dump_test "got-page-3"
728 run_ld_link_tests [subst {
729 {"GOT page 4 (one file)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
730 "" "$abi_asflags(o32) -mips2" {got-page-4b.s}
731 {{objdump -dr got-page-4a.d}
732 {readelf -A got-page-4a.got}}
733 "got-page-4a.so"}
734 {"GOT page 4 (two files)" "-shared $abi_ldflags(o32) -T got-page-1.ld"
735 "" "$abi_asflags(o32) -mips2" {got-page-4a.s got-page-4b.s}
736 {{objdump -dr got-page-4b.d}
737 {readelf -A got-page-4b.got}}
738 "got-page-4b.so"}
739 }]
740 if $has_newabi {
741 run_ld_link_tests [subst {
742 {"GOT page 5" "-shared $abi_ldflags(n32) -T got-page-1.ld"
743 "" "$abi_asflags(n32)" {got-page-5.s}
744 {{objdump -dr got-page-5.d}
745 {readelf -A got-page-5.got}}
746 "got-page-5.so"}
747 {"GOT page 6" "-shared $abi_ldflags(n32) -T got-page-1.ld"
748 "" "$abi_asflags(n32)" {got-page-6.s}
749 {{objdump -dr got-page-6.d}
750 {readelf -A got-page-6.got}}
751 "got-page-6.so"}
752 {"GOT page 7 (order 1)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
753 "" "$abi_asflags(n32)"
754 {got-page-7a.s got-page-7b.s got-page-7c.s got-page-7d.s
755 got-page-7e.s}
756 {{objdump -dr got-page-7.d}
757 {readelf -A got-page-7.got}}
758 "got-page-7a.so"}
759 {"GOT page 7 (order 2)" "-shared $abi_ldflags(n32) -T got-page-1.ld"
760 "" "$abi_asflags(n32)"
761 {got-page-7e.s got-page-7a.s got-page-7b.s got-page-7c.s
762 got-page-7d.s}
763 {{objdump -dr got-page-7.d}
764 {readelf -A got-page-7.got}}
765 "got-page-7b.so"}
766 }]
767 }
768 run_dump_test "got-dump-1"
769 if $has_newabi {
770 run_dump_test "got-dump-2"
771 }
772 run_dump_test "reloc-estimate-1"
773 }
774
775 if $has_newabi {
776 run_dump_test "emit-relocs-1"
777 }
778
779 run_dump_test "hash1a"
780 run_dump_test "hash1b"
781 run_dump_test "hash1c"
782
783 if {[istarget mips*-*-linux*]} {
784 # The number of symbols that are always included in the symbol table
785 # for these tests. The 4 are:
786 #
787 # the null symbol entry
788 # the .MIPS.stubs section symbol
789 set base_syms 2
790 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
791 run_ld_link_tests \
792 [list [list \
793 "Stub for dynsym 0x$dynsym" \
794 "-shared -melf32btsmip -T stub-dynsym-1.ld" "" \
795 [concat \
796 "-EB -march=mips1 -32 -KPIC" \
797 "--defsym base_syms=$base_syms" \
798 "--defsym dynsym=0x$dynsym"] \
799 [list "stub-dynsym-1.s"] \
800 [list [list \
801 "objdump" "-dz" \
802 "stub-dynsym-1-$dynsym.d"]] \
803 "stub-dynsym-1-$dynsym"]]
804 }
805 }
806
807 # For tests which may involve multiple files, use run_ld_link_tests.
808
809 # List contains test-items with 3 items followed by 2 lists:
810 # 0:name 1:ld early options 2:ld late options 3:assembler options
811 # 4:filenames of assembler files 5: action and options. 6: name of output file
812
813 # Actions:
814 # objdump: Apply objdump options on result. Compare with regex (last arg).
815 # nm: Apply nm options on result. Compare with regex (last arg).
816 # readelf: Apply readelf options on result. Compare with regex (last arg).
817
818 set mips_tls_tests {
819 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld" ""
820 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
821 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
822 "tls-static-o32"}
823 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld" ""
824 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
825 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
826 "tlslib-o32.so"}
827 {"Dynamic executable with TLS"
828 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so" ""
829 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
830 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
831 "tls-dynamic-o32"}
832 {"Shared library with multiple GOTs and TLS"
833 "-shared -melf32btsmip -T mips-lib.ld" ""
834 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
835 {{readelf {-d -r} tls-multi-got-1.r}
836 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
837 {objdump -Rsj.got tls-multi-got-1.got}}
838 "tlslib-multi.so"}
839 {"Shared library with TLS and versioning"
840 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver" ""
841 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
842 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
843 "tlslib-o32-ver.so"}
844 {"Dynamic executable with TLS and versioning"
845 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so" ""
846 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
847 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
848 "tls-dynamic-o32-ver"}
849 {"Dynamic executable with TLS and versioning (order 2)"
850 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o" ""
851 "-EB -march=mips1 -32 -KPIC" {}
852 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
853 "tls-dynamic-o32-ver-2"}
854 {"Dynamic executable with TLS and versioning (order 3)"
855 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o" ""
856 "-EB -march=mips1 -32 -KPIC" {}
857 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
858 "tls-dynamic-o32-ver-3"}
859 {"Shared library with TLS and hidden symbols"
860 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver" ""
861 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
862 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
863 "tlslib-o32-hidden.so"}
864 {"Shared library with TLS and hidden symbols (2)"
865 "-shared -melf32btsmip -T mips-lib.ld" ""
866 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
867 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
868 "tls-hidden2.so"}
869 {"Shared library with TLS and hidden symbols (3)"
870 "-shared -melf32btsmip -T tls-hidden3.ld" ""
871 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
872 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
873 {readelf --relocs tls-hidden3.r}}
874 "tls-hidden3.so"}
875 {"Shared library with TLS and hidden symbols (4)"
876 "-shared -melf32btsmip -T tls-hidden3.ld" ""
877 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
878 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
879 "tls-hidden4.so"}
880 }
881
882 if {[istarget mips*-*-linux*]} {
883 run_ld_link_tests $mips_tls_tests
884 }
885
886 set mips16_call_global_test [list \
887 [list "Global calls from mips16" \
888 "$abi_ldflags(o32) -T no-shared-1.ld" "" \
889 "$abi_asflags(o32) -mips32r2" \
890 {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s} \
891 {{objdump -dr mips16-call-global.d}} \
892 "mips16-call-global"]]
893
894 run_ld_link_tests $mips16_call_global_test
895
896 set mips16_intermix_test [list \
897 [list "Intermixing mips32 and mips16 functions" \
898 "$abi_ldflags(o32)" "" \
899 "$abi_asflags(o32) -mips32r2" \
900 {mips16-intermix-1.s mips16-intermix-2.s} \
901 {{objdump -t mips16-intermix.d}} \
902 "mips16-intermix"]]
903
904 run_ld_link_tests $mips16_intermix_test
905
906 run_dump_test "mips16-local-stubs-1"
907
908 set mips16_fp_stub_test [list \
909 [list "Floating-point stub for mips16 functions" \
910 "$abi_ldflags(o32)" "" \
911 "$abi_asflags(o32) -mips32r2" \
912 {mips16-fp-stub-1.s mips16-fp-stub-2.s} \
913 {{readelf --debug-dump=frames mips16-fp-stub.d}} \
914 "mips16-fp-stub"]]
915
916 run_ld_link_tests $mips16_fp_stub_test
917
918 set o32flagslist [list [list as $abi_asflags(o32)] [list ld $abi_ldflags(o32)]]
919
920 foreach firstfpabi [list 0 1 2 3 4 5 6 7 ] {
921 foreach secondfpabi [list 4 5 6 7 ] {
922 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
923 }
924 }
925 foreach firstfpabi [list 4 5 6 7 ] {
926 foreach secondfpabi [list 0 1 2 3 8 9] {
927 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}" $o32flagslist
928 }
929 }
930 foreach firstfpabi [list 0 1 2 3 ] {
931 foreach secondfpabi [list 0 1 2 3 8 9] {
932 run_dump_test "attr-gnu-4-${firstfpabi}${secondfpabi}"
933 }
934 }
935
936 run_dump_test "attr-gnu-4-81"
937
938 run_dump_test "attr-gnu-8-00"
939 run_dump_test "attr-gnu-8-01"
940 run_dump_test "attr-gnu-8-02"
941 run_dump_test "attr-gnu-8-10"
942 run_dump_test "attr-gnu-8-11"
943 run_dump_test "attr-gnu-8-12"
944 run_dump_test "attr-gnu-8-20"
945 run_dump_test "attr-gnu-8-21"
946 run_dump_test "attr-gnu-8-22"
947
948 run_dump_test "attr-gnu-4-0-ph" $o32flagslist
949 run_dump_test "attr-gnu-4-1-ph" $o32flagslist
950 run_dump_test "attr-gnu-4-2-ph" $o32flagslist
951 run_dump_test "attr-gnu-4-3-ph" $o32flagslist
952 run_dump_test "attr-gnu-4-4-ph" $o32flagslist
953 run_dump_test "attr-gnu-4-5-ph" $o32flagslist
954 run_dump_test "attr-gnu-4-6-ph" $o32flagslist
955 run_dump_test "attr-gnu-4-7-ph" $o32flagslist
956
957 if $has_newabi {
958 run_dump_test "attr-gnu-4-0-n32-ph"
959 run_dump_test "attr-gnu-4-1-n32-ph"
960 run_dump_test "attr-gnu-4-2-n32-ph"
961 run_dump_test "attr-gnu-4-3-n32-ph"
962 run_dump_test "attr-gnu-4-0-n64-ph"
963 run_dump_test "attr-gnu-4-1-n64-ph"
964 run_dump_test "attr-gnu-4-2-n64-ph"
965 run_dump_test "attr-gnu-4-3-n64-ph"
966 }
967
968 run_dump_test "abiflags-strip1-ph" $o32flagslist
969 run_dump_test "abiflags-strip2-ph" $o32flagslist
970 run_dump_test "abiflags-strip3-ph" $o32flagslist
971 run_dump_test "abiflags-strip4-ph" $o32flagslist
972 run_dump_test "abiflags-strip5-ph" $o32flagslist
973 run_dump_test "abiflags-strip6-ph" $o32flagslist
974 run_dump_test "abiflags-strip7-ph" $o32flagslist
975 run_dump_test "abiflags-strip8-ph" $o32flagslist
976 run_dump_test "abiflags-strip9-ph" $o32flagslist
977 run_dump_test "abiflags-strip10-ph" $o32flagslist
978
979 run_dump_test "nan-legacy"
980 run_dump_test "nan-2008"
981 run_dump_test "nan-mixed-1"
982 run_dump_test "nan-mixed-2"
983
984 if { $linux_gnu } {
985 run_ld_link_tests {
986 {"GOT and versioning 1"
987 "-shared -melf32btsmip --version-script got-vers-1.ver" ""
988 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
989 {{readelf -d got-vers-1.dd}
990 {readelf --symbols got-vers-1.sd}
991 {readelf --relocs got-vers-1.rd}}
992 "got-vers-1.so"}
993 }
994 }
995
996 run_dump_test "undefined"
997
998 # Test the conversion from jr to b
999 if { $linux_gnu } {
1000 run_dump_test "jr-to-b-1"
1001 run_dump_test "jr-to-b-2"
1002 }
1003
1004 # MIPS16 and microMIPS interlinking test.
1005 run_dump_test "mips16-and-micromips"
1006
1007 # Export class call relocation tests.
1008 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
1009 foreach { abi } $abis {
1010 set loadaddr [string map \
1011 {o32 0x12340000 n32 0x12340000 n64 0x123456789abc0000} $abi]
1012 set suff [subst \
1013 [expr { [istarget *-*-irix*] \
1014 ? [string map {o32 o32-irix n32 n32 n64 n64} $abi] \
1015 : $abi }]]
1016 run_ld_link_tests [list \
1017 [list \
1018 "MIPS export class call relocation test ($abi)" \
1019 "$abi_ldflags($abi) -shared -Ttext $loadaddr -T export-class-call16.ld" "" \
1020 "$abi_asflags($abi) -mips3 -KPIC" \
1021 [list export-class-call16-${abi}.s export-class-call16-def.s] \
1022 [list \
1023 "objdump -d export-class-call16-${suff}.dd" \
1024 "readelf -A export-class-call16-${abi}.gd"] \
1025 "export-class-call16-${abi}.so"]]
1026 }
1027
1028 # Magic __ehdr_start symbol tests.
1029 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
1030 foreach { abi } $abis {
1031 set suff [string map {o32 o32 n32 new n64 new} $abi]
1032 run_ld_link_tests [list \
1033 [list \
1034 "MIPS magic __ehdr_start symbol test 1 ($abi)" \
1035 "$abi_ldflags($abi) -T ehdr_start-1.ld" "" \
1036 "$abi_asflags($abi)" \
1037 [list ehdr_start-${suff}.s] \
1038 [list "readelf -s ehdr_start-1.nd"] \
1039 "ehdr_start-1-${abi}"] \
1040 [list \
1041 "MIPS magic __ehdr_start symbol test 2 ($abi)" \
1042 "$abi_ldflags($abi) -T ehdr_start-2.ld" "" \
1043 "$abi_asflags($abi)" \
1044 [list ehdr_start-${suff}.s] \
1045 [list "readelf -s ehdr_start-2.nd"] \
1046 "ehdr_start-2-${abi}"]]
1047 }
1048
1049 # R_MIPS_JALR reloc tests.
1050 set abis [concat o32 [expr {$has_newabi ? "n32 n64" : ""}]]
1051 foreach { abi } $abis {
1052 run_ld_link_tests [list \
1053 [list \
1054 "MIPS JALR reloc test ($abi)" \
1055 "$abi_ldflags($abi) -T jalr3.ld" "" \
1056 "$abi_asflags($abi)" \
1057 [list ../../../gas/testsuite/gas/mips/jalr3.s] \
1058 [list "objdump -d jalr3.dd"] \
1059 "jalr3-${abi}"] \
1060 [list \
1061 "MIPS JALR reloc unaligned/cross-mode link test ($abi)" \
1062 "$abi_ldflags($abi) -T jalr3.ld" "" \
1063 "$abi_asflags($abi)" \
1064 [list ../../../gas/testsuite/gas/mips/jalr4.s] \
1065 [list "objdump {-d --prefix-addresses --show-raw-insn} jalr4.dd"] \
1066 "jalr4-${abi}"] \
1067 [list \
1068 "MIPSr6 JALR reloc unaligned/cross-mode link test ($abi)" \
1069 "$abi_ldflags($abi) -T jalr3.ld" "" \
1070 [string map \
1071 [list -32 "-mips32r6 -32" \
1072 -n32 "-mips64r6 -n32" \
1073 -64 "-mips64r6 -64"] \
1074 [regsub -- -march=from-abi $abi_asflags($abi) ""]] \
1075 {../../../gas/testsuite/gas/mips/jalr4.s} \
1076 {{objdump {-d --prefix-addresses --show-raw-insn} jalr4-r6.dd}} \
1077 "jalr4-${abi}"]]
1078 }
1079
1080 proc build_mips_plt_lib { abi } {
1081 global abi_asflags
1082 global abi_ldflags
1083
1084 run_ld_link_tests [list \
1085 [list "Shared $abi library for compressed PLT tests" \
1086 "-shared $abi_ldflags($abi)" "" \
1087 "$abi_asflags($abi)" \
1088 { compressed-plt-1-dyn.s } \
1089 {} \
1090 "compressed-plt-1-${abi}-dyn.so"]]
1091 }
1092
1093 proc run_mips_plt_test { name abi filter micromips suffix {extra {}} } {
1094 global abi_asflags
1095 global abi_ldflags
1096
1097 set as_flags "$abi_asflags($abi) --defsym filter=$filter"
1098 append as_flags " --defsym micromips=$micromips --defsym $abi=1"
1099 if {[string equal $abi o32]} {
1100 append as_flags " -march=mips2"
1101 }
1102 set ld_flags "$abi_ldflags($abi) -T compressed-plt-1.ld"
1103 set dynobj "tmpdir/compressed-plt-1-${abi}-dyn.so"
1104 set files [list]
1105 if { $filter & 7 } {
1106 lappend files compressed-plt-1a.s
1107 }
1108 if { $filter & 56 } {
1109 lappend files compressed-plt-1b.s
1110 }
1111 if { $filter & 64 } {
1112 lappend files compressed-plt-1c.s
1113 }
1114 eval [list lappend files] $extra
1115 set readelf_flags "-A --syms --relocs -d"
1116 if { [string match "*word*" $suffix] } {
1117 append readelf_flags " -x.data"
1118 }
1119 set objdump_flags "-d -Mgpr-names=numeric"
1120 set basename "compressed-plt-1-${abi}-${suffix}"
1121 run_ld_link_tests [list \
1122 [list "$name" $ld_flags $dynobj \
1123 "$as_flags" $files \
1124 [list [list readelf $readelf_flags ${basename}.rd] \
1125 [list objdump $objdump_flags ${basename}.od]] \
1126 $basename]]
1127 }
1128
1129 if { $linux_gnu } {
1130 build_mips_plt_lib o32
1131 run_mips_plt_test "o32 PLTs for standard encoding" o32 104 0 se
1132 run_mips_plt_test "o32 PLTs for standard branches" o32 16 0 branch
1133 run_mips_plt_test "o32 PLTs for MIPS16 encoding" o32 69 0 mips16-only
1134 run_mips_plt_test "o32 PLTs for MIPS16 branches" o32 2 0 mips16-bronly
1135 run_mips_plt_test "o32 PLTs for microMIPS encoding" o32 69 1 umips-only
1136 run_mips_plt_test "o32 PLTs for microMIPS branches" o32 2 1 umips-bronly
1137 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16" \
1138 o32 109 0 mips16
1139 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 branches" \
1140 o32 18 0 mips16-branch
1141 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with %got" \
1142 o32 109 0 mips16-got compressed-plt-1d.s
1143 run_mips_plt_test "o32 PLTs for mixed MIPS and MIPS16 with .word" \
1144 o32 109 0 mips16-word compressed-plt-1e.s
1145 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS" \
1146 o32 109 1 umips
1147 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS branches" \
1148 o32 18 1 umips-branch
1149 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with %got" \
1150 o32 109 1 umips-got compressed-plt-1d.s
1151 run_mips_plt_test "o32 PLTs for mixed MIPS and microMIPS with .word" \
1152 o32 109 1 umips-word compressed-plt-1e.s
1153
1154 if $has_newabi {
1155 build_mips_plt_lib n32
1156 run_mips_plt_test "n32 PLTs for mixed MIPS and MIPS16" \
1157 n32 109 0 mips16
1158 run_mips_plt_test "n32 PLTs for mixed MIPS and microMIPS" \
1159 n32 109 1 umips
1160 }
1161 }
1162
1163 # PR ld/19908 export class tests.
1164 if { $linux_gnu } {
1165 run_ld_link_tests [list \
1166 [list "Shared library for MIPS export class symbol reference tests" \
1167 "$abi_ldflags(o32) -shared" "" \
1168 "$abi_asflags(o32)" \
1169 { export-class-ref-f2.s } \
1170 { { readelf --dyn-syms export-class-ref-lib.sd } } \
1171 "export-class-ref-lib.so"]]
1172 foreach { class flag } { internal 1 hidden 2 protected 3 } {
1173 run_ld_link_tests [list \
1174 [list "MIPS $class symbol reference test 1" \
1175 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1176 "$abi_asflags(o32) --defsym defv=$flag" \
1177 { export-class-ref-f0.s export-class-ref-f1.s } \
1178 [list [list readelf --dyn-syms export-$class-ref.sd] \
1179 [list readelf --dyn-syms export-local-ref.sd]] \
1180 "export-$class-ref"] \
1181 [list "MIPS $class symbol reference test 2" \
1182 "$abi_ldflags(o32) -e f0" "tmpdir/export-class-ref-lib.so" \
1183 "$abi_asflags(o32) --defsym defv=$flag --defsym refv=$flag" \
1184 { export-class-ref-f0.s export-class-ref-f1.s } \
1185 [list [list readelf --dyn-syms export-$class-ref.sd] \
1186 [list readelf --dyn-syms export-local-ref.sd]] \
1187 "export-$class-ref"]]
1188 }
1189 }
1190
1191 # PR ld/21334 GOT relocation in static binary test.
1192 run_ld_link_tests [list \
1193 [list \
1194 "PR ld/21233 MIPS GOT16 relocation in static binary" \
1195 "$abi_ldflags(o32) -e foo -T pr21334.ld" "" "$abi_asflags(o32)" \
1196 {pr21334.s} \
1197 {{objdump {-d --prefix-addresses} pr21334.dd} \
1198 {readelf -A pr21334.gd}} \
1199 "pr21334"]]
1200
1201 # Check that the ISA level is consistently II for the LSI 4010.
1202 run_dump_test "lsi-4010-isa" [list [list ld $abi_ldflags(o32)]]
1203
1204 # PIC branch relaxation with offset tests. We need to use our version
1205 # of `prune_warnings' to get rid of GAS branch relaxation noise.
1206 rename prune_warnings mips_old_prune_warnings
1207 proc prune_warnings { msg } {
1208 set msg1 "Assembler messages:"
1209 set msg2 "Warning: relaxed out-of-range branch into a jump"
1210 set msgx "(?:$msg1|$msg2)"
1211 regsub -all "(^|\[\n\r\]*)\[^\n\r\]*: $msgx\[\n\r\]*" $msg "\\1" msg
1212 return [mips_old_prune_warnings $msg]
1213 }
1214 run_ld_link_tests [list \
1215 [list \
1216 "MIPS link PIC branch relaxation with offset" \
1217 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1218 "$abi_asflags(o32) -relax-branch -mips2" \
1219 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1220 {{objdump \
1221 {-d --prefix-addresses --show-raw-insn} \
1222 relax-offset.dd} \
1223 {readelf -A relax-offset.gd}} \
1224 "relax-offset"] \
1225 [list \
1226 "microMIPS link PIC branch relaxation with offset" \
1227 "$abi_ldflags(o32) -shared -T relax-offset.ld" "" \
1228 "$abi_asflags(o32) -relax-branch -mmicromips" \
1229 {../../../gas/testsuite/gas/mips/relax-offset.s} \
1230 {{objdump \
1231 {-d --prefix-addresses --show-raw-insn} \
1232 relax-offset-umips.dd} \
1233 {readelf -A relax-offset-umips.gd}} \
1234 "relax-offset-umips"]]
1235 rename prune_warnings ""
1236 rename mips_old_prune_warnings prune_warnings
1237
1238 # Verify that we can link ELF input into the `binary' output format.
1239 run_dump_test "binary"
This page took 0.059337 seconds and 4 git commands to generate.