[PATCH 40/57][Arm][OBJDUMP] Add support for MVE instructions: vdup, veor, vfma, vfms...
[binutils-gdb.git] / ld / testsuite / ld-bootstrap / bootstrap.exp
blobee9442da167eb76ec24a986dbcc9eb4a0cacf280
1 # Expect script for LD Bootstrap Tests
2 # Copyright (C) 1993-2019 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
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.
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
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
21 # Written by Jeffrey Wheat (cassidy@cygnus.com)
22 # Rewritten by Ian Lance Taylor (ian@cygnus.com)
25 # Make sure that ld can bootstrap itself.
27 # This test can only be run if ld generates native executables.
28 if ![isnative] {
29 return
32 global STATIC_LDFLAGS
34 # Determine if plugin support is present.
35 remote_exec host "$nm --help" "" "/dev/null" "plugin-support"
36 set tmp [file_contents "plugin-support"]
37 regexp ".*\(--plugin\).*\n" $tmp foo plugins
38 if [info exists plugins] then {
39 set plugins "yes"
40 } else {
41 set plugins "no"
44 # LD can have plugin support even if BFD does not.
45 if [check_plugin_api_available] {
46 set plugins "yes"
49 # Bootstrap ld. First link the object files together using -r, in
50 # order to test -r. Then link the result into an executable, ld1, to
51 # really test -r. Use ld1 to link a fresh ld, ld2. Use ld2 to link a
52 # new ld, ld3. ld2 and ld3 should be identical.
53 set test_flags {"" "strip" "--static" "-Wl,--traditional-format"
54 "-Wl,--no-keep-memory" "-Wl,--relax"}
55 if { [istarget "powerpc-*-*"] } {
56 lappend test_flags "-Wl,--ppc476-workaround"
59 set gcc_B_opt_save $gcc_B_opt
61 foreach ldexe {ld1 ld2 ld3} {
62 if {![file isdirectory tmpdir/gcc$ldexe]} then {
63 catch "exec mkdir tmpdir/gcc$ldexe" status
64 catch "exec ln -s ../$ldexe tmpdir/gcc$ldexe/ld" status
65 catch "exec ln -s ld tmpdir/gcc$ldexe/collect-ld" status
66 catch "exec ln -s ../../../gas/as-new tmpdir/gcc$ldexe/as" status
70 foreach flags $test_flags {
71 set gcc_B_opt $gcc_B_opt_save
72 set do_strip "no"
73 if {"$flags" == "strip"} {
74 set testname "bootstrap with $flags"
75 set flags ""
76 set do_strip "yes"
77 } else { if {"$flags" != ""} {
78 set testname "bootstrap with $flags"
79 } else {
80 set testname "bootstrap"
83 # --static is meaningless and --relax is incompatible with -r.
84 regsub -- "-Wl," $flags "" partial_flags
85 if { "$partial_flags" == "--static" || "$partial_flags" == "--relax" } {
86 set partial_flags ""
89 if { $partial_flags == "--ppc476-workaround" } {
90 append partial_flags " -T $srcdir/$subdir/ppc476.t"
93 # This test can only be run if we have the ld build directory,
94 # since we need the object files.
95 if {$ld != "$objdir/ld-new"} {
96 untested $testname
97 continue
100 # If -static doesn't work, these tests will fail.
101 if { $flags == "--static" && [string match "" $STATIC_LDFLAGS] } then {
102 untested $testname
103 continue
106 # Plugin support requires linking with a dynamic library which
107 # means that these tests will fail.
108 if { $flags == "--static" && $plugins == "yes" } then {
109 untested $testname
110 continue
113 # If we only have a shared libbfd, we probably can't run the
114 # --static test.
115 if { $flags == "--static" && ! [string match "*libbfd.a*" $BFDLIB] } then {
116 untested $testname
117 continue
120 if ![ld_relocate $ld tmpdir/ld-partial.o "$partial_flags $OFILES"] {
121 fail $testname
122 continue
125 # On AIX, you need to specify an import list when using --static.
126 # You only want the import list when creating the final
127 # executable.
128 if { [istarget "*-*-aix*"]
129 && ![istarget "ia64-*-aix*"]} {
130 if {"$flags" == "--static"} {
131 set flags "--static -bI:/lib/syscalls.exp"
135 # On Cygwin, -lintl may require -liconv when linking statically.
136 set extralibs ""
137 if { [istarget "*-*-cygwin*"]} {
138 if {"$flags" == "--static"} {
139 set extralibs "-liconv"
143 # Check if the system's zlib library is used.
144 if {[file exists ../zlib/Makefile ]} then {
145 set extralibs "$extralibs -L../zlib -lz"
146 } else {
147 set extralibs "$extralibs -lz"
150 # Plugin support requires linking with libdl.
151 if { $plugins == "yes" } {
152 if { ![istarget "*-*-freebsd*"]} {
153 set extralibs "$extralibs -ldl"
157 # On Irix 5, linking with --static only works if all the files are
158 # compiled using -non_shared.
159 if {"$flags" == "--static"} {
160 setup_xfail "mips*-*-irix5*"
163 if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
164 fail $testname
165 continue
168 if {"$do_strip" == "yes"} {
169 verbose -log "$strip tmpdir/ld1"
170 catch "exec $strip tmpdir/ld1" exec_output
171 set exec_output [prune_warnings $exec_output]
172 if ![string match "" $exec_output] then {
173 verbose -log "$exec_output"
174 fail $testname
175 continue
179 regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
180 if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
181 fail $testname
182 continue
185 regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
186 if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
187 fail $testname
188 continue
191 if { "$flags" == "--static"
192 && ([istarget ia64-*-elf*]
193 || [istarget ia64-*-linux*]
194 || [istarget mips*-*-linux*]) } {
195 # On ia64 and mips, tmpdir/ld2 != tmpdir/ld3 is normal since they are
196 # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
197 # So we rebuild tmpdir/ld2 with tmpdir/ld3.
198 regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
199 if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
200 fail $testname
201 continue
205 if {[istarget "*-*-pe"]
206 || [istarget "*-*-wince"]
207 || [istarget "*-*-cygwin*"]
208 || [istarget "*-*-winnt*"]
209 || [istarget "*-*-mingw*"]
210 || [istarget "*-*-interix*"]
211 || [istarget "*-*-beospe*"]
212 || [istarget "*-*-netbsdpe*"]} {
213 # Trim off the date present in PE binaries by only looking
214 # at the ends of the files
215 # Although this works, a way to set the date would be better.
216 # Removing or zeroing the date stamp in the binary produced by
217 # the linker is not possible as it is required by the target OS.
218 set do_compare [string map {16 220 f1 tmpdir/ld2 f2 tmpdir/ld3 tmp-foo1 tmpdir/ld2tail tmp-foo2 tmpdir/ld3tail} $DO_COMPARE]
219 send_log "$do_compare\n"
220 verbose "$do_compare"
221 catch "exec sh -c [list $do_compare]" exec_output
222 } else {
223 send_log "cmp tmpdir/ld2 tmpdir/ld3\n"
224 verbose "cmp tmpdir/ld2 tmpdir/ld3"
225 catch "exec cmp tmpdir/ld2 tmpdir/ld3" exec_output
227 set exec_output [prune_warnings $exec_output]
229 if [string match "" $exec_output] then {
230 pass $testname
231 } else {
232 send_log "$exec_output\n"
233 verbose "$exec_output" 1
235 fail $testname
239 set gcc_B_opt $gcc_B_opt_save
240 catch "exec rm -f tmpdir/ld-partial.o tmpdir/ld1 tmpdir/ld2 tmpdir/ld3" status
241 catch "exec rm -f tmpdir/ld2tail tmpdir/ld3tail" status