Contribute sh64-elf.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-sh / sh64 / relfail.exp
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 reloc failures - that is, cases that ld must not allow.
20
21 if ![istarget sh64-*-*] {
22 return
23 }
24
25 # opcode, asflags, ldflags, expected or "" for fail
26 # opcode blank means rebuild relfail.o and set default as/ld options
27
28 set sh64relfailtests {
29
30 { "" "-isa=shcompact -abi=32" "-m shelf32 --oformat elf32-sh" "" }
31 { "mov.l lab,r0;.align 3;lab:nop" "" "" "mov.l 1008" }
32 { "mov.l to0,r0" "" "" "mov.l 1010" }
33 { "mov.l to1,r0" "" "" "" }
34 { "mov.l to2,r0" "" "" "" }
35 { "mov.l to3,r0" "" "" "" }
36 { "mov.l to4,r0" "" "" "mov.l 1014" }
37
38 { "" "-isa=shmedia -abi=64 -no-expand" "-m shelf64 --oformat elf64-sh64" "" }
39 { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
40 { "pta datalabel to0,tr0" "" "" "pta.*1010" }
41 { "pta datalabel to1,tr0" "" "" "pta.*1011" }
42 { "pta datalabel to2,tr0" "" "" "" }
43 { "pta datalabel to3,tr0" "" "" "" }
44 { "pta datalabel to4,tr0" "" "" "pta.*1014" }
45
46 { "ld.q r0,datalabel to0 - 0x1000,r0" "" "" "ld.q.*,16," }
47 { "ld.q r0,datalabel to1 - 0x1000,r0" "" "" "" }
48 { "ld.q r0,datalabel to2 - 0x1000,r0" "" "" "" }
49 { "ld.q r0,datalabel to3 - 0x1000,r0" "" "" "" }
50 { "ld.q r0,datalabel to4 - 0x1000,r0" "" "" "" }
51
52 { "ld.l r0,datalabel to0 - 0x1000,r0" "" "" "ld.l.*,16," }
53 { "ld.l r0,datalabel to1 - 0x1000,r0" "" "" "" }
54 { "ld.l r0,datalabel to2 - 0x1000,r0" "" "" "" }
55 { "ld.l r0,datalabel to3 - 0x1000,r0" "" "" "" }
56 { "ld.l r0,datalabel to4 - 0x1000,r0" "" "" "ld.l.*,20," }
57
58 { "ld.w r0,datalabel to0 - 0x1000,r0" "" "" "ld.w.*,16," }
59 { "ld.w r0,datalabel to1 - 0x1000,r0" "" "" "" }
60 { "ld.w r0,datalabel to2 - 0x1000,r0" "" "" "ld.w.*,18," }
61 { "ld.w r0,datalabel to3 - 0x1000,r0" "" "" "" }
62 { "ld.w r0,datalabel to4 - 0x1000,r0" "" "" "ld.w.*,20," }
63
64 }
65
66 proc run_sh64relfailtests {sh64relfailtests} {
67 global ld
68 global as
69 global nm
70 global objdump
71 global readelf
72 global srcdir
73 global subdir
74
75 set testindex 0
76 set is_unresolved 0
77
78 foreach testentry $sh64relfailtests {
79 set opcode [lindex $testentry 0]
80 set as_options [lindex $testentry 1]
81 set ld_options [lindex $testentry 2]
82 set expect_fail [lindex $testentry 3]
83
84 set testname "SH64 relfail $opcode $as_options $ld_options"
85
86 set objfiles {}
87
88 incr testindex
89
90 if {$opcode == ""} {
91 set def_as_options $as_options
92 set def_ld_options $ld_options
93 set is_unresolved 0
94 set baseobj "tmpdir/relfail-$testindex.o"
95 if ![ld_assemble $as "$as_options $srcdir/$subdir/relfail.s" $baseobj] {
96 set is_unresolved 1
97 }
98 continue
99 }
100
101 if {$as_options == ""} {
102 set as_options $def_as_options;
103 }
104 if {$ld_options == ""} {
105 set ld_options $def_ld_options;
106 }
107
108 if { $is_unresolved } {
109 unresolved $testname
110 continue
111 }
112
113 set asm [open "tmpdir/relfail-$testindex.s" "w"]
114 puts $asm " .text"
115 puts $asm " .global start"
116 puts $asm "start:"
117 puts $asm " $opcode";
118 close $asm
119
120 if ![ld_assemble $as "$as_options tmpdir/relfail-$testindex.s" "tmpdir/relfail-$testindex.o"] {
121 unresolved $testname
122 continue
123 }
124
125 set binfile "tmpdir/relfail-$testindex.x"
126
127 file delete $binfile
128 set objects "tmpdir/relfail-$testindex.o $baseobj"
129 set result [ld_simple_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
130
131 set exists [file exists $binfile]
132 if {$exists && $expect_fail == ""} {
133 verbose "$testname: file $binfile exists when it shouldn't" 1
134 catch "exec $objdump -d $binfile" objdump_output
135 verbose $objdump_output 1
136 fail "$testname (file exists)"
137 continue
138 }
139 if {!$exists && $expect_fail != ""} {
140 verbose "$testname: file $binfile doesn't exist when it should" 1
141 fail "$testname (file missing)"
142 continue
143 }
144
145 if {$exists} {
146 catch "exec $objdump -d $binfile" objdump_output
147 regsub -all {[ ][ ]*} $objdump_output " " objdump_short
148 if ![regexp $expect_fail $objdump_short junk] {
149 verbose $objdump_output 1
150 fail "$testname (incorrect reloc)"
151 continue
152 }
153 }
154
155 file delete "tmpdir/relfail-$testindex.s"
156 file delete "tmpdir/relfail-$testindex.o"
157 file delete $binfile
158 pass $testname
159 }
160 }
161
162 run_sh64relfailtests $sh64relfailtests
This page took 0.040395 seconds and 5 git commands to generate.