1 # Expect script
for ld-sh tests
2 # Copyright
(C
) 2001, 2002, 2003, 2004 Free Software Foundation
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.
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.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 # Test SH relaxing
- that is
, that it
's disabled when SHmedia sections
22 if ![istarget sh64-*-*] {
26 # There are four source files: the first is SHcompact only, the second
27 # is SHmedia only, the third has both, and the fourth has only a
28 # .cranges section. The table below has:
30 # as flags for first source (else "n/a" to skip)
31 # ditto, other three files
33 # 1/0 whether relaxing should have been done or not, or -1 if we expect
34 # the linker to not produce an output file.
36 if [istarget sh64*-*-linux*] {
37 set emul32 "shlelf32_linux"
38 } elseif { [istarget sh64*-*-netbsd*] || [istarget sh5*-*-netbsd*] } {
39 set emul32 "shelf32_nbsd"
45 {"SH64 not relaxing, shcompact"
46 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-m$emul32" 0}
47 {"SH64 relaxing, shcompact"
48 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-relax -m$emul32" 1}
49 {"SH64 relaxing, shcompacts"
50 {"-relax -isa shcompact" "-isa shcompact" "n/a" "n/a"} "-relax -m$emul32" 1}
51 {"SH64 relaxing disabled, shmedia"
52 {"-relax -isa shcompact" "-isa shmedia -no-mix" "n/a" "n/a"} "-relax -m$emul32" 0}
53 {"SH64 relaxing disabled, mixed"
54 {"-relax -isa shcompact" "n/a" "-isa shcompact" "n/a"} "-relax -m$emul32" 0}
55 {"SH64 relaxing disabled, cranges"
56 {"-relax -isa shcompact" "n/a" "n/a" ""} "-relax -m$emul32" 0}
59 proc run_sh64relaxtest {sh64relaxtests} {
72 "relax1.s" "relax2.s" "relax3.s" "relax4.s"
75 foreach testentry $sh64relaxtests {
76 set testname [lindex $testentry 0]
77 set as_options [lindex $testentry 1]
78 set ld_options [subst [lindex $testentry 2]]
79 set expect_relaxed [lindex $testentry 3]
86 # Assemble each file in the test.
87 for {set i 0} {$i < 4} {incr i} {
88 set as_file [lindex $sh64relaxfiles $i]
89 set as_opt [lindex $as_options $i]
90 if { [string compare $as_opt "n/a"] != 0 } {
91 set objfile "tmpdir/[file rootname $as_file]-$testindex.o"
92 lappend objfiles $objfile
94 if ![ld_assemble $as "$as_opt $srcdir/$subdir/$as_file" $objfile] {
101 # Catch assembler errors.
102 if { $is_unresolved != 0 } {
107 set binfile "tmpdir/relax-$testindex.x"
109 # We're not interested in the pass
/fail of the linker as much
110 # as we
're interested in whether or not relaxing got properly
111 # disabled. Hence the lax checking here.
114 set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
115 if ![file exists $binfile] {
117 if {$expect_relaxed == -1} {
122 verbose "$testname: file $binfile doesn't exist
" 1
127 catch
"exec $objdump -d $binfile" objdump_output
129 regexp
"\[ \t](jsr|bsr)\[ \t]" $objdump_output ignore calltype
131 if [string match $
calltype "bsr"] {
133 } elseif
[string match $
calltype "jsr"] {
136 verbose
"$testname: neither jsr nor bsr found" 1
137 verbose $objdump_output
2
142 if {$relaxed
!= $expect_relaxed
} {
143 verbose $objdump_output
2
152 run_sh64relaxtest $sh64relaxtests