]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-sh/sh64/relax.exp
Contribute sh64-elf.
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-sh / sh64 / relax.exp
CommitLineData
1b19eb81
AO
1# Expect script for ld-sh tests
2# Copyright (C) 2001 Free Software Foundation
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
19# Test SH relaxing - that is, that it's disabled when SHmedia sections
20# are present.
21
22if ![istarget sh64-*-*] {
23 return
24}
25
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:
29# Title
30# as flags for first source (else "n/a" to skip)
31# ditto, other three files
32# ld flags
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.
35
36set sh64relaxtests {
37 {"SH64 not relaxing, shcompact"
38 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-mshelf32" 0}
39 {"SH64 relaxing, shcompact"
40 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-relax -mshelf32" 1}
41 {"SH64 relaxing, shcompacts"
42 {"-relax -isa shcompact" "-isa shcompact" "n/a" "n/a"} "-relax -mshelf32" 1}
43 {"SH64 relaxing disabled, shmedia"
44 {"-relax -isa shcompact" "-isa shmedia -no-mix" "n/a" "n/a"} "-relax -mshelf32" 0}
45 {"SH64 relaxing disabled, mixed"
46 {"-relax -isa shcompact" "n/a" "-isa shcompact" "n/a"} "-relax -mshelf32" 0}
47 {"SH64 relaxing disabled, cranges"
48 {"-relax -isa shcompact" "n/a" "n/a" ""} "-relax -mshelf32" 0}
49}
50
51proc run_sh64relaxtest {sh64relaxtests} {
52 global ld
53 global as
54 global nm
55 global objdump
56 global readelf
57 global srcdir
58 global subdir
59
60 set testindex 0
61
62 set sh64relaxfiles {
63 "relax1.s" "relax2.s" "relax3.s" "relax4.s"
64 }
65
66 foreach testentry $sh64relaxtests {
67 set testname [lindex $testentry 0]
68 set as_options [lindex $testentry 1]
69 set ld_options [lindex $testentry 2]
70 set expect_relaxed [lindex $testentry 3]
71
72 set is_unresolved 0
73 set objfiles {}
74
75 incr testindex
76
77 # Assemble each file in the test.
78 for {set i 0} {$i < 4} {incr i} {
79 set as_file [lindex $sh64relaxfiles $i]
80 set as_opt [lindex $as_options $i]
81 if { [string compare $as_opt "n/a"] != 0 } {
82 set objfile "tmpdir/[file rootname $as_file]-$testindex.o"
83 lappend objfiles $objfile
84
85 if ![ld_assemble $as "$as_opt $srcdir/$subdir/$as_file" $objfile] {
86 set is_unresolved 1
87 break
88 }
89 }
90 }
91
92 # Catch assembler errors.
93 if { $is_unresolved != 0 } {
94 unresolved $testname
95 continue
96 }
97
98 set binfile "tmpdir/relax-$testindex.x"
99
100 # We're not interested in the pass/fail of the linker as much
101 # as we're interested in whether or not relaxing got properly
102 # disabled. Hence the lax checking here.
103
104 file delete $binfile
105 set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
106 if ![file exists $binfile] {
107
108 if {$expect_relaxed == -1} {
109 pass $testname
110 continue;
111 }
112
113 verbose "$testname: file $binfile doesn't exist" 1
114 fail $testname
115 continue
116 }
117
118 catch "exec $objdump -d $binfile" objdump_output
119
120 regexp "\[ \t](jsr|bsr)\[ \t]" $objdump_output ignore calltype
121
122 if [string match $calltype "bsr"] {
123 set relaxed 1
124 } elseif [string match $calltype "jsr"] {
125 set relaxed 0
126 } else {
127 verbose "$testname: neither jsr nor bsr found" 1
128 verbose $objdump_output 2
129 fail $testname
130 continue
131 }
132
133 if {$relaxed != $expect_relaxed} {
134 verbose $objdump_output 2
135 fail $testname
136 exit
137 } else {
138 pass $testname
139 }
140 }
141}
142
143run_sh64relaxtest $sh64relaxtests