ChangeLog rotatation and copyright year update
[deliverable/binutils-gdb.git] / ld / testsuite / ld-sh / sh64 / relfail.exp
1 # Expect script for ld-sh tests
2 # Copyright (C) 2001-2015 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # Test SH reloc failures - that is, cases that ld must not allow.
23
24 if ![istarget sh64-*-*] {
25 return
26 }
27
28 if [istarget sh64-*-linux*] {
29 set emul32 "shlelf32_linux"
30 set oformat32 "elf32-sh64-linux"
31 set startsym "_start"
32 set doabi64 0
33 } elseif { [istarget sh64*-*-netbsd*] || [istarget sh5*-*-netbsd*] } then {
34 set emul32 "shelf32_nbsd"
35 set oformat32 "elf32-sh64-nbsd"
36 set startsym "__start"
37 set doabi64 1
38 set emul64 "shelf64_nbsd"
39 set oformat64 "elf64-sh64-nbsd"
40 } else {
41 set emul32 "shelf32"
42 set oformat32 "elf32-sh64"
43 set startsym "start"
44 set doabi64 1
45 set emul64 "shelf64"
46 set oformat64 "elf64-sh64"
47 }
48
49 # opcode, asflags, ldflags, expected or "" for fail
50 # opcode blank means rebuild relfail.o and set default as/ld options
51
52 set sh64abi32relfailtests {
53
54 { "" "-isa=shcompact -abi=32" "-m $emul32 -Ttext 0x1000 --oformat $oformat32" "" }
55 { "mov.l lab,r0;.align 3;lab:nop" "" "" "mov.l 1008" }
56 { "mov.l to0,r0" "" "" "mov.l 1010" }
57 { "mov.l to1,r0" "" "" "" }
58 { "mov.l to2,r0" "" "" "" }
59 { "mov.l to3,r0" "" "" "" }
60 { "mov.l to4,r0" "" "" "mov.l 1014" }
61
62 { "" "-isa=shmedia -abi=32 -no-expand" "-m $emul32 -Ttext 0x1000 --oformat $oformat32" "" }
63 { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
64
65 { "ld.q r0,datalabel to0 - 0x1000,r0" "" "" "ld.q.*,16," }
66 { "ld.q r0,datalabel to1 - 0x1000,r0" "" "" "" }
67 { "ld.q r0,datalabel to2 - 0x1000,r0" "" "" "" }
68 { "ld.q r0,datalabel to3 - 0x1000,r0" "" "" "" }
69 { "ld.q r0,datalabel to4 - 0x1000,r0" "" "" "" }
70
71 { "ld.l r0,datalabel to0 - 0x1000,r0" "" "" "ld.l.*,16," }
72 { "ld.l r0,datalabel to1 - 0x1000,r0" "" "" "" }
73 { "ld.l r0,datalabel to2 - 0x1000,r0" "" "" "" }
74 { "ld.l r0,datalabel to3 - 0x1000,r0" "" "" "" }
75 { "ld.l r0,datalabel to4 - 0x1000,r0" "" "" "ld.l.*,20," }
76
77 { "ld.w r0,datalabel to0 - 0x1000,r0" "" "" "ld.w.*,16," }
78 { "ld.w r0,datalabel to1 - 0x1000,r0" "" "" "" }
79 { "ld.w r0,datalabel to2 - 0x1000,r0" "" "" "ld.w.*,18," }
80 { "ld.w r0,datalabel to3 - 0x1000,r0" "" "" "" }
81 { "ld.w r0,datalabel to4 - 0x1000,r0" "" "" "ld.w.*,20," }
82
83 }
84
85 set sh64abi64relfailtests {
86
87 { "" "-isa=shmedia -abi=64 -no-expand" "-m $emul64 -Ttext 0x1000 --oformat $oformat64" "" }
88 { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
89 { "pta datalabel to0,tr0" "" "" "pta.*1010" }
90 { "pta datalabel to1,tr0" "" "" "pta.*1011" }
91 { "pta datalabel to2,tr0" "" "" "" }
92 { "pta datalabel to3,tr0" "" "" "" }
93 { "pta datalabel to4,tr0" "" "" "pta.*1014" }
94
95 { "ld.q r0,datalabel to0 - 0x1000,r0" "" "" "ld.q.*,16," }
96 { "ld.q r0,datalabel to1 - 0x1000,r0" "" "" "" }
97 { "ld.q r0,datalabel to2 - 0x1000,r0" "" "" "" }
98 { "ld.q r0,datalabel to3 - 0x1000,r0" "" "" "" }
99 { "ld.q r0,datalabel to4 - 0x1000,r0" "" "" "" }
100
101 { "ld.l r0,datalabel to0 - 0x1000,r0" "" "" "ld.l.*,16," }
102 { "ld.l r0,datalabel to1 - 0x1000,r0" "" "" "" }
103 { "ld.l r0,datalabel to2 - 0x1000,r0" "" "" "" }
104 { "ld.l r0,datalabel to3 - 0x1000,r0" "" "" "" }
105 { "ld.l r0,datalabel to4 - 0x1000,r0" "" "" "ld.l.*,20," }
106
107 { "ld.w r0,datalabel to0 - 0x1000,r0" "" "" "ld.w.*,16," }
108 { "ld.w r0,datalabel to1 - 0x1000,r0" "" "" "" }
109 { "ld.w r0,datalabel to2 - 0x1000,r0" "" "" "ld.w.*,18," }
110 { "ld.w r0,datalabel to3 - 0x1000,r0" "" "" "" }
111 { "ld.w r0,datalabel to4 - 0x1000,r0" "" "" "ld.w.*,20," }
112
113 }
114
115 proc run_sh64relfailtests {sh64relfailtests} {
116 global ld
117 global as
118 global nm
119 global objdump
120 global readelf
121 global srcdir
122 global subdir
123 global emul32
124 global emul64
125 global oformat32
126 global oformat64
127 global startsym
128
129 set testindex 0
130 set is_unresolved 0
131
132 foreach testentry $sh64relfailtests {
133 set opcode [lindex $testentry 0]
134 set as_options [lindex $testentry 1]
135 set ld_options [subst [lindex $testentry 2]]
136 set expect_fail [lindex $testentry 3]
137
138 set testname "SH64 relfail $opcode $as_options $ld_options"
139
140 set objfiles {}
141
142 incr testindex
143
144 if {$opcode == ""} {
145 set def_as_options $as_options
146 set def_ld_options $ld_options
147 set is_unresolved 0
148 set baseobj "tmpdir/relfail-$testindex.o"
149 if ![ld_assemble $as "$as_options $srcdir/$subdir/relfail.s" $baseobj] {
150 set is_unresolved 1
151 }
152 continue
153 }
154
155 if {$as_options == ""} {
156 set as_options $def_as_options
157 }
158 if {$ld_options == ""} {
159 set ld_options $def_ld_options
160 }
161
162 if { $is_unresolved } {
163 unresolved $testname
164 continue
165 }
166
167 set asm [open "tmpdir/relfail-$testindex.s" "w"]
168 puts $asm " .text"
169 puts $asm " .global $startsym"
170 puts $asm "$startsym:"
171 puts $asm " $opcode"
172 close $asm
173
174 if ![ld_assemble $as "$as_options tmpdir/relfail-$testindex.s" "tmpdir/relfail-$testindex.o"] {
175 unresolved $testname
176 continue
177 }
178
179 set binfile "tmpdir/relfail-$testindex.x"
180
181 file delete $binfile
182 set objects "tmpdir/relfail-$testindex.o $baseobj"
183 set result [ld_simple_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
184
185 set exists [file exists $binfile]
186 if {$exists && $expect_fail == ""} {
187 verbose "$testname: file $binfile exists when it shouldn't" 1
188 catch "exec $objdump -d $binfile" objdump_output
189 verbose $objdump_output 1
190 fail "$testname (file exists)"
191 continue
192 }
193 if {!$exists && $expect_fail != ""} {
194 verbose "$testname: file $binfile doesn't exist when it should" 1
195 fail "$testname (file missing)"
196 continue
197 }
198
199 if {$exists} {
200 catch "exec $objdump -d $binfile" objdump_output
201 regsub -all {[ ][ ]*} $objdump_output " " objdump_short
202 if ![regexp $expect_fail $objdump_short junk] {
203 verbose $objdump_output 1
204 fail "$testname (incorrect reloc)"
205 continue
206 }
207 }
208
209 file delete "tmpdir/relfail-$testindex.s"
210 file delete "tmpdir/relfail-$testindex.o"
211 file delete $binfile
212 pass $testname
213 }
214 }
215
216 run_sh64relfailtests $sh64abi32relfailtests
217 if {$doabi64} {
218 run_sh64relfailtests $sh64abi64relfailtests
219 }
This page took 0.034746 seconds and 4 git commands to generate.