* simple.c: Correct placement of ATTRIBUTE_UNUSED.
[deliverable/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
24d1feef
SC
36if [istarget sh64*-*-linux*] {
37 set emul32 "shlelf32_linux"
38} else {
39 set emul32 "shelf32"
40}
41
1b19eb81
AO
42set sh64relaxtests {
43 {"SH64 not relaxing, shcompact"
24d1feef 44 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-m$emul32" 0}
1b19eb81 45 {"SH64 relaxing, shcompact"
24d1feef 46 {"-relax -isa shcompact" "n/a" "n/a" "n/a"} "-relax -m$emul32" 1}
1b19eb81 47 {"SH64 relaxing, shcompacts"
24d1feef 48 {"-relax -isa shcompact" "-isa shcompact" "n/a" "n/a"} "-relax -m$emul32" 1}
1b19eb81 49 {"SH64 relaxing disabled, shmedia"
24d1feef 50 {"-relax -isa shcompact" "-isa shmedia -no-mix" "n/a" "n/a"} "-relax -m$emul32" 0}
1b19eb81 51 {"SH64 relaxing disabled, mixed"
24d1feef 52 {"-relax -isa shcompact" "n/a" "-isa shcompact" "n/a"} "-relax -m$emul32" 0}
1b19eb81 53 {"SH64 relaxing disabled, cranges"
24d1feef 54 {"-relax -isa shcompact" "n/a" "n/a" ""} "-relax -m$emul32" 0}
1b19eb81
AO
55}
56
57proc run_sh64relaxtest {sh64relaxtests} {
58 global ld
59 global as
60 global nm
61 global objdump
62 global readelf
63 global srcdir
64 global subdir
24d1feef 65 global emul32
1b19eb81
AO
66
67 set testindex 0
68
69 set sh64relaxfiles {
70 "relax1.s" "relax2.s" "relax3.s" "relax4.s"
71 }
72
73 foreach testentry $sh64relaxtests {
74 set testname [lindex $testentry 0]
75 set as_options [lindex $testentry 1]
24d1feef 76 set ld_options [subst [lindex $testentry 2]]
1b19eb81
AO
77 set expect_relaxed [lindex $testentry 3]
78
79 set is_unresolved 0
80 set objfiles {}
81
82 incr testindex
83
84 # Assemble each file in the test.
85 for {set i 0} {$i < 4} {incr i} {
86 set as_file [lindex $sh64relaxfiles $i]
87 set as_opt [lindex $as_options $i]
88 if { [string compare $as_opt "n/a"] != 0 } {
89 set objfile "tmpdir/[file rootname $as_file]-$testindex.o"
90 lappend objfiles $objfile
91
92 if ![ld_assemble $as "$as_opt $srcdir/$subdir/$as_file" $objfile] {
93 set is_unresolved 1
94 break
95 }
96 }
97 }
98
99 # Catch assembler errors.
100 if { $is_unresolved != 0 } {
101 unresolved $testname
102 continue
103 }
104
105 set binfile "tmpdir/relax-$testindex.x"
106
107 # We're not interested in the pass/fail of the linker as much
108 # as we're interested in whether or not relaxing got properly
109 # disabled. Hence the lax checking here.
110
111 file delete $binfile
112 set result [ld_simple_link $ld $binfile " --no-warn-mismatch $ld_options $objfiles"]
113 if ![file exists $binfile] {
114
115 if {$expect_relaxed == -1} {
116 pass $testname
117 continue;
118 }
119
120 verbose "$testname: file $binfile doesn't exist" 1
121 fail $testname
122 continue
123 }
124
125 catch "exec $objdump -d $binfile" objdump_output
126
127 regexp "\[ \t](jsr|bsr)\[ \t]" $objdump_output ignore calltype
128
129 if [string match $calltype "bsr"] {
130 set relaxed 1
131 } elseif [string match $calltype "jsr"] {
132 set relaxed 0
133 } else {
134 verbose "$testname: neither jsr nor bsr found" 1
135 verbose $objdump_output 2
136 fail $testname
137 continue
138 }
139
140 if {$relaxed != $expect_relaxed} {
141 verbose $objdump_output 2
142 fail $testname
143 exit
144 } else {
145 pass $testname
146 }
147 }
148}
149
150run_sh64relaxtest $sh64relaxtests
This page took 0.103396 seconds and 4 git commands to generate.