OSDN Git Service

Update FSF addresses
[pf3gnuchains/pf3gnuchains4x.git] / ld / testsuite / ld-sh / sh64 / relfail.exp
1 # Expect script for ld-sh tests
2 #   Copyright (C) 2001, 2002, 2003, 2004 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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 if [istarget sh64-*-linux*] {
26     set emul32 "shlelf32_linux"
27     set oformat32 "elf32-sh64-linux"
28     set startsym "_start"
29     set doabi64 0
30 } elseif { [istarget sh64*-*-netbsd*] || [istarget sh5*-*-netbsd*] } then {
31     set emul32 "shelf32_nbsd"
32     set oformat32 "elf32-sh64-nbsd"
33     set startsym "__start"
34     set doabi64 1
35     set emul64 "shelf64_nbsd"
36     set oformat64 "elf64-sh64-nbsd"
37 } else {
38     set emul32 "shelf32"
39     set oformat32 "elf32-sh64"
40     set startsym "start"
41     set doabi64 1
42     set emul64 "shelf64"
43     set oformat64 "elf64-sh64"
44 }
45
46 # opcode, asflags, ldflags, expected or "" for fail
47 # opcode blank means rebuild relfail.o and set default as/ld options
48
49 set sh64abi32relfailtests {
50
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" }
58
59     { "" "-isa=shmedia -abi=32 -no-expand" "-m $emul32 -Ttext 0x1000 --oformat $oformat32" "" }
60     { "pta lab,tr0;.align 3;lab:nop" "" "" "pta.*1008" }
61
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" "" "" "" }
67
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," }
73
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," }
79
80 }
81
82 set sh64abi64relfailtests {
83
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" }
91
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" "" "" "" }
97
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," }
103
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," }
109
110 }
111
112 proc run_sh64relfailtests {sh64relfailtests} {
113     global ld
114     global as
115     global nm
116     global objdump
117     global readelf
118     global srcdir
119     global subdir
120     global emul32
121     global emul64
122     global oformat32
123     global oformat64
124     global startsym
125
126     set testindex 0
127     set is_unresolved 0
128
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]
134         
135         set testname "SH64 relfail $opcode $as_options $ld_options"
136         
137         set objfiles {}
138         
139         incr testindex
140         
141         if {$opcode == ""} {
142             set def_as_options $as_options
143             set def_ld_options $ld_options
144             set is_unresolved 0
145             set baseobj "tmpdir/relfail-$testindex.o"
146             if ![ld_assemble $as "$as_options $srcdir/$subdir/relfail.s" $baseobj] {
147                 set is_unresolved 1
148             }
149             continue
150         }
151         
152         if {$as_options == ""} {
153             set as_options $def_as_options
154         }
155         if {$ld_options == ""} {
156             set ld_options $def_ld_options
157         }
158         
159         if { $is_unresolved } {
160             unresolved $testname
161             continue
162         }
163         
164         set asm [open "tmpdir/relfail-$testindex.s" "w"]
165         puts $asm " .text"
166         puts $asm " .global $startsym"
167         puts $asm "$startsym:"
168         puts $asm " $opcode"
169         close $asm
170         
171         if ![ld_assemble $as "$as_options tmpdir/relfail-$testindex.s" "tmpdir/relfail-$testindex.o"] {
172             unresolved $testname
173             continue
174         }
175         
176         set binfile "tmpdir/relfail-$testindex.x"
177         
178         file delete $binfile
179         set objects "tmpdir/relfail-$testindex.o $baseobj"
180         set result [ld_simple_link $ld $binfile "--no-warn-mismatch $ld_options $objects"]
181         
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)"
188             continue
189         }
190         if {!$exists && $expect_fail != ""} {
191             verbose "$testname: file $binfile doesn't exist when it should" 1
192             fail "$testname (file missing)"
193             continue
194         }
195         
196         if {$exists} {
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)"
202                 continue
203             }
204         }
205         
206         file delete "tmpdir/relfail-$testindex.s"
207         file delete "tmpdir/relfail-$testindex.o"
208         file delete $binfile
209         pass $testname
210     }
211 }
212
213 run_sh64relfailtests $sh64abi32relfailtests
214 if {$doabi64} {
215     run_sh64relfailtests $sh64abi64relfailtests
216 }