]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-mips-elf/mips-elf.exp
* ld-mips-elf/mips-elf.exp: Add test for R_MIPS16_GPREL relocations.
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-mips-elf / mips-elf.exp
1 # Expect script for MIPS ELF linker tests
2 # Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
3 #
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17 #
18
19 if {[istarget "mips*-*-vxworks"]} {
20 set mipsvxtests {
21 {"VxWorks shared library test 1" "-shared -Tvxworks1.ld"
22 "-mips2" {vxworks1-lib.s}
23 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
24 {readelf --symbols vxworks1-lib.nd}}
25 "libvxworks1.so"}
26 {"VxWorks executable test 1 (dynamic)" \
27 "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic"
28 "-mips2" {vxworks1.s}
29 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
30 "vxworks1"}
31 {"VxWorks executable test 2 (dynamic)" \
32 "-Tvxworks1.ld -q --force-dynamic"
33 "-mips2" {vxworks2.s}
34 {{readelf --segments vxworks2.sd}}
35 "vxworks2"}
36 {"VxWorks executable test 2 (static)"
37 "-Tvxworks1.ld"
38 "-mips2" {vxworks2.s}
39 {{readelf --segments vxworks2-static.sd}}
40 "vxworks2"}
41 }
42 run_ld_link_tests $mipsvxtests
43 run_dump_test "vxworks1-static"
44 return
45 }
46
47 if {![istarget mips*-*-*] || ![is_elf_format]} {
48 return
49 }
50
51 set has_newabi [expr [istarget *-*-irix6*] || [istarget mips64*-*-linux*]]
52 set linux_gnu [expr [istarget mips*-*-linux*]]
53 set embedded_elf [expr [istarget mips*-*-elf]]
54
55
56 # Check MIPS16 markings being passed through link.
57 run_dump_test "mips16-1"
58
59 # MIPS branch offset final link checking.
60 run_dump_test "branch-misc-1"
61
62 # Test multi-got link. We only do this on GNU/Linux because it requires
63 # the "traditional" emulations.
64 if { $linux_gnu } {
65 run_dump_test "multi-got-1"
66 run_dump_test "multi-got-no-shared"
67 }
68
69 if $has_newabi {
70 run_dump_test "elf-rel-got-n32"
71 run_dump_test "elf-rel-xgot-n32"
72 if { $linux_gnu } {
73 run_dump_test "elf-rel-got-n64-linux"
74 run_dump_test "elf-rel-xgot-n64-linux"
75 } else {
76 run_dump_test "elf-rel-got-n64"
77 run_dump_test "elf-rel-xgot-n64"
78 }
79
80 run_dump_test "relax-jalr-n32"
81 run_dump_test "relax-jalr-n32-shared"
82 run_dump_test "relax-jalr-n64"
83 run_dump_test "relax-jalr-n64-shared"
84 }
85
86 if { $linux_gnu } {
87 run_dump_test "rel32-o32"
88 run_dump_test "rel32-n32"
89 run_dump_test "rel64"
90 }
91
92 if { $embedded_elf } {
93 run_dump_test "region1"
94 }
95
96 if $embedded_elf {
97 # This could work on other targets too, but would need the appropriate
98 # ld -m switch.
99 run_dump_test "reloc-1-rel"
100 }
101 if $has_newabi {
102 run_dump_test "reloc-1-n32"
103 if $linux_gnu {
104 # Uses a linux-specific ld -m switch
105 run_dump_test "reloc-1-n64"
106 }
107 }
108 run_dump_test "reloc-2"
109 run_dump_test "reloc-merge-lo16"
110 run_dump_test "reloc-3"
111 if {$has_newabi} {
112 run_dump_test "reloc-3-n32"
113 }
114 if {$has_newabi && $linux_gnu} {
115 run_dump_test "eh-frame1-n32"
116 run_dump_test "eh-frame1-n64"
117 run_dump_test "eh-frame2-n32"
118 run_dump_test "eh-frame2-n64"
119 }
120 if {$embedded_elf} {
121 run_dump_test "eh-frame3"
122 run_dump_test "eh-frame4"
123 }
124
125 run_dump_test "jaloverflow"
126 run_dump_test "jaloverflow-2"
127 if {$has_newabi} {
128 run_dump_test "jalbal"
129 }
130
131 run_dump_test "mips16-hilo"
132 if {$has_newabi} {
133 run_dump_test "mips16-hilo-n32"
134 }
135
136 if { $linux_gnu } {
137 run_dump_test "textrel-1"
138 }
139
140 if $has_newabi {
141 run_dump_test "emit-relocs-1"
142 }
143
144 run_dump_test "hash1a"
145 run_dump_test "hash1b"
146 run_dump_test "hash1c"
147
148 if {[istarget mips*-*-linux*]} {
149 # The number of symbols that are always included in the symbol table
150 # for these tests. The 5 are:
151 #
152 # the null symbol entry
153 # the .MIPS.stubs section symbol
154 # the .text section symbol
155 # _gp
156 # _GLOBAL_OFFSET_TABLE_
157 set base_syms 5
158 foreach dynsym { 7fff 8000 fff0 10000 2fe80 } {
159 run_ld_link_tests \
160 [list [list \
161 "Stub for dynsym 0x$dynsym" \
162 "-shared -melf32btsmip -T stub-dynsym-1.ld" \
163 [concat \
164 "-EB -march=mips1 -32 -KPIC" \
165 "--defsym base_syms=$base_syms" \
166 "--defsym dynsym=0x$dynsym"] \
167 [list "stub-dynsym-1.s"] \
168 [list [list \
169 "objdump" "-dz" \
170 "stub-dynsym-1-$dynsym.d"]] \
171 "stub-dynsym-1-$dynsym"]]
172 }
173 }
174
175 # For tests which may involve multiple files, use run_ld_link_tests.
176
177 # List contains test-items with 3 items followed by 2 lists:
178 # 0:name 1:ld options 2:assembler options
179 # 3:filenames of assembler files 4: action and options. 5: name of output file
180
181 # Actions:
182 # objdump: Apply objdump options on result. Compare with regex (last arg).
183 # nm: Apply nm options on result. Compare with regex (last arg).
184 # readelf: Apply readelf options on result. Compare with regex (last arg).
185
186 set mips_tls_tests {
187 {"Static executable with TLS" "-static -melf32btsmip -T mips-dyn.ld"
188 "-EB -march=mips1 -32 -KPIC" {tlsbin-o32.s}
189 {{objdump {-dr -m mips:isa32r2} tlsbin-o32.d} {objdump -srj.got tlsbin-o32.got}}
190 "tls-static-o32"}
191 {"Shared library with TLS" "-shared -melf32btsmip -T mips-lib.ld"
192 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
193 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32.got}}
194 "tlslib-o32.so"}
195 {"Dynamic executable with TLS"
196 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32.so"
197 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s}
198 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32.d} {objdump -Rsj.got tlsdyn-o32.got}}
199 "tls-dynamic-o32"}
200 {"Shared library with multiple GOTs and TLS"
201 "-shared -melf32btsmip -T mips-lib.ld"
202 "-EB -march=mips1 -32 -KPIC" {tls-multi-got-1-1.s tls-multi-got-1-2.s}
203 {{readelf {-d -r} tls-multi-got-1.r}
204 {objdump {-dr -m mips:isa32r2} tls-multi-got-1.d}
205 {objdump -Rsj.got tls-multi-got-1.got}}
206 "tlslib-multi.so"}
207 {"Shared library with TLS and versioning"
208 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib.ver"
209 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
210 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-ver.got}}
211 "tlslib-o32-ver.so"}
212 {"Dynamic executable with TLS and versioning"
213 "-melf32btsmip -T mips-dyn.ld tmpdir/tlslib-o32-ver.so"
214 "-EB -march=mips1 -32 -KPIC" {tlsdyn-o32.s tlsdyn-o32-2.s}
215 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-1.d} {objdump -Rsj.got tlsdyn-o32-1.got}}
216 "tls-dynamic-o32-ver"}
217 {"Dynamic executable with TLS and versioning (order 2)"
218 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32-2.o"
219 "-EB -march=mips1 -32 -KPIC" {}
220 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-2.d} {objdump -Rsj.got tlsdyn-o32-2.got}}
221 "tls-dynamic-o32-ver-2"}
222 {"Dynamic executable with TLS and versioning (order 3)"
223 "-melf32btsmip -T mips-dyn.ld tmpdir/tlsdyn-o32-2.o tmpdir/tlslib-o32-ver.so tmpdir/tlsdyn-o32.o"
224 "-EB -march=mips1 -32 -KPIC" {}
225 {{objdump {-dr -m mips:isa32r2} tlsdyn-o32-3.d} {objdump -Rsj.got tlsdyn-o32-3.got}}
226 "tls-dynamic-o32-ver-3"}
227 {"Shared library with TLS and hidden symbols"
228 "-shared -melf32btsmip -T mips-lib.ld --version-script tlslib-hidden.ver"
229 "-EB -march=mips1 -32 -KPIC" {tlslib-o32.s}
230 {{objdump {-dr -m mips:isa32r2} tlslib-o32.d} {objdump -Rsj.got tlslib-o32-hidden.got}}
231 "tlslib-o32-hidden.so"}
232 {"Shared library with TLS and hidden symbols (2)"
233 "-shared -melf32btsmip -T mips-lib.ld"
234 "-EB -march=mips1 -32 -KPIC" {tls-hidden2a.s tls-hidden2b.s}
235 {{objdump -drj.text tls-hidden2.d} {objdump -sj.got tls-hidden2-got.d}}
236 "tls-hidden2.so"}
237 {"Shared library with TLS and hidden symbols (3)"
238 "-shared -melf32btsmip -T tls-hidden3.ld"
239 "-EB -march=mips2 -32 -KPIC" {tls-hidden3a.s tls-hidden3b.s}
240 {{objdump -dj.text tls-hidden3.d} {objdump -sj.got tls-hidden3.got}
241 {readelf --relocs tls-hidden3.r}}
242 "tls-hidden3.so"}
243 {"Shared library with TLS and hidden symbols (4)"
244 "-shared -melf32btsmip -T tls-hidden3.ld"
245 "-EB -march=mips2 -32 -KPIC" {tls-hidden4a.s tls-hidden4b.s}
246 {{objdump -sj.got tls-hidden4.got} {readelf --relocs tls-hidden4.r}}
247 "tls-hidden4.so"}
248 }
249
250 if {[istarget mips*-*-linux*]} {
251 run_ld_link_tests $mips_tls_tests
252 }
253
254 set mips16_call_global_test {
255 {"Global calls from mips16"
256 ""
257 "-mips32r2" {mips16-call-global-1.s mips16-call-global-2.s mips16-call-global-3.s}
258 {{objdump -dr mips16-call-global.d}}
259 "mips16-call-global"}
260 }
261
262 run_ld_link_tests $mips16_call_global_test