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 reloc failures
- that is
, cases that
ld must not allow.
21 if ![istarget sh64
-*-*] {
25 if [istarget sh64
-*-linux
*] {
26 set emul32
"shlelf32_linux"
27 set oformat32
"elf32-sh64-linux"
30 } elseif
{ [istarget sh64
*-*-netbsd
*] ||
[istarget sh5
*-*-netbsd
*] } then {
31 set emul32
"shelf32_nbsd"
32 set oformat32
"elf32-sh64-nbsd"
33 set startsym
"__start"
35 set emul64
"shelf64_nbsd"
36 set oformat64
"elf64-sh64-nbsd"
39 set oformat32
"elf32-sh64"
43 set oformat64
"elf64-sh64"
46 # opcode
, asflags
, ldflags
, expected or
"" for fail
47 # opcode
blank means rebuild relfail.o and
set default as
/ld options
49 set sh64abi32relfailtests
{
51 { "" "-isa=shcompact -abi=32" "-m $emul32 -Ttext 0x1000 --oformat $oformat32" "" }
52 { "mov.l lab,r0;.align 3;lab:nop" "" "" "mov.l 1008" }
53 { "mov.l to0,r0" "" "" "mov.l 1010" }
54 { "mov.l to1,r0" "" "" "" }
55 { "mov.l to2,r0" "" "" "" }
56 { "mov.l to3,r0" "" "" "" }
57 { "mov.l to4,r0" "" "" "mov.l 1014" }
59 { "" "-isa=shmedia -abi=32 -no-expand" "-m $emul32 -Ttext 0x1000 --oformat $oformat32" "" }
60 { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
62 { "ld.q r0,datalabel to0 - 0x1000,r0" "" "" "ld.q.*,16," }
63 { "ld.q r0,datalabel to1 - 0x1000,r0" "" "" "" }
64 { "ld.q r0,datalabel to2 - 0x1000,r0" "" "" "" }
65 { "ld.q r0,datalabel to3 - 0x1000,r0" "" "" "" }
66 { "ld.q r0,datalabel to4 - 0x1000,r0" "" "" "" }
68 { "ld.l r0,datalabel to0 - 0x1000,r0" "" "" "ld.l.*,16," }
69 { "ld.l r0,datalabel to1 - 0x1000,r0" "" "" "" }
70 { "ld.l r0,datalabel to2 - 0x1000,r0" "" "" "" }
71 { "ld.l r0,datalabel to3 - 0x1000,r0" "" "" "" }
72 { "ld.l r0,datalabel to4 - 0x1000,r0" "" "" "ld.l.*,20," }
74 { "ld.w r0,datalabel to0 - 0x1000,r0" "" "" "ld.w.*,16," }
75 { "ld.w r0,datalabel to1 - 0x1000,r0" "" "" "" }
76 { "ld.w r0,datalabel to2 - 0x1000,r0" "" "" "ld.w.*,18," }
77 { "ld.w r0,datalabel to3 - 0x1000,r0" "" "" "" }
78 { "ld.w r0,datalabel to4 - 0x1000,r0" "" "" "ld.w.*,20," }
82 set sh64abi64relfailtests
{
84 { "" "-isa=shmedia -abi=64 -no-expand" "-m $emul64 -Ttext 0x1000 --oformat $oformat64" "" }
85 { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
86 { "pta datalabel to0,tr0" "" "" "pta.*1010" }
87 { "pta datalabel to1,tr0" "" "" "pta.*1011" }
88 { "pta datalabel to2,tr0" "" "" "" }
89 { "pta datalabel to3,tr0" "" "" "" }
90 { "pta datalabel to4,tr0" "" "" "pta.*1014" }
92 { "ld.q r0,datalabel to0 - 0x1000,r0" "" "" "ld.q.*,16," }
93 { "ld.q r0,datalabel to1 - 0x1000,r0" "" "" "" }
94 { "ld.q r0,datalabel to2 - 0x1000,r0" "" "" "" }
95 { "ld.q r0,datalabel to3 - 0x1000,r0" "" "" "" }
96 { "ld.q r0,datalabel to4 - 0x1000,r0" "" "" "" }
98 { "ld.l r0,datalabel to0 - 0x1000,r0" "" "" "ld.l.*,16," }
99 { "ld.l r0,datalabel to1 - 0x1000,r0" "" "" "" }
100 { "ld.l r0,datalabel to2 - 0x1000,r0" "" "" "" }
101 { "ld.l r0,datalabel to3 - 0x1000,r0" "" "" "" }
102 { "ld.l r0,datalabel to4 - 0x1000,r0" "" "" "ld.l.*,20," }
104 { "ld.w r0,datalabel to0 - 0x1000,r0" "" "" "ld.w.*,16," }
105 { "ld.w r0,datalabel to1 - 0x1000,r0" "" "" "" }
106 { "ld.w r0,datalabel to2 - 0x1000,r0" "" "" "ld.w.*,18," }
107 { "ld.w r0,datalabel to3 - 0x1000,r0" "" "" "" }
108 { "ld.w r0,datalabel to4 - 0x1000,r0" "" "" "ld.w.*,20," }
112 proc run_sh64relfailtests
{sh64relfailtests
} {
129 foreach testentry $sh64relfailtests
{
130 set opcode
[lindex $testentry
0]
131 set as_options
[lindex $testentry
1]
132 set ld_options
[subst
[lindex $testentry
2]]
133 set expect_fail
[lindex $testentry
3]
135 set testname
"SH64 relfail $opcode $as_options $ld_options"
142 set def_as_options $as_options
143 set def_ld_options $ld_options
145 set baseobj
"tmpdir/relfail-$testindex.o"
146 if ![ld_assemble $as
"$as_options $srcdir/$subdir/relfail.s" $baseobj] {
152 if {$as_options
== ""} {
153 set as_options $def_as_options
155 if {$ld_options
== ""} {
156 set ld_options $def_ld_options
159 if { $is_unresolved
} {
164 set asm
[open
"tmpdir/relfail-$testindex.s" "w"]
166 puts $asm
" .global $startsym"
167 puts $asm
"$startsym:"
171 if ![ld_assemble $as
"$as_options tmpdir/relfail-$testindex.s" "tmpdir/relfail-$testindex.o"] {
176 set binfile
"tmpdir/relfail-$testindex.x"
179 set objects
"tmpdir/relfail-$testindex.o $baseobj"
180 set result
[ld_simple_link $
ld $binfile
"--no-warn-mismatch $ld_options $objects"]
182 set exists [file
exists $binfile
]
183 if {$
exists && $expect_fail
== ""} {
184 verbose
"$testname: file $binfile exists when it shouldn't" 1
185 catch
"exec $objdump -d $binfile" objdump_output
186 verbose $objdump_output
1
187 fail
"$testname (file exists)"
190 if {!$
exists && $expect_fail
!= ""} {
191 verbose
"$testname: file $binfile doesn't exist when it should" 1
192 fail
"$testname (file missing)"
197 catch
"exec $objdump -d $binfile" objdump_output
198 regsub
-all
{[ ][ ]*} $objdump_output
" " objdump_short
199 if ![regexp $expect_fail $objdump_short junk
] {
200 verbose $objdump_output
1
201 fail
"$testname (incorrect reloc)"
206 file
delete "tmpdir/relfail-$testindex.s"
207 file
delete "tmpdir/relfail-$testindex.o"
213 run_sh64relfailtests $sh64abi32relfailtests
215 run_sh64relfailtests $sh64abi64relfailtests