1 |
66 |
khays |
# Expect script for ld-i386 tests
|
2 |
|
|
# Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010
|
3 |
|
|
# Free Software Foundation
|
4 |
|
|
#
|
5 |
|
|
# This file is part of the GNU Binutils.
|
6 |
|
|
#
|
7 |
|
|
# This program is free software; you can redistribute it and/or modify
|
8 |
|
|
# it under the terms of the GNU General Public License as published by
|
9 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
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
|
19 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
20 |
|
|
# MA 02110-1301, USA.
|
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 |
|
|
|
26 |
|
|
if {[istarget "i?86-*-vxworks"]} {
|
27 |
|
|
set i386tests {
|
28 |
|
|
{"VxWorks shared library test 1" "-shared -Tvxworks1.ld"
|
29 |
|
|
"" {vxworks1-lib.s}
|
30 |
|
|
{{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
|
31 |
|
|
{readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
|
32 |
|
|
"libvxworks1.so"}
|
33 |
|
|
{"VxWorks executable test 1 (dynamic)" \
|
34 |
|
|
"tmpdir/libvxworks1.so -Tvxworks1.ld -q --force-dynamic"
|
35 |
|
|
"" {vxworks1.s}
|
36 |
|
|
{{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
|
37 |
|
|
"vxworks1"}
|
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"}
|
48 |
|
|
}
|
49 |
|
|
run_ld_link_tests $i386tests
|
50 |
|
|
run_dump_test "vxworks1-static"
|
51 |
|
|
}
|
52 |
|
|
|
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 |
|
|
|
101 |
|
|
if { !([istarget "i?86-*-elf*"]
|
102 |
|
|
|| (([istarget "i?86-*-linux*"]
|
103 |
|
|
|| [istarget "i?86-*-gnu*"])
|
104 |
|
|
&& ![istarget "*-*-*aout*"]
|
105 |
|
|
&& ![istarget "*-*-*oldld*"])
|
106 |
|
|
|| [istarget "x86_64-*-linux*"]
|
107 |
|
|
|| [istarget "amd64-*-linux*"]) } {
|
108 |
|
|
return
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
# List contains test-items with 3 items followed by 2 lists:
|
112 |
|
|
# 0:name 1:ld options 2:assembler options
|
113 |
|
|
# 3:filenames of assembler files 4: action and options. 5: name of output file
|
114 |
|
|
|
115 |
|
|
# Actions:
|
116 |
|
|
# objdump: Apply objdump options on result. Compare with regex (last arg).
|
117 |
|
|
# nm: Apply nm options on result. Compare with regex (last arg).
|
118 |
|
|
# readelf: Apply readelf options on result. Compare with regex (last arg).
|
119 |
|
|
|
120 |
|
|
set i386tests {
|
121 |
157 |
khays |
{"TLS -fpic -shared transitions"
|
122 |
|
|
"-shared -melf_i386 --no-ld-generated-unwind-info"
|
123 |
66 |
khays |
"--32" {tlspic1.s tlspic2.s}
|
124 |
|
|
{{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd}
|
125 |
|
|
{objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
|
126 |
|
|
"libtlspic.so"}
|
127 |
157 |
khays |
{"TLS descriptor -fpic -shared transitions"
|
128 |
|
|
"-shared -melf_i386 --no-ld-generated-unwind-info"
|
129 |
66 |
khays |
"--32" {tlsdesc.s tlspic2.s}
|
130 |
|
|
{{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
|
131 |
|
|
{objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}}
|
132 |
|
|
"libtlsdesc.so"}
|
133 |
|
|
{"Helper shared library" "-shared -melf_i386"
|
134 |
|
|
"--32" {tlslib.s} {} "libtlslib.so"}
|
135 |
|
|
{"TLS -fpic and -fno-pic exec transitions"
|
136 |
157 |
khays |
"-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info"
|
137 |
|
|
"--32" {tlsbinpic.s tlsbin.s}
|
138 |
66 |
khays |
{{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
|
139 |
|
|
{objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
|
140 |
|
|
"tlsbin"}
|
141 |
|
|
{"TLS descriptor -fpic and -fno-pic exec transitions"
|
142 |
157 |
khays |
"-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info"
|
143 |
|
|
"--32" {tlsbindesc.s tlsbin.s}
|
144 |
66 |
khays |
{{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
|
145 |
|
|
{objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
|
146 |
|
|
"tlsbindesc"}
|
147 |
157 |
khays |
{"TLS -fno-pic -shared" "-shared -melf_i386 --no-ld-generated-unwind-info"
|
148 |
66 |
khays |
"--32" {tlsnopic1.s tlsnopic2.s}
|
149 |
|
|
{{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
|
150 |
|
|
{objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"}
|
151 |
|
|
{"TLS with global dynamic and descriptors"
|
152 |
157 |
khays |
"-shared -melf_i386 --no-ld-generated-unwind-info"
|
153 |
|
|
"--32" {tlsgdesc.s}
|
154 |
66 |
khays |
{{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
|
155 |
|
|
"libtlsgdesc.so"}
|
156 |
|
|
{"TLS in debug sections" "-melf_i386"
|
157 |
|
|
"--32" {tlsg.s}
|
158 |
|
|
{{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
|
159 |
|
|
{"TLS @indntpoff with %eax" "-melf_i386" "--32" {tlsindntpoff.s}
|
160 |
|
|
{{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
|
161 |
|
|
{"Reloc section order" "-shared -melf_i386 -z nocombreloc" "--32"
|
162 |
|
|
{reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
|
163 |
|
|
{"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "--32"
|
164 |
|
|
{emit-relocs.s} {{readelf --relocs emit-relocs.d}} "emit-relocs.so"}
|
165 |
|
|
{"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc"
|
166 |
|
|
"--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
|
167 |
|
|
{"TLS GD->LE transition" "-melf_i386"
|
168 |
|
|
"--32" {tlsgd1.s}
|
169 |
|
|
{{objdump -dwr tlsgd1.dd}} "tlsgd1"}
|
170 |
|
|
{"TLS LD->LE transition" "-melf_i386"
|
171 |
|
|
"--32" {tlsld1.s}
|
172 |
|
|
{{objdump -dwr tlsld1.dd}} "tlsld1"}
|
173 |
|
|
{"TLS IE->LE transition" "-melf_i386"
|
174 |
|
|
"--32" {tlsie1.s}
|
175 |
|
|
{{objdump -dwr tlsie1.dd}} "tlsie1"}
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
run_ld_link_tests $i386tests
|
179 |
|
|
|
180 |
|
|
run_dump_test "abs"
|
181 |
|
|
run_dump_test "pcrel8"
|
182 |
|
|
run_dump_test "pcrel16"
|
183 |
|
|
run_dump_test "pcrel16abs"
|
184 |
|
|
run_dump_test "alloc"
|
185 |
|
|
run_dump_test "warn1"
|
186 |
|
|
run_dump_test "tlsgd2"
|
187 |
|
|
run_dump_test "tlsie2"
|
188 |
|
|
run_dump_test "tlsie3"
|
189 |
|
|
run_dump_test "tlsie4"
|
190 |
|
|
run_dump_test "tlsie5"
|
191 |
|
|
run_dump_test "hidden1"
|
192 |
|
|
run_dump_test "hidden2"
|
193 |
|
|
run_dump_test "hidden3"
|
194 |
|
|
run_dump_test "protected1"
|
195 |
|
|
run_dump_test "protected2"
|
196 |
|
|
run_dump_test "protected3"
|
197 |
|
|
run_dump_test "tlspie1"
|
198 |
|
|
run_dump_test "tlspie2"
|
199 |
|
|
run_dump_test "nogot1"
|
200 |
|
|
run_dump_test "nogot2"
|
201 |
|
|
run_dump_test "discarded1"
|
202 |
|
|
run_dump_test "pr12718"
|
203 |
157 |
khays |
run_dump_test "pr12921"
|
204 |
66 |
khays |
|
205 |
|
|
if { !([istarget "i?86-*-linux*"]
|
206 |
|
|
|| [istarget "i?86-*-gnu*"]
|
207 |
|
|
|| [istarget "x86_64-*-linux*"]) } {
|
208 |
|
|
return
|
209 |
|
|
}
|
210 |
|
|
|
211 |
|
|
run_dump_test "compressed1"
|
212 |
|
|
run_dump_test "pr12627"
|
213 |
163 |
khays |
run_dump_test "pr13302"
|