1 # Expect script
for ld-sh tests
2 # Copyright
(C
) 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation
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
,
22 # Test SH relaxing
- that is
, that it
's disabled when SHmedia sections
25 if ![istarget sh64-*-*] {
29 # There are four source files: the first is SHcompact only, the second
30 # is SHmedia only, the third has both, and the fourth has only a
31 # .cranges section. The table below has:
33 # as flags for first source (else "n/a" to skip)
34 # ditto, other three files
36 # 1/0 whether relaxing should have been done or not, or -1 if we expect
37 # the linker to not produce an output file.
39 if [istarget sh64*-*-linux*] {
40 set emul32 "shlelf32_linux"
41 } elseif { [istarget sh64*-*-netbsd*] || [istarget sh5*-*-netbsd*] } {
42 set emul32 "shelf32_nbsd"
48 {"SH64 not relaxing, shcompact"
49 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-m$emul32" 0}
50 {"SH64 relaxing, shcompact"
51 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-relax -m$emul32" 1}
52 {"SH64 relaxing, shcompacts"
53 {"-relax -isa shcompact" "-isa shcompact" "n/a" "n/a"} "-relax -m$emul32" 1}
54 {"SH64 relaxing disabled, shmedia"
55 {"-relax -isa shcompact" "-isa shmedia -no-mix" "n/a" "n/a"} "-relax -m$emul32" 0}
56 {"SH64 relaxing disabled, mixed"
57 {"-relax -isa shcompact" "n/a" "-isa shcompact" "n/a"} "-relax -m$emul32" 0}
58 {"SH64 relaxing disabled, cranges"
59 {"-relax -isa shcompact" "n/a" "n/a" ""} "-relax -m$emul32" 0}
62 proc run_sh64relaxtest {sh64relaxtests} {
75 "relax1.s" "relax2.s" "relax3.s" "relax4.s"
78 foreach testentry $sh64relaxtests {
79 set testname [lindex $testentry 0]
80 set as_options [lindex $testentry 1]
81 set ld_options [subst [lindex $testentry 2]]
82 set expect_relaxed [lindex $testentry 3]
89 # Assemble each file in the test.
90 for {set i 0} {$i < 4} {incr i} {
91 set as_file [lindex $sh64relaxfiles $i]
92 set as_opt [lindex $as_options $i]
93 if { [string compare $as_opt "n/a"] != 0 } {
94 set objfile "tmpdir/[file rootname $as_file]-$testindex.o"
95 lappend objfiles $objfile
97 if ![ld_assemble $as "$as_opt $srcdir/$subdir/$as_file" $objfile] {
104 # Catch assembler errors.
105 if { $is_unresolved != 0 } {
110 set binfile "tmpdir/relax-$testindex.x"
112 # We're not interested in the pass
/fail of the linker as much
113 # as we
're interested in whether or not relaxing got properly
114 # disabled. Hence the lax checking here.
117 set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
118 if ![file exists $binfile] {
120 if {$expect_relaxed == -1} {
125 verbose "$testname: file $binfile doesn't exist
" 1
130 catch
"exec $objdump -d $binfile" objdump_output
132 regexp
"\[ \t](jsr|bsr)\[ \t]" $objdump_output ignore calltype
134 if [string match $
calltype "bsr"] {
136 } elseif
[string match $
calltype "jsr"] {
139 verbose
"$testname: neither jsr nor bsr found" 1
140 verbose $objdump_output
2
145 if {$relaxed
!= $expect_relaxed
} {
146 verbose $objdump_output
2
155 run_sh64relaxtest $sh64relaxtests