* lib/ld-lib.exp (run_ld_link_tests): Add another argument, pass
[deliverable/binutils-gdb.git] / ld / testsuite / ld-x86-64 / x86-64.exp
CommitLineData
bffbf940 1# Expect script for ld-x86_64 tests
5a68afcf 2# Copyright (C) 2002, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
889a4d3e 3# Free Software Foundation
bffbf940 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
bffbf940 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
bffbf940
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.
bffbf940
JJ
21#
22
23# Test x86_64 linking; all types of relocs. This tests the assembler and
24# tools like objdump as well as the linker.
25
26if { !([istarget "x86_64-*-elf*"]
5a68afcf 27 || [istarget "x86_64-*-nacl*"]
bffbf940
JJ
28 || [istarget "x86_64-*-linux*"]) } {
29 return
30}
31
5a68afcf
RM
32if [istarget "*-*-nacl*"] {
33 set emul "elf_x86_64_nacl"
34} else {
35 set emul "elf_x86_64"
36}
37
bffbf940 38# List contains test-items with 3 items followed by 2 lists:
897aea50
MR
39# 0:name 1:ld early options 2:ld late options 3:assembler options
40# 4:filenames of assembler files 5: action and options. 6: name of output file
bffbf940
JJ
41
42# Actions:
43# objdump: Apply objdump options on result. Compare with regex (last arg).
44# nm: Apply nm options on result. Compare with regex (last arg).
45# readelf: Apply readelf options on result. Compare with regex (last arg).
46
47set x86_64tests {
5a68afcf 48 {"Helper shared library (basic PLT test)"
897aea50 49 "-shared -melf_x86_64" "" "--64" {pltlib.s} {} "libpltlib.so"}
5a68afcf 50 {"basic PLT generation"
897aea50 51 "-melf_x86_64 tmpdir/libpltlib.so" "" "--64" {plt.s}
5a68afcf 52 {{objdump -drj.plt plt.pd}} "plt"}
e41b3a13 53 {"TLS -fpic -shared transitions"
897aea50 54 "-shared -melf_x86_64 --no-ld-generated-unwind-info" ""
bffbf940
JJ
55 "--64" {tlspic1.s tlspic2.s}
56 {{readelf -WSsrl tlspic.rd} {objdump -drj.text tlspic.dd}
57 {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
58 "libtlspic.so"}
e41b3a13 59 {"TLS descriptor -fpic -shared transitions"
897aea50 60 "-shared -melf_x86_64 --no-ld-generated-unwind-info" ""
67a4f2b7
AO
61 "--64" {tlsdesc.s tlspic2.s}
62 {{readelf -WSsrld tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
63 {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}
64 {objdump -drj.plt tlsdesc.pd}} "libtlsdesc.so"}
897aea50 65 {"Helper shared library" "-shared -melf_x86_64" ""
bffbf940
JJ
66 "--64" {tlslib.s} {} "libtlslib.so"}
67 {"TLS -fpic and -fno-pic exec transitions"
897aea50 68 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info" ""
e41b3a13 69 "--64" {tlsbinpic.s tlsbin.s}
bffbf940
JJ
70 {{readelf -WSsrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
71 {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
72 "tlsbin"}
67a4f2b7 73 {"TLS descriptor -fpic and -fno-pic exec transitions"
897aea50 74 "-melf_x86_64 tmpdir/libtlslib.so --no-ld-generated-unwind-info" ""
e41b3a13 75 "--64" {tlsbindesc.s tlsbin.s}
67a4f2b7
AO
76 {{readelf -WSsrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
77 {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
78 "tlsbindesc"}
79 {"TLS with global dynamic and descriptors"
897aea50 80 "-shared -melf_x86_64 --no-ld-generated-unwind-info" ""
e41b3a13 81 "--64" {tlsgdesc.s}
67a4f2b7
AO
82 {{readelf -WSsrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
83 "libtlsgdesc.so"}
897aea50 84 {"TLS in debug sections" "-melf_x86_64" ""
a45bb67d
JJ
85 "--64" {tlsg.s}
86 {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
897aea50 87 {"TLS GD->LE transition" "-melf_x86_64" ""
a3fadc9a
L
88 "--64" {tlsgd1.s}
89 {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
897aea50 90 {"TLS LD->LE transition" "-melf_x86_64" ""
a3fadc9a
L
91 "--64" {tlsld1.s}
92 {{objdump -dwr tlsld1.dd}} "tlsld1"}
897aea50 93 {"TLS IE->LE transition" "-melf_x86_64" ""
dd1093aa
L
94 "--64" {tlsie1.s}
95 {{objdump -dwr tlsie1.dd}} "tlsie1"}
897aea50 96 {"Helper 64bit object 1" "-r -melf_x86_64" ""
39334f3a 97 "--64" {mixed1a.s} {} "libmixe1a.o"}
897aea50 98 {"Helper 32bit object 1" "-r -melf_i386" ""
39334f3a 99 "--32" {mixed1b.s} {} "libmixe1b.o"}
897aea50 100 {"Helper 64bit object 2" "-r -melf_x86_64" ""
39334f3a 101 "--64" {mixed2a.s} {} "libmixe2a.o"}
897aea50 102 {"Helper 32bit object 2" "-r -melf_i386" ""
39334f3a 103 "--32" {mixed2b.s} {} "libmixe2b.o"}
897aea50
MR
104 {"Split by file with 'l' flag on section."
105 "-split-by-file -r -melf_x86_64" ""
3dbcc61d
NC
106 "--64" {split-by-file1.s split-by-file2.s}
107 {{readelf -SW split-by-file.rd}} "split-by-file.o"}
897aea50 108 {"TLS X32 IE->LE transition" "-melf32_x86_64" ""
4a4c5f25
L
109 "--x32" {tlsie4.s}
110 {{objdump -dwr tlsie4.dd}} "tlsie4"}
897aea50 111 {"TLS X32 GD->LE transition" "-melf32_x86_64" ""
52bc799a
L
112 "--x32" {tlsgd4.s}
113 {{objdump -dwr tlsgd4.dd}} "tlsgd4"}
897aea50 114 {"Helper TLS GD->IE transition DSO" "-shared -melf_x86_64" ""
52bc799a 115 "--64" {tlsgd5b.s} {} "libtlsgd5.so"}
897aea50 116 {"TLS GD->IE transition" "-melf_x86_64 tmpdir/libtlsgd5.so" ""
52bc799a
L
117 "--64" {tlsgd5a.s}
118 {{objdump -dwr tlsgd5.dd}} "tlsgd5"}
897aea50 119 {"Helper TLS X32 GD->IE transition DSO" "-shared -melf32_x86_64" ""
52bc799a 120 "--x32" {tlsgd6b.s} {} "libtlsgd6.so"}
897aea50 121 {"TLS X32 GD->IE transition" "-melf32_x86_64 tmpdir/libtlsgd6.so" ""
52bc799a
L
122 "--x32" {tlsgd6a.s}
123 {{objdump -dwr tlsgd6.dd}} "tlsgd6"}
897aea50 124 {"TLS X32 LD->LE transition" "-melf32_x86_64" ""
52bc799a
L
125 "--x32" {tlsld2.s}
126 {{objdump -dwr tlsld2.dd}} "tlsld2"}
5a68afcf 127
897aea50
MR
128 {"build 32-bit object with 33 locals" "-melf_x86_64 -e 0" "" "--32" {32bit.s} {{ ld incompatible.l }} "dummy" }
129 {"build 64-bit object" "-melf_x86_64 -e 0 --defsym foo=1" "" "--64" {64bit.s} {} "dummy" }
130 {"link mixed objects" "-melf_x86_64 -e 0 tmpdir/32bit.o tmpdir/64bit.o" "" "" {} { { ld incompatible.l } } "mixed"}
5a68afcf
RM
131}
132
133# So as to avoid rewriting every last test case here in a nacl variant,
134# we use black magic to massage the generic cases into nacl-variant cases.
135if [istarget "*-*-nacl*"] {
136 set emul elf_x86_64_nacl
137
138 set lhs {elf(32)?_(i386|x86_64)[[:>:]]}
139 set rhs {&_nacl}
140
141 # Change all the -melf_x86_64 to -melf_x86_64_nacl so linking can succeed.
142 regsub -all -- $lhs $x86_64tests $rhs x86_64tests
143
144 # Same, applied to all the run_dump_test cases.
145 set options_regsub(ld) [list $lhs $rhs]
146
147 # The section/segment layout differs too much for the vanilla
148 # readelf output files to match. So massage the cases so that
149 # they refer to a foo-nacl.rd file instead of a foo.rd file.
150 regsub -all -- {([a-z0-9]+)\.rd} $x86_64tests {\1-nacl.rd} x86_64tests
151
152 # Likewise for PLTs.
153 regsub -all -- {([a-z0-9]+)\.pd} $x86_64tests {\1-nacl.pd} x86_64tests
154} else {
155 set emul elf_x86_64
bffbf940
JJ
156}
157
158run_ld_link_tests $x86_64tests
ac2aa337 159
39334f3a
L
160global link_output
161global ld
162
b51176f1 163set test_name "Mixed x86_64 and i386 input test 1"
39334f3a 164set test mixed1
5a68afcf 165if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
39334f3a 166 if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] {
5a68afcf 167 pass "$test_name"
39334f3a 168 } {
5a68afcf 169 fail "$test_name"
39334f3a
L
170 }
171}
172
b51176f1 173set test_name "Mixed x86_64 and i386 input test 2"
39334f3a 174set test mixed2
5a68afcf 175if { ![ld_simple_link $ld tmpdir/$test "-m$emul tmpdir/${test}a.o tmpdir/${test}b.o"] } {
39334f3a 176 if [string match "*i386 architecture of input file `tmpdir/${test}b.o' is incompatible with i386:x86-64 output*" $link_output] {
5a68afcf 177 pass "$test_name"
39334f3a 178 } {
5a68afcf 179 fail "$test_name"
39334f3a
L
180 }
181}
182
ac2aa337 183run_dump_test "abs"
8a9036a4 184run_dump_test "abs-l1om"
ac2aa337
JB
185run_dump_test "pcrel8"
186run_dump_test "pcrel16"
dd1093aa
L
187run_dump_test "tlsgd2"
188run_dump_test "tlsgd3"
189run_dump_test "tlsie2"
190run_dump_test "tlsie3"
41bed6dd
L
191run_dump_test "hidden1"
192run_dump_test "hidden2"
193run_dump_test "hidden3"
194run_dump_test "protected1"
195run_dump_test "protected2"
8a9036a4 196run_dump_test "protected2-l1om"
41bed6dd 197run_dump_test "protected3"
8a9036a4 198run_dump_test "protected3-l1om"
bdb892b9
L
199run_dump_test "protected4"
200run_dump_test "protected5"
9b769489 201run_dump_test "tlsle1"
1d85728f 202run_dump_test "tlspie1"
6f8bcf84 203run_dump_test "unique1"
a7b16ceb 204run_dump_test "nogot1"
0629d0af 205run_dump_test "nogot2"
56d4289c 206run_dump_test "discarded1"
2abca860 207run_dump_test "pr12718"
a81aeffc 208run_dump_test "pr12921"
aed64b35 209run_dump_test "pr13947"
2fe0fd06
L
210run_dump_test "pr12570a"
211run_dump_test "pr12570b"
17d6eea5 212run_dump_test "pr14215"
8981c88a 213run_dump_test "pr14207"
25d17eb4 214
5a68afcf 215if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
25d17eb4
L
216 return
217}
218
5a68afcf 219if ![ld_assemble $as "--x32 $srcdir/$subdir/start.s" tmpdir/startx32.o] {
889a4d3e
L
220 unresolved "Build ILP32 start.o"
221 return
222}
223
5a68afcf 224if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
889a4d3e
L
225 unresolved "Build ia32 start.o"
226 return
227}
228
5a68afcf 229if ![ld_assemble $as "--64 $srcdir/$subdir/start.s" tmpdir/start64.o] {
889a4d3e
L
230 unresolved "Build LP64 start.o"
231 return
232}
233
5a68afcf 234if ![ld_assemble $as "--x32 $srcdir/$subdir/foo.s" tmpdir/foox32.o] {
889a4d3e
L
235 unresolved "Build ILP32 foo.o"
236 return
237}
238
5a68afcf 239if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
889a4d3e
L
240 unresolved "Build ia32 foo.o"
241 return
242}
243
5a68afcf 244if ![ld_assemble $as "--64 $srcdir/$subdir/foo.s" tmpdir/foo64.o] {
889a4d3e
L
245 unresolved "Build LP64 foo.o"
246 return
247}
248
25d17eb4 249run_dump_test "compressed1"
889a4d3e
L
250run_dump_test "ilp32-1"
251run_dump_test "ilp32-2"
252run_dump_test "ilp32-3"
82e96e07 253run_dump_test "ilp32-4"
5a68afcf 254run_dump_test "ilp32-4-nacl"
248775ba 255run_dump_test "ilp32-5"
d7921315
L
256run_dump_test "ilp32-6"
257run_dump_test "ilp32-7"
258run_dump_test "ilp32-8"
259run_dump_test "ilp32-9"
df4f9443 260run_dump_test "ilp32-10"
8cf0d2dd 261run_dump_test "ilp32-11"
889a4d3e
L
262run_dump_test "ia32-1"
263run_dump_test "ia32-2"
264run_dump_test "ia32-3"
265run_dump_test "lp64-1"
266run_dump_test "lp64-2"
267run_dump_test "lp64-3"
64d25c44
L
268run_dump_test "pr13082-1a"
269run_dump_test "pr13082-1b"
270run_dump_test "pr13082-2a"
271run_dump_test "pr13082-2b"
272run_dump_test "pr13082-3a"
273run_dump_test "pr13082-3b"
274run_dump_test "pr13082-4a"
275run_dump_test "pr13082-4b"
276run_dump_test "pr13082-5a"
277run_dump_test "pr13082-5b"
278run_dump_test "pr13082-6a"
279run_dump_test "pr13082-6b"
80d87326
L
280run_dump_test "lea1a"
281run_dump_test "lea1b"
282run_dump_test "lea1c"
283run_dump_test "lea1d"
284run_dump_test "lea1e"
285run_dump_test "lea1f"
daa67607
L
286run_dump_test "lea1g"
287run_dump_test "lea1h"
288run_dump_test "lea1i"
289run_dump_test "lea1j"
290run_dump_test "lea1k"
291run_dump_test "lea1l"
3f65f599
L
292run_dump_test "mov1a"
293run_dump_test "mov1b"
294run_dump_test "mov1c"
295run_dump_test "mov1d"
adc7571d 296
56d4d7f2
L
297# Must be native with the C compiler
298if { [isnative] && [which $CC] != 0 } {
adc7571d
L
299 run_cc_link_tests {
300 {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g"
301 {simple.c} {} "libsimple.a"}
302 }
303
304 set convertx32 "$objcopy -O elf32-x86-64 tmpdir/simple.o tmpdir/simple-x32.o"
305 send_log "$convertx32\n"
306 set got [remote_exec host "$convertx32"]
307 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
308 send_log "$got\n"
309 fail "Convert x86-64 object to x32"
310 return
311 }
312
313 run_ld_link_tests {
314 {"X32 DSO from x86-64 object"
897aea50 315 "-shared -melf32_x86_64 tmpdir/simple-x32.o" "" "--x32"
adc7571d
L
316 {dummy.s} {{readelf {-s --wide} x86-64-x32.rd}} "x86-64-x32"}
317 }
318}
This page took 0.45777 seconds and 4 git commands to generate.