fixed bash/dash/sh issue (Ubuntu)
[zpugcc/jano.git] / toolchain / binutils / ld / testsuite / ld-sh / sh.exp
bloba1074210f43c3cf9bfc8c8fa47a3879dd0fce46b
1 # Expect script for ld-sh tests
2 # Copyright 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Written by Ian Lance Taylor (ian@cygnus.com)
21 # Test SH relaxing. This tests the compiler and assembler as well as
22 # the linker.
24 if ![istarget sh*-*-*] {
25 return
28 if { ([istarget sh64*-*-*] || [istarget sh5*-*-*])} {
29 # relaxing not supported on sh64 yet.
30 return
33 set testsimple "SH simple relaxing"
35 if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
36 unresolved $testsimple
37 } else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
38 fail $testsimple
39 } else {
40 if ![ld_nm $nm "" tmpdir/sh1] {
41 unresolved $testsimple
42 } else {
43 if {![info exists nm_output(bar)] \
44 || ![info exists nm_output(foo)]} {
45 send_log "bad output from nm\n"
46 verbose "bad output from nm"
47 fail $testsimple
48 } else {
49 if {$nm_output(bar) != $nm_output(foo) + 4} {
50 send_log "foo == $nm_output(foo)\n"
51 verbose "foo == $nm_output(foo)"
52 send_log "bar == $nm_output(bar)\n"
53 verbose "bar == $nm_output(bar)"
54 fail $testsimple
55 } else {
56 pass $testsimple
60 } }
62 set testsrec "SH relaxing to S-records"
64 if [istarget sh*-linux-gnu] {
65 # This target needs the explicit entry address.
66 catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
67 set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
68 } else {
69 set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
71 if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
72 fail $testsrec
73 } else {
74 # The file name is embedded in the S-records, so create both
75 # files with the same name.
76 catch "exec rm -f tmpdir/sh1.s2" exec_output
77 send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
78 verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
79 catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
80 if ![string match "" $exec_output] {
81 send_log "$exec_output\n"
82 verbose "$exec_output"
83 unresolved $testsrec
84 } else {
85 send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
86 verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
87 catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
88 if ![string match "" $exec_output] {
89 send_log "$exec_output\n"
90 verbose "$exec_output"
91 unresolved $testsrec
92 } else {
93 send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
94 verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
95 catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
96 set exec_output [prune_warnings $exec_output]
97 if ![string match "" $exec_output] {
98 send_log "$exec_output\n"
99 verbose "$exec_output"
100 fail $testsrec
101 } else {
102 pass $testsrec
108 set testlink "SH relaxing"
109 set testjsr "SH confirm relaxing"
110 set testrun "SH relaxing execution"
112 if { [which $CC] == 0 } {
113 untested $testlink
114 untested $testjsr
115 untested $testrun
116 return
119 if [istarget sh*-linux-gnu] {
120 exec sed -e s/_main/main/ -e s/_trap/trap/ -e s/_stack/stack/ \
121 < $srcdir/$subdir/start.s >tmpdir/start.s
122 } else {
123 exec cp $srcdir/$subdir/start.s tmpdir/start.s
126 if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
127 || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
128 unresolved $testlink
129 unresolved $testjsr
130 unresolved $testrun
131 return
134 if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
135 fail $testlink
136 unresolved $testjsr
137 unresolved $testrun
138 return
141 pass $testlink
143 send_log "$objdump -d tmpdir/sh2\n"
144 verbose "$objdump -d tmpdir/sh2"
145 catch "exec $objdump -d tmpdir/sh2" exec_output
146 if [string match "*jsr*" $exec_output] {
147 fail $testjsr
148 } else {
149 pass $testjsr
152 if { ![info exists SIM] || [which $SIM] == 0 } {
153 untested $testrun
154 return
157 set status [catch "exec $SIM tmpdir/sh2" exec_output]
158 if { $status == 0 } {
159 pass $testrun
160 } else {
161 fail $testrun