1 # Expect script
for LD Bootstrap Tests
2 # Copyright
1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2004,
3 #
2006, 2007 Free Software Foundation
, Inc.
5 # This file is part of the GNU Binutils.
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.
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.
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
,
22 # Written by Jeffrey Wheat
(cassidy@cygnus.com
)
23 # Rewritten by Ian Lance Taylor
(ian@cygnus.com
)
26 # Make sure that
ld can bootstrap itself.
28 # This test can only be run
if ld generates native executables.
33 # Bootstrap
ld. First link the object files together using
-r
, in
34 # order to test
-r.
Then link the result into an executable
, ld1
, to
35 # really test
-r. Use ld1 to link a fresh
ld, ld2. Use ld2 to link a
36 # new
ld, ld3. ld2 and ld3 should be identical.
38 foreach flags
{"" "strip" "--static" "--traditional-format"
39 "--no-keep-memory" "--relax"} {
41 if {"$flags" == "strip"} {
42 set testname
"bootstrap with $flags"
45 } else { if {"$flags" != ""} {
46 set testname
"bootstrap with $flags"
48 set testname
"bootstrap"
51 #
--static is meaningless and
--relax is incompatible with
-r.
52 set partial_flags
"$flags"
53 if { "$flags" == "--static" || "$flags" == "--relax" } {
57 # This test can only be run
if we have the
ld build directory
,
58 # since we need the object files.
59 if {$
ld != "$objdir/ld-new"} {
64 #
If we only have a shared libbfd
, we probably can
't run the
66 if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
71 if ![ld_relocate $ld tmpdir/ld-partial.o "$partial_flags $OFILES"] {
76 # On AIX, you need to specify an import list when using --static.
77 # You only want the import list when creating the final
79 if { [istarget "*-*-aix*"]
80 && ![istarget "ia64-*-aix*"]} {
81 if {"$flags" == "--static"} {
82 set flags "--static -bI:/lib/syscalls.exp"
86 # On Irix 5, linking with --static only works if all the files are
87 # compiled using -non_shared.
88 if {"$flags" == "--static"} {
89 setup_xfail "mips*-*-irix5*"
92 if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY"] {
97 if {"$do_strip" == "yes"} {
98 verbose -log "$strip tmpdir/ld1"
99 catch "exec $strip tmpdir/ld1" exec_output
100 if ![string match "" $exec_output] then {
101 verbose -log "$exec_output"
107 if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
112 if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
117 if {"$flags" == "--static"} {
118 if { [istarget ia64-*-elf*]
119 || [istarget ia64-*-linux*] } {
120 # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
121 # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
122 # So we rebuild tmpdir/ld2 with tmpdir/ld3.
123 if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
129 if { [istarget mips*-*-linux*] } {
130 # On Linux/mips, tmpdir/ld2 != tmpdir/ld3 is normal since
131 # they are generated by different linkers, tmpdir/ld1 and
132 # tmpdir/ld2. So we rebuild tmpdir/ld2 with tmpdir/ld3.
133 if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
140 send_log "compare (tail of) tmpdir/ld2 tmpdir/ld3\n"
141 verbose "compare (tail of) tmpdir/ld2 tmpdir/ld3"
142 if {[istarget "*-*-pe"]
143 || [istarget "*-*-wince"]
144 || [istarget "*-*-cygwin*"]
145 || [istarget "*-*-winnt*"]
146 || [istarget "*-*-mingw*"]
147 || [istarget "*-*-interix*"]
148 || [istarget "*-*-beospe*"]
149 || [istarget "*-*-netbsdpe*"]} {
150 # Trim off the date present in PE binaries by only looking
151 # at the ends of the files
152 # Although this works, a way to set the date would be better.
153 # Removing or zeroing the date stamp in the binary produced by
154 # the linker is not possible as it is required by the target OS.
155 exec tail +140 tmpdir/ld2 >tmpdir/ld2tail
156 exec tail +140 tmpdir/ld3 >tmpdir/ld3tail
157 catch "exec cmp tmpdir/ld2tail tmpdir/ld3tail" exec_output
158 exec rm tmpdir/ld2tail tmpdir/ld3tail
160 send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
161 verbose "cmp tmpdir/ld2 tmpdir/ld3"
162 catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
164 set exec_output [prune_warnings $exec_output]
166 if [string match "" $exec_output] then {
169 send_log "$exec_output\n"
170 verbose "$exec_output" 1
176 catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
177 catch "exec rm -f tmpdir/ld1tail tmpdir/ld2tail tmpdir/ld3tail" status