* config/default.exp (ld_nm): Add "nmflags" arg.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-sh / sh.exp
CommitLineData
252b5132 1# Expect script for ld-sh tests
a2b64bed 2# Copyright 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
252b5132
RH
3#
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.
13#
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.
17#
18# Written by Ian Lance Taylor (ian@cygnus.com)
19#
20
21# Test SH relaxing. This tests the compiler and assembler as well as
22# the linker.
23
24if ![istarget sh*-*-*] {
25 return
26}
27
28set testsimple "SH simple relaxing"
29
30if ![ld_assemble $as "-relax $srcdir/$subdir/sh1.s" tmpdir/sh1.o] {
31 unresolved $testsimple
32} else { if ![ld_simple_link $ld tmpdir/sh1 "-relax tmpdir/sh1.o"] {
33 fail $testsimple
34} else {
992c450d 35 if ![ld_nm $nm "" tmpdir/sh1] {
252b5132
RH
36 unresolved $testsimple
37 } else {
38 if {![info exists nm_output(bar)] \
39 || ![info exists nm_output(foo)]} {
40 send_log "bad output from nm\n"
41 verbose "bad output from nm"
42 fail $testsimple
43 } else {
44 if {$nm_output(bar) != $nm_output(foo) + 4} {
45 send_log "foo == $nm_output(foo)\n"
46 verbose "foo == $nm_output(foo)"
47 send_log "bar == $nm_output(bar)\n"
48 verbose "bar == $nm_output(bar)"
49 fail $testsimple
50 } else {
51 pass $testsimple
52 }
53 }
54 }
55} }
56
57set testsrec "SH relaxing to S-records"
58
1e329ce6
NC
59if [istarget sh*-linux-gnu] {
60 # This target needs the explicit entry address.
61 catch "exec $objdump -x tmpdir/sh1 | grep start\\ address | sed s/start\\ address//" entry_addr
62 set srec_relax_arg "-Ttext $entry_addr -relax --oformat srec tmpdir/sh1.o"
63} else {
64 set srec_relax_arg "-relax --oformat srec tmpdir/sh1.o"
65}
66if ![ld_simple_link $ld tmpdir/sh1.s1 $srec_relax_arg ] {
252b5132
RH
67 fail $testsrec
68} else {
69 # The file name is embedded in the S-records, so create both
70 # files with the same name.
71 catch "exec rm -f tmpdir/sh1.s2" exec_output
72 send_log "mv tmpdir/sh1.s1 tmpdir/sh1.s2\n"
73 verbose "mv tmpdir/sh1.s1 tmpdir/sh1.s2"
74 catch "exec mv tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
75 if ![string match "" $exec_output] {
76 send_log "$exec_output\n"
77 verbose "$exec_output"
78 unresolved $testsrec
79 } else {
80 send_log "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
81 verbose "$objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1"
82 catch "exec $objcopy -O srec tmpdir/sh1 tmpdir/sh1.s1" exec_output
83 if ![string match "" $exec_output] {
84 send_log "$exec_output\n"
85 verbose "$exec_output"
86 unresolved $testsrec
87 } else {
88 send_log "cmp tmpdir/sh1.s1 tmpdir/sh1.s2\n"
89 verbose "cmp tmpdir/sh1.s1 tmpdir/sh1.s2"
90 catch "exec cmp tmpdir/sh1.s1 tmpdir/sh1.s2" exec_output
91 set exec_output [prune_warnings $exec_output]
92 if ![string match "" $exec_output] {
93 send_log "$exec_output\n"
94 verbose "$exec_output"
95 fail $testsrec
96 } else {
97 pass $testsrec
98 }
99 }
100 }
101}
102
103set testlink "SH relaxing"
104set testjsr "SH confirm relaxing"
105set testrun "SH relaxing execution"
106
107if { [which $CC] == 0 } {
108 untested $testlink
109 untested $testjsr
110 untested $testrun
111 return
112}
113
114if {![ld_assemble $as "-relax $srcdir/$subdir/start.s" tmpdir/start.o] \
115 || ![ld_compile $CC "-O -mrelax $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
116 unresolved $testlink
117 unresolved $testjsr
118 unresolved $testrun
119 return
120}
121
122if ![ld_simple_link $ld tmpdir/sh2 "-relax tmpdir/start.o tmpdir/sh2.o"] {
123 fail $testlink
124 unresolved $testjsr
125 unresolved $testrun
126 return
127}
128
129pass $testlink
130
131send_log "$objdump -d tmpdir/sh2\n"
132verbose "$objdump -d tmpdir/sh2"
133catch "exec $objdump -d tmpdir/sh2" exec_output
134if [string match "*jsr*" $exec_output] {
135 fail $testjsr
136} else {
137 pass $testjsr
138}
139
140if { ![info exists SIM] || [which $SIM] == 0 } {
141 untested $testrun
142 return
143}
144
145set status [catch "exec $SIM tmpdir/sh2" exec_output]
146if { $status == 0 } {
147 pass $testrun
148} else {
149 fail $testrun
150}
This page took 0.103391 seconds and 4 git commands to generate.