1 # Expect script
for MIPS ELF linker tests
2 # Copyright
2002, 2003, 2004, 2005, 2007 Free Software Foundation
, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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
,
22 if {[istarget
"mips*-*-vxworks"]} {
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
}}
29 {"VxWorks executable test 1 (dynamic)" \
30 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic"
32 {{readelf
--relocs vxworks1.rd
} {objdump
-dr vxworks1.dd
}}
34 {"VxWorks executable test 2 (dynamic)" \
35 "-Tvxworks1.ld -q --force-dynamic"
37 {{readelf
--segments vxworks2.sd
}}
39 {"VxWorks executable test 2 (static)"
42 {{readelf
--segments vxworks2
-static.sd
}}
45 run_ld_link_tests $mipsvxtests
46 run_dump_test
"vxworks1-static"
47 run_dump_test
"vxworks-forced-local-1"
51 if {![istarget mips
*-*-*] ||
![is_elf_format
]} {
55 set has_newabi
[expr
[istarget
*-*-irix6
*] ||
[istarget mips64
*-*-linux
*]]
56 set linux_gnu
[expr
[istarget mips
*-*-linux
*]]
57 set embedded_elf
[expr
[istarget mips
*-*-elf
]]
60 run_ld_link_tests
[list \
61 [list
"Dummy shared library for MIPS16 PIC test 1" \
62 "-shared -melf32btsmip" \
63 "-EB -32" { mips16-pic-1-dummy.s } \
65 "mips16-pic-1-dummy.so"] \
66 [list
"MIPS16 PIC test 1" \
67 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" \
68 "-EB -32 -I $srcdir/$subdir" { mips16-pic-1a.s mips16-pic-1b.s } \
69 { { objdump
{ -dr
-j.
text } mips16
-pic
-1.dd
}
70 { readelf
-A mips16
-pic
-1.gd
} } \
72 [list
"MIPS16 PIC test 2" \
73 "-melf32btsmip -T mips16-pic-1.ld -shared" \
74 "-EB -32 -I $srcdir/$subdir" { mips16-pic-2a.s mips16-pic-2b.s } \
75 { { objdump
{ -dr
-j.
text } mips16
-pic
-2.dd
} \
76 { readelf
-A mips16
-pic
-2.gd
} \
77 { readelf
--symbols mips16
-pic
-2.nd
} \
78 { readelf
--relocs mips16
-pic
-2.rd
} \
79 { readelf
-d mips16
-pic
-2.ad
} } \
81 [list
"MIPS16 PIC test 3" \
82 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-1-dummy.so" \
83 "-EB -32 -I $srcdir/$subdir" { mips16-pic-3a.s mips16-pic-3b.s } \
84 { { objdump
-dr mips16
-pic
-3.dd
} \
85 { readelf
--relocs mips16
-pic
-3.rd
} \
86 { readelf
-A mips16
-pic
-3.gd
} } \
88 [list
"MIPS16 PIC test 4 (shared library)" \
89 "-shared -melf32btsmip -T mips16-pic-1.ld --version-script mips16-pic-4.ver" \
90 "-EB -32" { mips16-pic-4a.s mips16-pic-4b.s } \
91 { { objdump
-dr mips16
-pic
-4a.dd
} \
92 { readelf
--symbols mips16
-pic
-4a.nd
} \
93 { readelf
-A mips16
-pic
-4a.gd
} } \
95 [list
"MIPS16 PIC test 4 (executable)" \
96 "-melf32btsmip -T mips16-pic-1.ld tmpdir/mips16-pic-4.so" \
97 "-EB -32" { mips16-pic-4c.s } \
98 { { objdump
-dr mips16
-pic
-4b.dd
} } \
102 if { [istarget mips64
*-linux
-gnu
] } {
103 set o32_as_flags
"-32 -EB"
104 set o32_ld_flags
"-melf32btsmip"
110 # Check MIPS16 markings being passed through link.
111 run_dump_test
"mips16-1"
113 # MIPS branch offset final link checking.
114 run_dump_test
"branch-misc-1"
116 # Test multi
-got link. We only
do this
on GNU
/Linux because it requires
117 # the
"traditional" emulations.
119 run_dump_test
"multi-got-1"
120 run_dump_test
"multi-got-no-shared"
121 run_dump_test
"multi-got-hidden-1"
122 run_dump_test
"multi-got-hidden-2"
125 # Test __gnu_local_gp accesses
127 run_dump_test
"no-shared-1-o32"
129 run_dump_test
"no-shared-1-n32"
130 run_dump_test
"no-shared-1-n64"
135 run_dump_test
"elf-rel-got-n32"
136 run_dump_test
"elf-rel-xgot-n32"
138 run_dump_test
"elf-rel-got-n64-linux"
139 run_dump_test
"elf-rel-xgot-n64-linux"
141 run_dump_test
"elf-rel-got-n64"
142 run_dump_test
"elf-rel-xgot-n64"
145 run_dump_test
"relax-jalr-n32"
146 run_dump_test
"relax-jalr-n32-shared"
147 run_dump_test
"relax-jalr-n64"
148 run_dump_test
"relax-jalr-n64-shared"
152 run_dump_test
"rel32-o32"
153 run_dump_test
"rel32-n32"
154 run_dump_test
"rel64"
155 # The first test checks that a mixed PIC
/non
-PIC relocatable link
156 # will not introduce
any stubs itself
, but will flag PIC functions
157 #
for the final link.
159 # The second test checks that we insert stubs
for calls from
160 # non
-PIC functions to PIC functions when linking the original
161 # two objects together.
163 # The third test checks that we
do the same when linking the
164 # result of the first link
(with no other source files
).
166 {"PIC and non-PIC test 1 (relocatable)" "-r -melf32btsmip"
167 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
168 {{objdump
-dr pic
-and
-nonpic
-1-rel.dd
}
169 {readelf
--symbols pic
-and
-nonpic
-1-rel.nd
}}
170 "pic-and-nonpic-1-rel.o"}
171 {"PIC and non-PIC test 1 (static 1)"
172 "-melf32btsmip -Tpic-and-nonpic-1.ld"
173 "-32 -EB -mips2" {pic-and-nonpic-1a.s pic-and-nonpic-1b.s}
174 {{objdump
-dr pic
-and
-nonpic
-1.dd
}
175 {readelf
--symbols pic
-and
-nonpic
-1.nd
}}
176 "pic-and-nonpic-1-static1.o"}
177 {"PIC and non-PIC test 1 (static 2)"
178 "-melf32btsmip -Tpic-and-nonpic-1.ld tmpdir/pic-and-nonpic-1-rel.o"
180 {{objdump
-dr pic
-and
-nonpic
-1.dd
}
181 {readelf
--symbols pic
-and
-nonpic
-1.nd
}}
182 "pic-and-nonpic-1-static2.o"}
184 run_dump_test
"pic-and-nonpic-2"
186 {"PIC and non-PIC test 3 (shared library)"
187 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld"
188 "-32 -EB -mips2" {pic-and-nonpic-3a.s}
189 {{readelf
--segments pic
-and
-nonpic
-3a.sd
}
190 {readelf
-A pic
-and
-nonpic
-3a.gd
}
191 {objdump
-dr pic
-and
-nonpic
-3a.dd
}}
192 "pic-and-nonpic-3a.so"}
193 {"PIC and non-PIC test 3 (executable)"
194 "-melf32btsmip -Tpic-and-nonpic-3b.ld tmpdir/pic-and-nonpic-3a.so"
195 "-32 -EB -mips2" {pic-and-nonpic-3b.s}
196 {{readelf
--segments pic
-and
-nonpic
-3b.sd
}
197 {objdump
-dr pic
-and
-nonpic
-3b.dd
}
198 {objdump
{-s
-j.got.plt
} pic
-and
-nonpic
-3b.pd
}
199 {readelf
-A pic
-and
-nonpic
-3b.gd
}
200 {readelf
--relocs pic
-and
-nonpic
-3b.rd
}
201 {readelf
--symbols pic
-and
-nonpic
-3b.nd
}
202 {readelf
-d pic
-and
-nonpic
-3b.ad
}}
205 run_dump_test
"pic-and-nonpic-3-error"
207 {"PIC and non-PIC test 4 (shared library)"
208 "-melf32btsmip -shared -Tpic-and-nonpic-3a.ld"
209 "-32 -EB -mips2" {pic-and-nonpic-4a.s}
211 "pic-and-nonpic-4a.so"}
212 {"PIC and non-PIC test 4 (executable)"
213 "-melf32btsmip -Tpic-and-nonpic-4b.ld tmpdir/pic-and-nonpic-4a.so"
214 "-32 -EB -mips2" {pic-and-nonpic-4b.s}
215 {{readelf
--segments pic
-and
-nonpic
-4b.sd
}
216 {objdump
-dr pic
-and
-nonpic
-4b.dd
}
217 {objdump
{-s
-j.got
-j.data
} pic
-and
-nonpic
-4b.gd
}
218 {readelf
--relocs pic
-and
-nonpic
-4b.rd
}
219 {readelf
--symbols pic
-and
-nonpic
-4b.nd
}
220 {readelf
-d pic
-and
-nonpic
-4b.ad
}}
223 run_dump_test
"pic-and-nonpic-4-error"
225 {"PIC and non-PIC test 5 (executable)"
226 "-melf32btsmip -Tpic-and-nonpic-5b.ld tmpdir/pic-and-nonpic-3a.so tmpdir/pic-and-nonpic-4a.so"
227 "-32 -EB -mips2" {pic-and-nonpic-5a.s pic-and-nonpic-5b.s}
228 {{readelf
--segments pic
-and
-nonpic
-5b.sd
}
229 {objdump
-dr pic
-and
-nonpic
-5b.dd
}
230 {objdump
{-s
-j.got.plt
-j.data
} pic
-and
-nonpic
-5b.pd
}
231 {readelf
-A pic
-and
-nonpic
-5b.gd
}
232 {readelf
--relocs pic
-and
-nonpic
-5b.rd
}
233 {readelf
--symbols pic
-and
-nonpic
-5b.nd
}
234 {readelf
-d pic
-and
-nonpic
-5b.ad
}}
237 set abis
{ o32
-32 elf32btsmip
}
239 lappend abis n32
-n32 elf32btsmipn32
240 lappend abis n64
-64 elf64btsmip
242 foreach
{ abi flag emul
} $abis
{
243 run_ld_link_tests
[list \
244 [list
"PIC and non-PIC test 6 ($abi shared library)" \
245 "-m$emul -shared -Tpic-and-nonpic-3a.ld" \
247 [list
"pic-and-nonpic-6-${abi}a.s"] {} \
248 "pic-and-nonpic-6-${abi}.so"] \
249 [list
"PIC and non-PIC test 6 ($abi executable)" \
250 "-m$emul -Tpic-and-nonpic-6.ld tmpdir/pic-and-nonpic-6-${abi}.so" \
252 [list
"pic-and-nonpic-6-${abi}b.s" \
253 "pic-and-nonpic-6-${abi}c.s"] \
254 [list
"readelf {--wide --segments} pic-and-nonpic-6-${abi}.sd" \
255 "objdump -dr pic-and-nonpic-6-${abi}.dd" \
256 "objdump {-s -j.got.plt} pic-and-nonpic-6-${abi}.pd" \
257 "readelf -A pic-and-nonpic-6-${abi}.gd" \
258 "readelf --relocs pic-and-nonpic-6-${abi}.rd" \
259 "readelf --symbols pic-and-nonpic-6-${abi}.nd" \
260 "readelf -d pic-and-nonpic-6-${abi}.ad"] \
261 "pic-and-nonpic-6-${abi}"]]
265 if { $embedded_elf
} {
266 run_dump_test
"region1"
270 # This could work
on other targets too
, but would need the appropriate
272 run_dump_test
"reloc-1-rel"
275 run_dump_test
"reloc-1-n32"
277 # Uses a linux
-specific
ld -m
switch
278 run_dump_test
"reloc-1-n64"
281 run_dump_test
"reloc-2"
282 run_dump_test
"reloc-merge-lo16"
283 run_dump_test
"reloc-3"
285 run_dump_test
"reloc-3-n32"
287 run_dump_test
"reloc-4"
288 run_dump_test
"reloc-5"
290 if {$has_newabi
&& $linux_gnu
} {
291 run_dump_test
"eh-frame1-n32"
292 run_dump_test
"eh-frame1-n64"
293 run_dump_test
"eh-frame2-n32"
294 run_dump_test
"eh-frame2-n64"
297 run_dump_test
"eh-frame3"
298 run_dump_test
"eh-frame4"
301 run_dump_test
"jaloverflow"
302 run_dump_test
"jaloverflow-2"
304 run_dump_test
"jalbal"
307 run_dump_test
"mips16-hilo"
309 run_dump_test
"mips16-hilo-n32"
313 run_dump_test
"textrel-1"
314 run_dump_test
"got-page-1"
316 run_dump_test
"got-page-2"
317 run_dump_test
"dyn-sec64"
319 run_dump_test
"got-page-3"
320 run_dump_test
"got-dump-1"
322 run_dump_test
"got-dump-2"
324 run_dump_test
"reloc-estimate-1"
328 run_dump_test
"emit-relocs-1"
331 run_dump_test
"hash1a"
332 run_dump_test
"hash1b"
333 run_dump_test
"hash1c"
335 if {[istarget mips
*-*-linux
*]} {
336 # The number of symbols that are always included in the symbol table
337 #
for these tests. The
4 are
:
339 # the null symbol entry
340 # the .MIPS.stubs section symbol
342 # _GLOBAL_OFFSET_TABLE_
344 foreach dynsym
{ 7fff
8000 fff0
10000 2fe80
} {
347 "Stub for dynsym 0x$dynsym" \
348 "-shared -melf32btsmip -T stub-dynsym-1.ld" \
350 "-EB -march=mips1 -32 -KPIC" \
351 "--defsym base_syms=$base_syms" \
352 "--defsym dynsym=0x$dynsym"] \
353 [list
"stub-dynsym-1.s"] \
356 "stub-dynsym-1-$dynsym.d"]] \
357 "stub-dynsym-1-$dynsym"]]
361 #
For tests which may involve multiple files
, use run_ld_link_tests.
363 # List contains test
-items with
3 items followed by
2 lists
:
364 #
0:name 1:ld options
2:assembler options
365 #
3:filenames of assembler files
4: action and options.
5: name of output file
368 # objdump
: Apply objdump options
on result. Compare with regex
(last
arg).
369 # nm
: Apply nm options
on result. Compare with regex
(last
arg).
370 # readelf
: Apply readelf options
on result. Compare with regex
(last
arg).
373 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld"
374 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
375 {{objdump
{-dr
-m mips
:isa32r2
} tlsbin
-o32.d
} {objdump
-srj.got tlsbin
-o32.got
}}
377 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld"
378 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
379 {{objdump
{-dr
-m mips
:isa32r2
} tlslib
-o32.d
} {objdump
-Rsj.got tlslib
-o32.got
}}
381 {"Dynamic executable with TLS"
382 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so"
383 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
384 {{objdump
{-dr
-m mips
:isa32r2
} tlsdyn
-o32.d
} {objdump
-Rsj.got tlsdyn
-o32.got
}}
386 {"Shared library with multiple GOTs and TLS"
387 "-shared -melf32btsmip -T mips-lib.ld"
388 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
389 {{readelf
{-d
-r
} tls
-multi
-got
-1.r
}
390 {objdump
{-dr
-m mips
:isa32r2
} tls
-multi
-got
-1.d
}
391 {objdump
-Rsj.got tls
-multi
-got
-1.got
}}
393 {"Shared library with TLS and versioning"
394 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver"
395 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
396 {{objdump
{-dr
-m mips
:isa32r2
} tlslib
-o32.d
} {objdump
-Rsj.got tlslib
-o32
-ver.got
}}
398 {"Dynamic executable with TLS and versioning"
399 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so"
400 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
401 {{objdump
{-dr
-m mips
:isa32r2
} tlsdyn
-o32
-1.d
} {objdump
-Rsj.got tlsdyn
-o32
-1.got
}}
402 "tls-dynamic-o32-ver"}
403 {"Dynamic executable with TLS and versioning (order 2)"
404 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o"
405 "-EB -march=mips1 -32 -KPIC" {}
406 {{objdump
{-dr
-m mips
:isa32r2
} tlsdyn
-o32
-2.d
} {objdump
-Rsj.got tlsdyn
-o32
-2.got
}}
407 "tls-dynamic-o32-ver-2"}
408 {"Dynamic executable with TLS and versioning (order 3)"
409 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o"
410 "-EB -march=mips1 -32 -KPIC" {}
411 {{objdump
{-dr
-m mips
:isa32r2
} tlsdyn
-o32
-3.d
} {objdump
-Rsj.got tlsdyn
-o32
-3.got
}}
412 "tls-dynamic-o32-ver-3"}
413 {"Shared library with TLS and hidden symbols"
414 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver"
415 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
416 {{objdump
{-dr
-m mips
:isa32r2
} tlslib
-o32.d
} {objdump
-Rsj.got tlslib
-o32
-hidden.got
}}
417 "tlslib-o32-hidden.so"}
418 {"Shared library with TLS and hidden symbols (2)"
419 "-shared -melf32btsmip -T mips-lib.ld"
420 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
421 {{objdump
-drj.
text tls
-hidden2.d
} {objdump
-sj.got tls
-hidden2
-got.d
}}
423 {"Shared library with TLS and hidden symbols (3)"
424 "-shared -melf32btsmip -T tls-hidden3.ld"
425 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
426 {{objdump
-dj.
text tls
-hidden3.d
} {objdump
-sj.got tls
-hidden3.got
}
427 {readelf
--relocs tls
-hidden3.r
}}
429 {"Shared library with TLS and hidden symbols (4)"
430 "-shared -melf32btsmip -T tls-hidden3.ld"
431 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
432 {{objdump
-sj.got tls
-hidden4.got
} {readelf
--relocs tls
-hidden4.r
}}
436 if {[istarget mips
*-*-linux
*]} {
437 run_ld_link_tests $mips_tls_tests
440 set mips16_call_global_test
[list \
441 [list
"Global calls from mips16" \
443 "$o32_as_flags -mips32r2" \
444 {mips16
-call-global
-1.s mips16
-call-global
-2.s mips16
-call-global
-3.s
} \
445 {{objdump
-dr mips16
-call-global.d
}} \
446 "mips16-call-global"]]
448 run_ld_link_tests $mips16_call_global_test
450 set mips16_intermix_test
[list \
451 [list
"Intermixing mips32 and mips16 functions" \
453 "$o32_as_flags -mips32r2" \
454 {mips16
-intermix
-1.s mips16
-intermix
-2.s
} \
455 {{objdump
-t mips16
-intermix.d
}} \
458 run_ld_link_tests $mips16_intermix_test
460 run_dump_test
"mips16-local-stubs-1"
462 run_dump_test
"attr-gnu-4-00"
463 run_dump_test
"attr-gnu-4-01"
464 run_dump_test
"attr-gnu-4-02"
465 run_dump_test
"attr-gnu-4-03"
466 run_dump_test
"attr-gnu-4-04"
467 run_dump_test
"attr-gnu-4-05"
468 run_dump_test
"attr-gnu-4-10"
469 run_dump_test
"attr-gnu-4-11"
470 run_dump_test
"attr-gnu-4-12"
471 run_dump_test
"attr-gnu-4-13"
472 run_dump_test
"attr-gnu-4-14"
473 run_dump_test
"attr-gnu-4-15"
474 run_dump_test
"attr-gnu-4-20"
475 run_dump_test
"attr-gnu-4-21"
476 run_dump_test
"attr-gnu-4-22"
477 run_dump_test
"attr-gnu-4-23"
478 run_dump_test
"attr-gnu-4-24"
479 run_dump_test
"attr-gnu-4-25"
480 run_dump_test
"attr-gnu-4-30"
481 run_dump_test
"attr-gnu-4-31"
482 run_dump_test
"attr-gnu-4-32"
483 run_dump_test
"attr-gnu-4-33"
484 run_dump_test
"attr-gnu-4-34"
485 run_dump_test
"attr-gnu-4-35"
486 run_dump_test
"attr-gnu-4-40"
487 run_dump_test
"attr-gnu-4-41"
488 run_dump_test
"attr-gnu-4-42"
489 run_dump_test
"attr-gnu-4-43"
490 run_dump_test
"attr-gnu-4-44"
491 run_dump_test
"attr-gnu-4-45"
492 run_dump_test
"attr-gnu-4-51"
496 {"GOT and versioning 1"
497 "-shared -melf32btsmip --version-script got-vers-1.ver"
498 "-EB -mips2 -32" {got-vers-1a.s got-vers-1b.s}
499 {{readelf
-d got
-vers
-1.dd
}
500 {readelf
--symbols got
-vers
-1.sd
}
501 {readelf
--relocs got
-vers
-1.rd
}}