2001-06-04 Michael Snyder <msnyder@redhat.com>
[deliverable/binutils-gdb.git] / ld / testsuite / ld-bootstrap / bootstrap.exp
CommitLineData
252b5132 1# Expect script for LD Bootstrap Tests
a2b64bed
NC
2# Copyright 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001
3# Free Software Foundation, Inc.
252b5132
RH
4#
5# This file is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18#
19# Written by Jeffrey Wheat (cassidy@cygnus.com)
20# Rewritten by Ian Lance Taylor (ian@cygnus.com)
21#
22
23# Make sure that ld can bootstrap itself.
24
25# This test can only be run if ld generates native executables.
26if ![isnative] {
27 return
28}
29
30# Bootstrap ld. First link the object files together using -r, in
31# order to test -r. Then link the result into an executable, ld1, to
32# really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a
33# new ld, ld3. ld2 and ld3 should be identical.
34
e1753d2c
L
35foreach flags {"" "strip" "--static" "--traditional-format" "--no-keep-memory"} {
36 set do_strip "no"
37 if {"$flags" == "strip"} {
38 set testname "bootstrap with $flags"
39 set flags ""
40 set do_strip "yes"
41 } else { if {"$flags" != ""} {
252b5132
RH
42 set testname "bootstrap with $flags"
43 } else {
44 set testname "bootstrap"
e1753d2c 45 }}
252b5132
RH
46
47 # This test can only be run if we have the ld build directory,
48 # since we need the object files.
49 if {$ld != "$objdir/ld-new"} {
50 untested $testname
51 continue
52 }
53
54 # If we only have a shared libbfd, we probably can't run the
55 # --static test.
56 if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
57 untested $testname
58 continue
59 }
60
61 if ![ld_relocate $ld tmpdir/ld-partial.o "$flags $OFILES"] {
62 fail $testname
63 continue
64 }
65
66 # On AIX, you need to specify an import list when using --static.
67 # You only want the import list when creating the final
68 # executable.
41c49998
TW
69 if { [istarget "*-*-aix*"]
70 && ![istarget "ia64-*-aix*"]} {
252b5132
RH
71 if {"$flags" == "--static"} {
72 set flags "--static -bI:/lib/syscalls.exp"
73 }
74 }
75
76 # On Irix 5, linking with --static only works if all the files are
77 # compiled using -non_shared.
78 if {"$flags" == "--static"} {
79 setup_xfail "mips*-*-irix5*"
80 }
81
82 if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY"] {
83 fail $testname
84 continue
85 }
86
e1753d2c
L
87 if {"$do_strip" == "yes"} {
88 verbose -log "$strip tmpdir/ld1"
89 catch "exec $strip tmpdir/ld1" exec_output
90 if ![string match "" $exec_output] then {
91 verbose -log "$exec_output"
92 fail $testname
93 continue
94 }
95 }
96
252b5132
RH
97 if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
98 fail $testname
99 continue
100 }
101
102 if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
103 fail $testname
104 continue
105 }
106
ad995491
L
107 if {"$flags" == "--static"} {
108 if { [istarget ia64-*-elf*]
109 || [istarget ia64-*-linux*] } {
110 # On ia64, tmpdir/ld2 != tmpdir/ld3 is normal since they are
111 # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
112 # So we rebuild tmpdir/ld2 with tmpdir/ld3.
113 if ![ld_link tmpdir/ld3 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
114 fail $testname
115 continue
116 }
117 }
118 }
119
252b5132
RH
120 send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
121 verbose "cmp tmpdir/ld2 tmpdir/ld3"
122 catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
123 set exec_output [prune_warnings $exec_output]
124
125 if [string match "" $exec_output] then {
126 pass $testname
127 } else {
128 send_log "$exec_output\n"
129 verbose "$exec_output" 1
130
131 fail $testname
132 }
133}
This page took 0.074579 seconds and 4 git commands to generate.