Commit | Line | Data |
---|---|---|
1b19eb81 | 1 | # Expect script for ld-sh tests |
aef6203b | 2 | # Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation |
1b19eb81 AO |
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 | ||
22 | if ![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 | ||
24d1feef SC |
36 | if [istarget sh64*-*-linux*] { |
37 | set emul32 "shlelf32_linux" | |
f19ae42f KK |
38 | } elseif { [istarget sh64*-*-netbsd*] || [istarget sh5*-*-netbsd*] } { |
39 | set emul32 "shelf32_nbsd" | |
24d1feef SC |
40 | } else { |
41 | set emul32 "shelf32" | |
42 | } | |
43 | ||
1b19eb81 AO |
44 | set sh64relaxtests { |
45 | {"SH64 not relaxing, shcompact" | |
24d1feef | 46 | {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-m$emul32" 0} |
1b19eb81 | 47 | {"SH64 relaxing, shcompact" |
24d1feef | 48 | {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-relax -m$emul32" 1} |
1b19eb81 | 49 | {"SH64 relaxing, shcompacts" |
24d1feef | 50 | {"-relax -isa shcompact" "-isa shcompact" "n/a" "n/a"} "-relax -m$emul32" 1} |
1b19eb81 | 51 | {"SH64 relaxing disabled, shmedia" |
24d1feef | 52 | {"-relax -isa shcompact" "-isa shmedia -no-mix" "n/a" "n/a"} "-relax -m$emul32" 0} |
1b19eb81 | 53 | {"SH64 relaxing disabled, mixed" |
24d1feef | 54 | {"-relax -isa shcompact" "n/a" "-isa shcompact" "n/a"} "-relax -m$emul32" 0} |
1b19eb81 | 55 | {"SH64 relaxing disabled, cranges" |
24d1feef | 56 | {"-relax -isa shcompact" "n/a" "n/a" ""} "-relax -m$emul32" 0} |
1b19eb81 AO |
57 | } |
58 | ||
59 | proc run_sh64relaxtest {sh64relaxtests} { | |
60 | global ld | |
61 | global as | |
62 | global nm | |
63 | global objdump | |
64 | global readelf | |
65 | global srcdir | |
66 | global subdir | |
24d1feef | 67 | global emul32 |
1b19eb81 AO |
68 | |
69 | set testindex 0 | |
70 | ||
71 | set sh64relaxfiles { | |
72 | "relax1.s" "relax2.s" "relax3.s" "relax4.s" | |
73 | } | |
74 | ||
75 | foreach testentry $sh64relaxtests { | |
76 | set testname [lindex $testentry 0] | |
77 | set as_options [lindex $testentry 1] | |
24d1feef | 78 | set ld_options [subst [lindex $testentry 2]] |
1b19eb81 AO |
79 | set expect_relaxed [lindex $testentry 3] |
80 | ||
81 | set is_unresolved 0 | |
82 | set objfiles {} | |
83 | ||
84 | incr testindex | |
85 | ||
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 | |
93 | ||
94 | if ![ld_assemble $as "$as_opt $srcdir/$subdir/$as_file" $objfile] { | |
95 | set is_unresolved 1 | |
96 | break | |
97 | } | |
98 | } | |
99 | } | |
100 | ||
101 | # Catch assembler errors. | |
102 | if { $is_unresolved != 0 } { | |
103 | unresolved $testname | |
104 | continue | |
105 | } | |
106 | ||
107 | set binfile "tmpdir/relax-$testindex.x" | |
108 | ||
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. | |
112 | ||
113 | file delete $binfile | |
114 | set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"] | |
115 | if ![file exists $binfile] { | |
116 | ||
117 | if {$expect_relaxed == -1} { | |
118 | pass $testname | |
b24f926d | 119 | continue |
1b19eb81 AO |
120 | } |
121 | ||
122 | verbose "$testname: file $binfile doesn't exist" 1 | |
123 | fail $testname | |
124 | continue | |
125 | } | |
126 | ||
127 | catch "exec $objdump -d $binfile" objdump_output | |
128 | ||
129 | regexp "\[ \t](jsr|bsr)\[ \t]" $objdump_output ignore calltype | |
130 | ||
131 | if [string match $calltype "bsr"] { | |
132 | set relaxed 1 | |
133 | } elseif [string match $calltype "jsr"] { | |
134 | set relaxed 0 | |
135 | } else { | |
136 | verbose "$testname: neither jsr nor bsr found" 1 | |
137 | verbose $objdump_output 2 | |
138 | fail $testname | |
139 | continue | |
140 | } | |
141 | ||
142 | if {$relaxed != $expect_relaxed} { | |
143 | verbose $objdump_output 2 | |
144 | fail $testname | |
145 | exit | |
146 | } else { | |
147 | pass $testname | |
148 | } | |
149 | } | |
150 | } | |
151 | ||
152 | run_sh64relaxtest $sh64relaxtests |