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 # Check MIPS16 markings being passed through link.
61 run_dump_test "mips16-1"
63 # MIPS branch offset final link checking.
64 run_dump_test "branch-misc-1"
66 # Test multi-got link. We only do this on GNU/Linux because it requires
67 # the "traditional" emulations.
69 run_dump_test "multi-got-1"
70 run_dump_test "multi-got-no-shared"
74 run_dump_test "elf-rel-got-n32"
75 run_dump_test "elf-rel-xgot-n32"
77 run_dump_test "elf-rel-got-n64-linux"
78 run_dump_test "elf-rel-xgot-n64-linux"
80 run_dump_test "elf-rel-got-n64"
81 run_dump_test "elf-rel-xgot-n64"
84 run_dump_test "relax-jalr-n32"
85 run_dump_test "relax-jalr-n32-shared"
86 run_dump_test "relax-jalr-n64"
87 run_dump_test "relax-jalr-n64-shared"
91 run_dump_test "rel32-o32"
92 run_dump_test "rel32-n32"
96 if { $embedded_elf } {
97 run_dump_test "region1"
101 # This could work on other targets too, but would need the appropriate
103 run_dump_test "reloc-1-rel"
106 run_dump_test "reloc-1-n32"
108 # Uses a linux-specific ld -m switch
109 run_dump_test "reloc-1-n64"
112 run_dump_test "reloc-2"
113 run_dump_test "reloc-merge-lo16"
114 run_dump_test "reloc-3"
116 run_dump_test "reloc-3-n32"
118 run_dump_test "reloc-4"
119 run_dump_test "reloc-5"
121 if {$has_newabi && $linux_gnu} {
122 run_dump_test "eh-frame1-n32"
123 run_dump_test "eh-frame1-n64"
124 run_dump_test "eh-frame2-n32"
125 run_dump_test "eh-frame2-n64"
128 run_dump_test "eh-frame3"
129 run_dump_test "eh-frame4"
132 run_dump_test "jaloverflow"
133 run_dump_test "jaloverflow-2"
135 run_dump_test "jalbal"
138 run_dump_test "mips16-hilo"
140 run_dump_test "mips16-hilo-n32"
144 run_dump_test "textrel-1"
148 run_dump_test "emit-relocs-1"
151 run_dump_test "hash1a"
152 run_dump_test "hash1b"
153 run_dump_test "hash1c"
155 if {[istarget mips*-*-linux*]} {
156 # The number of symbols that are always included in the symbol table
157 # for these tests. The 4 are:
159 # the null symbol entry
160 # the .MIPS.stubs section symbol
162 # _GLOBAL_OFFSET_TABLE_
164 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
167 "Stub for dynsym 0x$dynsym" \
168 "-shared -melf32btsmip -T stub-dynsym-1.ld" \
170 "-EB -march=mips1 -32 -KPIC" \
171 "--defsym base_syms=$base_syms" \
172 "--defsym dynsym=0x$dynsym"] \
173 [list "stub-dynsym-1.s"] \
176 "stub-dynsym-1-$dynsym.d"]] \
177 "stub-dynsym-1-$dynsym"]]
181 # For tests which may involve multiple files, use run_ld_link_tests.
183 # List contains test-items with 3 items followed by 2 lists:
184 # 0:name 1:ld options 2:assembler options
185 # 3:filenames of assembler files 4: action and options. 5: name of output file
188 # objdump: Apply objdump options on result. Compare with regex (last arg).
189 # nm: Apply nm options on result. Compare with regex (last arg).
190 # readelf: Apply readelf options on result. Compare with regex (last arg).
193 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld"
194 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
195 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
197 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld"
198 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
199 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
201 {"Dynamic executable with TLS"
202 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so"
203 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
204 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
206 {"Shared library with multiple GOTs and TLS"
207 "-shared -melf32btsmip -T mips-lib.ld"
208 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
209 {{readelf {-d -r} tls-multi-got-1.r}
210 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
211 {objdump -Rsj.got tls-multi-got-1.got}}
213 {"Shared library with TLS and versioning"
214 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver"
215 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
216 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
218 {"Dynamic executable with TLS and versioning"
219 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so"
220 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
221 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
222 "tls-dynamic-o32-ver"}
223 {"Dynamic executable with TLS and versioning (order 2)"
224 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o"
225 "-EB -march=mips1 -32 -KPIC" {}
226 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
227 "tls-dynamic-o32-ver-2"}
228 {"Dynamic executable with TLS and versioning (order 3)"
229 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o"
230 "-EB -march=mips1 -32 -KPIC" {}
231 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
232 "tls-dynamic-o32-ver-3"}
233 {"Shared library with TLS and hidden symbols"
234 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver"
235 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
236 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
237 "tlslib-o32-hidden.so"}
238 {"Shared library with TLS and hidden symbols (2)"
239 "-shared -melf32btsmip -T mips-lib.ld"
240 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
241 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
243 {"Shared library with TLS and hidden symbols (3)"
244 "-shared -melf32btsmip -T tls-hidden3.ld"
245 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
246 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
247 {readelf --relocs tls-hidden3.r}}
249 {"Shared library with TLS and hidden symbols (4)"
250 "-shared -melf32btsmip -T tls-hidden3.ld"
251 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
252 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
256 if {[istarget mips*-*-linux*]} {
257 run_ld_link_tests $mips_tls_tests
260 set mips16_call_global_test {
261 {"Global calls from mips16"
263 "-mips32r2" {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s}
264 {{objdump -dr mips16-call-global.d}}
265 "mips16-call-global"}
268 run_ld_link_tests $mips16_call_global_test
270 set mips16_intermix_test {
271 {"Intermixing mips32 and mips16 functions"
273 "-mips32r2" {mips16-intermix-1.s mips16-intermix-2.s}
274 {{objdump -t mips16-intermix.d}}
278 run_ld_link_tests $mips16_intermix_test
280 run_dump_test "mips16-local-stubs-1"
282 run_dump_test "attr-gnu-4-00"
283 run_dump_test "attr-gnu-4-01"
284 run_dump_test "attr-gnu-4-02"
285 run_dump_test "attr-gnu-4-03"
286 run_dump_test "attr-gnu-4-10"
287 run_dump_test "attr-gnu-4-11"
288 run_dump_test "attr-gnu-4-12"
289 run_dump_test "attr-gnu-4-13"
290 run_dump_test "attr-gnu-4-14"
291 run_dump_test "attr-gnu-4-20"
292 run_dump_test "attr-gnu-4-21"
293 run_dump_test "attr-gnu-4-22"
294 run_dump_test "attr-gnu-4-23"
295 run_dump_test "attr-gnu-4-30"
296 run_dump_test "attr-gnu-4-31"
297 run_dump_test "attr-gnu-4-32"
298 run_dump_test "attr-gnu-4-33"
299 run_dump_test "attr-gnu-4-41"