Revert the last change.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / binutils.exp
CommitLineData
24718e3b 1# Expect script for binutils tests
5940a93c 2# Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
24718e3b 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
24718e3b 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
24718e3b 9# (at your option) any later version.
f96b4a7b 10#
24718e3b
L
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.
f96b4a7b 15#
24718e3b
L
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
24718e3b
L
20#
21# Written by H.J. Lu (hongjiu.lu@intel.com)
22#
23
24# Make sure that binutils can correctly handle ld output in ELF.
25
5940a93c
TS
26if { ![istarget *-*-linux*]
27 && ![istarget *-*-gnu*]} {
24718e3b
L
28 return
29}
30
1224efb8
L
31if { [istarget *-*-linux*aout*]
32 || [istarget *-*-linux*oldld*] } {
33 return
34}
35
36proc binutils_test { prog_name ld_options test } {
24718e3b
L
37 global as
38 global ld
39 global READELF
1224efb8 40 global objcopy
24718e3b
L
41 global strip
42 global srcdir
43 global subdir
1224efb8
L
44 global link_output
45
46 eval set prog \$$prog_name
47 set test_name "$prog_name $ld_options ($test)"
24718e3b
L
48
49 if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } {
1224efb8 50 unresolved "$test_name"
24718e3b
L
51 return
52 }
53
54 if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
1224efb8
L
55 if { [string match "*not supported*" $link_output]
56 || [string match "*unrecognized option*" $link_output] } {
57 unsupported "$ld_options is not supported by this target"
58 } else {
59 unresolved "$test_name"
60 }
24718e3b
L
61 return
62 }
63
64 send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n"
7f6a71ff
JM
65 set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"]
66 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
24718e3b 67 send_log "$got\n"
1224efb8 68 unresolved "$test_name"
24718e3b
L
69 return
70 }
71
1224efb8 72 send_log "$prog tmpdir/$test\n"
7f6a71ff
JM
73 set got [remote_exec host "$prog tmpdir/$test"]
74 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
24718e3b 75 send_log "$got\n"
1224efb8 76 fail "$test_name"
24718e3b
L
77 return
78 }
79
80 send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n"
7f6a71ff
JM
81 set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
82 if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
24718e3b 83 send_log "$got\n"
1224efb8 84 unresolved "$test_name"
24718e3b
L
85 return
86 }
87
88 if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
89 send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
1224efb8 90 fail "$test_name"
24718e3b
L
91 return
92 }
93
1224efb8 94 pass "$test_name"
24718e3b
L
95}
96
1224efb8
L
97binutils_test strip "-z max-page-size=0x200000" maxpage1
98binutils_test strip "-z max-page-size=0x200000 -z common-page-size=0x100000" maxpage1
99binutils_test strip "-z max-page-size=0x100000" maxpage1
100binutils_test strip "-z max-page-size=0x100000 -z common-page-size=0x1000" maxpage1
101
102binutils_test strip "" maxpage1
103binutils_test strip "-shared" maxpage1
104binutils_test objcopy "" maxpage1
105binutils_test objcopy "-shared" maxpage1
106
f33cfcaa
L
107binutils_test strip "-z relro" relro1
108binutils_test strip "-z relro -shared" relro1
109binutils_test objcopy "-z relro" relro1
110binutils_test objcopy "-z relro -shared" relro1
111if { ([istarget "i?86-*-elf*"]
99753d9d
AM
112 || (([istarget "i?86-*-linux*"]
113 || [istarget "i?86-*-gnu*"])
b10a8ae0
L
114 && ![istarget "*-*-*aout*"]
115 && ![istarget "*-*-*oldld*"])
116 || [istarget "x86_64-*-linux*"]
117 || [istarget "amd64-*-linux*"]) } {
118 binutils_test strip "-z relro -shared" relro2
119 binutils_test objcopy "-z relro -shared" relro2
120}
c9df6640 121
b26238c0
AM
122binutils_test strip "-T ${srcdir}/${subdir}/lma.lnk" lma
123
3bd61671 124set tls_tests { "tdata1" "tdata2" }
de5c4ae2
AM
125# hppa64 has its own .tbss section, with different flags.
126if { ![istarget "hppa64-*-*"] } {
3bd61671 127 lappend tls_tests "tdata3" "tbss1" "tbss2" "tbss3"
de5c4ae2 128}
67e9eb74
AM
129set tls_opts {
130 ""
131 "-z relro"
132 "-shared"
133 "-shared -z relro"
134 "-z max-page-size=0x100000"
135 "-z max-page-size=0x100000 -z common-page-size=0x1000"
de5c4ae2 136}
b10a8ae0 137
67e9eb74
AM
138foreach testitem $tls_tests {
139 foreach testopt $tls_opts {
f33cfcaa 140 binutils_test objcopy $testopt $testitem
67e9eb74
AM
141 }
142}
This page took 0.236048 seconds and 4 git commands to generate.