Commit | Line | Data |
---|---|---|
37e55690 | 1 | # Expect script for ld-i386 tests |
5a68afcf | 2 | # Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2012 |
aa820537 | 3 | # Free Software Foundation |
37e55690 | 4 | # |
f96b4a7b NC |
5 | # This file is part of the GNU Binutils. |
6 | # | |
7 | # This program is free software; you can redistribute it and/or modify | |
37e55690 | 8 | # it under the terms of the GNU General Public License as published by |
f96b4a7b | 9 | # the Free Software Foundation; either version 3 of the License, or |
37e55690 JJ |
10 | # (at your option) any later version. |
11 | # | |
12 | # This program is distributed in the hope that it will be useful, | |
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | # GNU General Public License for more details. | |
16 | # | |
17 | # You should have received a copy of the GNU General Public License | |
18 | # along with this program; if not, write to the Free Software | |
f96b4a7b NC |
19 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 | # MA 02110-1301, USA. | |
37e55690 JJ |
21 | # |
22 | ||
23 | # Test i386 linking; all types of relocs. This tests the assembler and | |
24 | # tools like objdump as well as the linker. | |
25 | ||
b9201bb3 RS |
26 | if {[istarget "i?86-*-vxworks"]} { |
27 | set i386tests { | |
28 | {"VxWorks shared library test 1" "-shared -Tvxworks1.ld" | |
29 | "" {vxworks1-lib.s} | |
711de32c | 30 | {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd} |
e68ed250 | 31 | {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}} |
b9201bb3 | 32 | "libvxworks1.so"} |
4f471f39 RS |
33 | {"VxWorks executable test 1 (dynamic)" \ |
34 | "tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic" | |
35 | "" {vxworks1.s} | |
b9201bb3 RS |
36 | {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}} |
37 | "vxworks1"} | |
4f471f39 RS |
38 | {"VxWorks executable test 2 (dynamic)" \ |
39 | "-Tvxworks1.ld -q --force-dynamic" | |
40 | "" {vxworks2.s} | |
41 | {{readelf --segments vxworks2.sd}} | |
42 | "vxworks2"} | |
43 | {"VxWorks executable test 2 (static)" | |
44 | "-Tvxworks1.ld" | |
45 | "" {vxworks2.s} | |
46 | {{readelf --segments vxworks2-static.sd}} | |
47 | "vxworks2"} | |
b9201bb3 RS |
48 | } |
49 | run_ld_link_tests $i386tests | |
4f471f39 | 50 | run_dump_test "vxworks1-static" |
b9201bb3 RS |
51 | } |
52 | ||
e39e47bd JK |
53 | if [istarget "*-*-go32*"] { |
54 | run_ld_link_tests {{"go32 stub" "" "" {zero.s} {} "go32stub"}} | |
55 | ||
56 | set src "tmpdir/go32stub" | |
57 | set dest "tmpdir/go32stub-copy" | |
58 | ||
59 | set test "go32 stub patch the source" | |
60 | set fi [open $src r+] | |
61 | fconfigure $fi -translation binary | |
62 | if {[read $fi 2] != "MZ"} { | |
63 | fail $test | |
64 | } else { | |
65 | pass $test | |
66 | seek $fi 0x40 | |
67 | puts -nonewline $fi "objcopy-test-go32stub" | |
68 | } | |
69 | close $fi | |
70 | ||
71 | set test "go32 stub objcopy" | |
72 | set status [remote_exec build $OBJCOPY "$OBJCOPYFLAGS $src $dest"] | |
73 | set exec_output [lindex $status 1] | |
74 | set exec_output [prune_warnings $exec_output] | |
75 | if [string match "" $exec_output] then { | |
76 | pass $test | |
77 | } else { | |
78 | send_log "$exec_output\n" | |
79 | verbose "$exec_output" 1 | |
80 | fail $test | |
81 | } | |
82 | ||
83 | # cmp would compare the whole files and some data after the initial exe | |
84 | # stub could differ. | |
85 | set test "go32 stub comparison after objcopy" | |
86 | set fi [open $src] | |
87 | fconfigure $fi -translation binary | |
88 | set src_stub [read $fi 2048] | |
89 | close $fi | |
90 | set fi [open $dest] | |
91 | fconfigure $fi -translation binary | |
92 | set dest_stub [read $fi 2048] | |
93 | close $fi | |
94 | if {$src_stub == $dest_stub} { | |
95 | pass $test | |
96 | } else { | |
97 | fail $test | |
98 | } | |
99 | } | |
100 | ||
5a68afcf | 101 | if { !([istarget "i?86-*-elf*"] |
99753d9d AM |
102 | || (([istarget "i?86-*-linux*"] |
103 | || [istarget "i?86-*-gnu*"]) | |
c7749bd6 | 104 | && ![istarget "*-*-*aout*"] |
67a4f2b7 | 105 | && ![istarget "*-*-*oldld*"]) |
5a68afcf RM |
106 | || [istarget "i?86-*-nacl*"] |
107 | || [istarget "x86_64-*-nacl*"] | |
67a4f2b7 AO |
108 | || [istarget "x86_64-*-linux*"] |
109 | || [istarget "amd64-*-linux*"]) } { | |
37e55690 JJ |
110 | return |
111 | } | |
112 | ||
37e55690 JJ |
113 | # List contains test-items with 3 items followed by 2 lists: |
114 | # 0:name 1:ld options 2:assembler options | |
115 | # 3:filenames of assembler files 4: action and options. 5: name of output file | |
116 | ||
117 | # Actions: | |
118 | # objdump: Apply objdump options on result. Compare with regex (last arg). | |
119 | # nm: Apply nm options on result. Compare with regex (last arg). | |
120 | # readelf: Apply readelf options on result. Compare with regex (last arg). | |
121 | ||
122 | set i386tests { | |
5a68afcf RM |
123 | {"Helper shared library (basic PLT test)" |
124 | "-shared -melf_i386" "--32" {pltlib.s} {} "libpltlib.so"} | |
125 | {"basic PLT generation (non-PIC)" | |
126 | "-melf_i386 tmpdir/libpltlib.so" "--32" {plt.s} | |
127 | {{objdump -drj.plt plt.pd}} "plt"} | |
128 | {"basic PLT generation (PIC)" | |
129 | "-shared -melf_i386 tmpdir/libpltlib.so" "--32" {plt-pic.s} | |
130 | {{objdump -drj.plt plt-pic.pd}} "libplt-pic.so"} | |
e41b3a13 JJ |
131 | {"TLS -fpic -shared transitions" |
132 | "-shared -melf_i386 --no-ld-generated-unwind-info" | |
37e55690 JJ |
133 | "--32" {tlspic1.s tlspic2.s} |
134 | {{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd} | |
135 | {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}} | |
136 | "libtlspic.so"} | |
e41b3a13 JJ |
137 | {"TLS descriptor -fpic -shared transitions" |
138 | "-shared -melf_i386 --no-ld-generated-unwind-info" | |
67a4f2b7 AO |
139 | "--32" {tlsdesc.s tlspic2.s} |
140 | {{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd} | |
141 | {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}} | |
142 | "libtlsdesc.so"} | |
37e55690 JJ |
143 | {"Helper shared library" "-shared -melf_i386" |
144 | "--32" {tlslib.s} {} "libtlslib.so"} | |
145 | {"TLS -fpic and -fno-pic exec transitions" | |
e41b3a13 JJ |
146 | "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info" |
147 | "--32" {tlsbinpic.s tlsbin.s} | |
37e55690 JJ |
148 | {{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd} |
149 | {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}} | |
150 | "tlsbin"} | |
67a4f2b7 | 151 | {"TLS descriptor -fpic and -fno-pic exec transitions" |
e41b3a13 JJ |
152 | "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info" |
153 | "--32" {tlsbindesc.s tlsbin.s} | |
67a4f2b7 AO |
154 | {{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd} |
155 | {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}} | |
156 | "tlsbindesc"} | |
e41b3a13 | 157 | {"TLS -fno-pic -shared" "-shared -melf_i386 --no-ld-generated-unwind-info" |
37e55690 JJ |
158 | "--32" {tlsnopic1.s tlsnopic2.s} |
159 | {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd} | |
160 | {objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"} | |
67a4f2b7 | 161 | {"TLS with global dynamic and descriptors" |
e41b3a13 JJ |
162 | "-shared -melf_i386 --no-ld-generated-unwind-info" |
163 | "--32" {tlsgdesc.s} | |
67a4f2b7 AO |
164 | {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}} |
165 | "libtlsgdesc.so"} | |
a45bb67d JJ |
166 | {"TLS in debug sections" "-melf_i386" |
167 | "--32" {tlsg.s} | |
168 | {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"} | |
7c445aa3 JJ |
169 | {"TLS @indntpoff with %eax" "-melf_i386" "--32" {tlsindntpoff.s} |
170 | {{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"} | |
4565652e AM |
171 | {"Reloc section order" "-shared -melf_i386 -z nocombreloc" "--32" |
172 | {reloc.s} {{objdump -hw reloc.d}} "reloc.so"} | |
5ae0bfb6 | 173 | {"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "--32" |
5a68afcf | 174 | {emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"} |
2030e6d7 JJ |
175 | {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc" |
176 | "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"} | |
a3fadc9a L |
177 | {"TLS GD->LE transition" "-melf_i386" |
178 | "--32" {tlsgd1.s} | |
179 | {{objdump -dwr tlsgd1.dd}} "tlsgd1"} | |
180 | {"TLS LD->LE transition" "-melf_i386" | |
181 | "--32" {tlsld1.s} | |
182 | {{objdump -dwr tlsld1.dd}} "tlsld1"} | |
dd1093aa L |
183 | {"TLS IE->LE transition" "-melf_i386" |
184 | "--32" {tlsie1.s} | |
185 | {{objdump -dwr tlsie1.dd}} "tlsie1"} | |
37e55690 JJ |
186 | } |
187 | ||
5a68afcf RM |
188 | # So as to avoid rewriting every last test case here in a nacl variant, |
189 | # we use black magic to massage the generic cases into nacl-variant cases. | |
190 | if [istarget "*-*-nacl*"] { | |
191 | # Change all the -melf_i386 to -melf_i386_nacl so linking can succeed. | |
192 | regsub -all elf_i386 $i386tests elf_i386_nacl i386tests | |
193 | ||
194 | # Same, applied to all the run_dump_test cases. | |
195 | set options_regsub(ld) {-melf_i386 -melf_i386_nacl} | |
196 | ||
197 | # The section/segment layout differs too much for the vanilla | |
198 | # readelf output files to match. So massage the cases so that | |
199 | # they refer to a foo-nacl.rd file instead of a foo.rd file. | |
200 | regsub -all {([a-z0-9]+)\.rd} $i386tests {\1-nacl.rd} i386tests | |
201 | ||
202 | # Likewise for PLTs. | |
203 | regsub -all -- {([a-z0-9]+)\.pd} $i386tests {\1-nacl.pd} i386tests | |
204 | } | |
205 | ||
37e55690 | 206 | run_ld_link_tests $i386tests |
ac2aa337 JB |
207 | |
208 | run_dump_test "abs" | |
209 | run_dump_test "pcrel8" | |
210 | run_dump_test "pcrel16" | |
ab96bf03 | 211 | run_dump_test "pcrel16abs" |
0920dee7 | 212 | run_dump_test "alloc" |
9267588c | 213 | run_dump_test "warn1" |
4c544807 | 214 | run_dump_test "tlsgd2" |
dd1093aa L |
215 | run_dump_test "tlsie2" |
216 | run_dump_test "tlsie3" | |
217 | run_dump_test "tlsie4" | |
218 | run_dump_test "tlsie5" | |
41bed6dd L |
219 | run_dump_test "hidden1" |
220 | run_dump_test "hidden2" | |
221 | run_dump_test "hidden3" | |
222 | run_dump_test "protected1" | |
223 | run_dump_test "protected2" | |
224 | run_dump_test "protected3" | |
bdb892b9 L |
225 | run_dump_test "protected4" |
226 | run_dump_test "protected5" | |
1d85728f | 227 | run_dump_test "tlspie1" |
959b0961 | 228 | run_dump_test "tlspie2" |
a7b16ceb | 229 | run_dump_test "nogot1" |
0629d0af | 230 | run_dump_test "nogot2" |
56d4289c | 231 | run_dump_test "discarded1" |
2abca860 | 232 | run_dump_test "pr12718" |
a81aeffc | 233 | run_dump_test "pr12921" |
2fe0fd06 L |
234 | run_dump_test "pr12570a" |
235 | run_dump_test "pr12570b" | |
25d17eb4 L |
236 | |
237 | if { !([istarget "i?86-*-linux*"] | |
5940a93c | 238 | || [istarget "i?86-*-gnu*"] |
5a68afcf RM |
239 | || [istarget "i?86-*-nacl*"] |
240 | || [istarget "x86_64-*-nacl*"] | |
25d17eb4 L |
241 | || [istarget "x86_64-*-linux*"]) } { |
242 | return | |
243 | } | |
244 | ||
245 | run_dump_test "compressed1" | |
a3293649 | 246 | run_dump_test "pr12627" |
98920172 | 247 | run_dump_test "pr13302" |
17d6eea5 | 248 | run_dump_test "pr14215" |