Add ppc476 workaround bootstrap test
[deliverable/binutils-gdb.git] / ld / testsuite / ld-bootstrap / bootstrap.exp
1 # Expect script for LD Bootstrap Tests
2 # Copyright 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004,
3 # 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
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 # Written by Jeffrey Wheat (cassidy@cygnus.com)
23 # Rewritten by Ian Lance Taylor (ian@cygnus.com)
24 #
25
26 # Make sure that ld can bootstrap itself.
27
28 # This test can only be run if ld generates native executables.
29 if ![isnative] {
30 return
31 }
32
33 # Determine if plugin support is present.
34 remote_exec host "$nm --help" "" "/dev/null" "plugin-support"
35 set tmp [file_contents "plugin-support"]
36 regexp ".*\(--plugin\).*\n" $tmp foo plugins
37 if [info exists plugins] then {
38 set plugins "yes"
39 } else {
40 set plugins "no"
41 }
42
43 # LD can have plugin support even if BFD does not.
44 if [check_plugin_api_available] {
45 set plugins "yes"
46 }
47
48 # Bootstrap ld. First link the object files together using -r, in
49 # order to test -r. Then link the result into an executable, ld1, to
50 # really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a
51 # new ld, ld3. ld2 and ld3 should be identical.
52 set test_flags {"" "strip" "--static" "--traditional-format"
53 "--no-keep-memory" "--relax"}
54 if { [istarget "powerpc-*-*"] } {
55 lappend test_flags "--ppc476-workaround"
56 }
57
58 foreach flags $test_flags {
59 set do_strip "no"
60 if {"$flags" == "strip"} {
61 set testname "bootstrap with $flags"
62 set flags ""
63 set do_strip "yes"
64 } else { if {"$flags" != ""} {
65 set testname "bootstrap with $flags"
66 } else {
67 set testname "bootstrap"
68 }}
69
70 # --static is meaningless and --relax is incompatible with -r.
71 set partial_flags "$flags"
72 if { "$flags" == "--static" || "$flags" == "--relax" } {
73 set partial_flags ""
74 }
75
76 if { $partial_flags == "--ppc476-workaround" } {
77 append partial_flags " -T $srcdir/$subdir/ppc476.t"
78 }
79
80 # This test can only be run if we have the ld build directory,
81 # since we need the object files.
82 if {$ld != "$objdir/ld-new"} {
83 untested $testname
84 continue
85 }
86
87 # Plugin support requires linking with a dynamic library which
88 # means that these tests will fail.
89 if { $flags == "--static" && $plugins == "yes" } then {
90 untested $testname
91 continue
92 }
93
94 # If we only have a shared libbfd, we probably can't run the
95 # --static test.
96 if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
97 untested $testname
98 continue
99 }
100
101 if ![ld_relocate $ld tmpdir/ld-partial.o "$partial_flags $OFILES"] {
102 fail $testname
103 continue
104 }
105
106 # On AIX, you need to specify an import list when using --static.
107 # You only want the import list when creating the final
108 # executable.
109 if { [istarget "*-*-aix*"]
110 && ![istarget "ia64-*-aix*"]} {
111 if {"$flags" == "--static"} {
112 set flags "--static -bI:/lib/syscalls.exp"
113 }
114 }
115
116 # On Cygwin, -lintl may require -liconv when linking statically.
117 set extralibs ""
118 if { [istarget "*-*-cygwin*"]} {
119 if {"$flags" == "--static"} {
120 set extralibs "-liconv"
121 }
122 }
123
124 # Plugin support requires linking with libdl.
125 if { $plugins == "yes" } {
126 set extralibs "$extralibs -ldl"
127 }
128
129 # On Irix 5, linking with --static only works if all the files are
130 # compiled using -non_shared.
131 if {"$flags" == "--static"} {
132 setup_xfail "mips*-*-irix5*"
133 }
134
135 if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
136 fail $testname
137 continue
138 }
139
140 if {"$do_strip" == "yes"} {
141 verbose -log "$strip tmpdir/ld1"
142 catch "exec $strip tmpdir/ld1" exec_output
143 if ![string match "" $exec_output] then {
144 verbose -log "$exec_output"
145 fail $testname
146 continue
147 }
148 }
149
150 if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
151 fail $testname
152 continue
153 }
154
155 if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
156 fail $testname
157 continue
158 }
159
160 if {"$flags" == "--static"} {
161 if { [istarget ia64-*-elf*]
162 || [istarget ia64-*-linux*] } {
163 # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
164 # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
165 # So we rebuild tmpdir/ld2 with tmpdir/ld3.
166 if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
167 fail $testname
168 continue
169 }
170 }
171 } else {
172 if { [istarget mips*-*-linux*] } {
173 # On Linux/mips, tmpdir/ld2 != tmpdir/ld3 is normal since
174 # they are generated by different linkers, tmpdir/ld1 and
175 # tmpdir/ld2. So we rebuild tmpdir/ld2 with tmpdir/ld3.
176 if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
177 fail $testname
178 continue
179 }
180 }
181 }
182
183 if {[istarget "*-*-pe"]
184 || [istarget "*-*-wince"]
185 || [istarget "*-*-cygwin*"]
186 || [istarget "*-*-winnt*"]
187 || [istarget "*-*-mingw*"]
188 || [istarget "*-*-interix*"]
189 || [istarget "*-*-beospe*"]
190 || [istarget "*-*-netbsdpe*"]} {
191 # Trim off the date present in PE binaries by only looking
192 # at the ends of the files
193 # Although this works, a way to set the date would be better.
194 # Removing or zeroing the date stamp in the binary produced by
195 # the linker is not possible as it is required by the target OS.
196 set do_compare [string map {16 220 f1 tmpdir/ld2 f2 tmpdir/ld3 tmp-foo1 tmpdir/ld2tail tmp-foo2 tmpdir/ld3tail} $DO_COMPARE]
197 send_log "$do_compare\n"
198 verbose "$do_compare"
199 catch "exec sh -c [list $do_compare]" exec_output
200 } else {
201 send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
202 verbose "cmp tmpdir/ld2 tmpdir/ld3"
203 catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
204 }
205 set exec_output [prune_warnings $exec_output]
206
207 if [string match "" $exec_output] then {
208 pass $testname
209 } else {
210 send_log "$exec_output\n"
211 verbose "$exec_output" 1
212
213 fail $testname
214 }
215 }
216
217 catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
218 catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status
This page took 0.035447 seconds and 5 git commands to generate.