Re-add support for lbarx, lharx, stbcx. and sthcx. insns back to the E6500 cpu.
[binutils-gdb.git] / ld / testsuite / ld-m68k / m68k-got.exp
blob65aa36bcb8e4a57290c0a49e8dbd003e102e3724
1 # Expect script for run_dump_test based ld-m68k GOT tests.
2 # Copyright (C) 2008-2016 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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.
22 if { ![is_elf_format] || ![istarget m68k-*-*] } {
23 return
26 # 1 - 1
27 # 2 - 8189
28 # 3 - 8190
29 # 4 - 16382
30 # 5 - 16385
32 proc gen_got_test { testname } {
33 global srcdir
34 global subdir
36 if [catch { set ofd [open "tmpdir/$testname.s" w] } msg] {
37 perror "$msg"
38 unresolved $testname
39 return
42 switch -- $testname {
43 "got-12" {
44 set start 1
45 set count 8189
46 set xgot 0
48 "got-13" {
49 set start 1
50 set count 8190
51 set xgot 0
53 "got-14" {
54 set start 1
55 set count 16382
56 set xgot 0
58 "got-15" {
59 set start 1
60 set count 16385
61 set xgot 0
63 "got-34" {
64 set start 8190
65 set count 16382
66 set xgot 0
68 "got-35" {
69 set start 8190
70 set count 16385
71 set xgot 0
73 "xgot-15" {
74 set start 1
75 set count 16385
76 set xgot 1
80 set func [format "sum_%05d_%05d" $start $count]
81 puts $ofd "\t.text"
82 puts $ofd "\t.align 2"
83 puts $ofd "\t.globl $func"
84 puts $ofd "\t.type $func,@function"
85 puts $ofd "$func:"
86 puts $ofd "\tlink.w %fp,#0"
87 puts $ofd "\tmove.l %a5,-(%sp)"
88 puts $ofd "\tmove.l #_GLOBAL_OFFSET_TABLE_@GOTPC, %a5"
89 puts $ofd "\tlea (-6, %pc, %a5), %a5"
91 if { $xgot == 1 } {
92 set symbol [format "a%05d" $start]
93 incr start
94 puts $ofd "\tlea $symbol@GOT,%a0"
95 puts $ofd "\tadd.l %a5,%a0"
96 puts $ofd "\tmove.l (%a0),%a0"
97 puts $ofd "\tmove.l (%a0),%d1"
98 for { set i $start } { $i < $count } { incr i } {
99 set symbol [format "a%05d" $i]
100 puts $ofd "\tlea $symbol@GOT,%a0"
101 puts $ofd "\tadd.l %a5,%a0"
102 puts $ofd "\tmove.l (%a0),%a0"
103 puts $ofd "\tmove.l (%a0),%d0"
104 puts $ofd "\tadd.l %d0,%d1"
106 set symbol [format "a%05d" $count]
107 puts $ofd "\tlea $symbol@GOT,%a0"
108 puts $ofd "\tadd.l %a5,%a0"
109 puts $ofd "\tmove.l (%a0),%a0"
110 puts $ofd "\tmove.l (%a0),%d0"
111 puts $ofd "\tadd.l %d1,%d0"
112 } else {
113 set symbol [format "a%05d" $start]
114 incr start
115 puts $ofd "\tmove.l $symbol@GOT(%a5),%d0"
116 puts $ofd "\tmove.l %d0,%a0"
117 puts $ofd "\tmove.l (%a0),%d1"
118 for { set i $start } { $i < $count } { incr i } {
119 set symbol [format "a%05d" $i]
120 puts $ofd "\tmove.l $symbol@GOT(%a5),%d0"
121 puts $ofd "\tmove.l %d0,%a0"
122 puts $ofd "\tmove.l (%a0),%d0"
123 puts $ofd "\tadd.l %d0,%d1"
125 set symbol [format "a%05d" $count]
126 puts $ofd "\tmove.l $symbol@GOT(%a5),%d0"
127 puts $ofd "\tmove.l %d0,%a0"
128 puts $ofd "\tmove.l (%a0),%d0"
129 puts $ofd "\tadd.l %d1,%d0"
132 puts $ofd "\tmove.l (%sp)+,%a5"
133 puts $ofd "\tunlk %fp"
134 puts $ofd "\trts"
135 puts $ofd "\t.size $func, .-$func"
137 close $ofd
140 proc got_test { testname } {
141 global srcdir
142 global subdir
143 global objdir
145 if [catch { set ifd [open "$srcdir/$subdir/$testname.d" r] } msg] {
146 perror "$msg"
147 unresolved $testname
148 return
150 if [catch { set ofd [open "tmpdir/$testname.d" w] } msg] {
151 perror "$msg"
152 unresolved $testname
153 return
156 switch -- $testname {
157 "got-single-12-ok" {
158 puts $ofd "#source: $objdir/tmpdir/got-12.s"
159 set count 8189
161 "got-single-13-er" {
162 puts $ofd "#source: $objdir/tmpdir/got-13.s"
163 set count 0
165 "got-negative-14-ok" {
166 puts $ofd "#source: $objdir/tmpdir/got-14.s"
167 set count 16382
169 "got-negative-15-er" {
170 puts $ofd "#source: $objdir/tmpdir/got-15.s"
171 set count 0
173 "got-negative-12-13-14-34-ok" {
174 puts $ofd "#source: $objdir/tmpdir/got-12.s"
175 puts $ofd "#source: $objdir/tmpdir/got-13.s"
176 puts $ofd "#source: $objdir/tmpdir/got-14.s"
177 puts $ofd "#source: $objdir/tmpdir/got-34.s"
178 set count 16382
180 "got-negative-12-13-14-35-er" {
181 puts $ofd "#source: $objdir/tmpdir/got-12.s"
182 puts $ofd "#source: $objdir/tmpdir/got-13.s"
183 puts $ofd "#source: $objdir/tmpdir/got-14.s"
184 puts $ofd "#source: $objdir/tmpdir/got-35.s"
185 set count 0
187 "got-multigot-14-ok" {
188 puts $ofd "#source: $objdir/tmpdir/got-14.s"
189 set count 16382
191 "got-multigot-15-er" {
192 puts $ofd "#source: $objdir/tmpdir/got-15.s"
193 set count 0
195 "got-multigot-12-13-14-34-35-ok" {
196 puts $ofd "#source: $objdir/tmpdir/got-12.s"
197 puts $ofd "#source: $objdir/tmpdir/got-13.s"
198 puts $ofd "#source: $objdir/tmpdir/got-14.s"
199 puts $ofd "#source: $objdir/tmpdir/got-34.s"
200 puts $ofd "#source: $objdir/tmpdir/got-35.s"
201 set count 24578
203 "got-xgot-15-ok" {
204 puts $ofd "#source: $objdir/tmpdir/xgot-15.s"
205 set count 16385
207 "got-xgot-12-13-14-15-34-35-ok" {
208 puts $ofd "#source: $objdir/tmpdir/got-12.s"
209 puts $ofd "#source: $objdir/tmpdir/got-13.s"
210 puts $ofd "#source: $objdir/tmpdir/got-14.s"
211 puts $ofd "#source: $objdir/tmpdir/xgot-15.s"
212 puts $ofd "#source: $objdir/tmpdir/got-34.s"
213 puts $ofd "#source: $objdir/tmpdir/got-35.s"
214 set count 24581
218 while { [gets $ifd line] != -1 } {
219 puts $ofd $line
222 for { set i 0 } { $i < $count } { incr i } {
223 puts $ofd "^\[0-9a-f\]+ \[0-9a-f\]+ R_68K_GLOB_DAT 00000000 a\[0-9\]+ \\\+ 0"
226 close $ifd
227 close $ofd
228 run_dump_test "tmpdir/$testname"
231 gen_got_test got-12
232 gen_got_test got-13
233 gen_got_test got-14
234 gen_got_test got-15
235 gen_got_test got-34
236 gen_got_test got-35
237 gen_got_test xgot-15
239 run_dump_test "got-1"
240 got_test "got-single-12-ok"
241 got_test "got-single-13-er"
242 got_test "got-negative-14-ok"
243 got_test "got-negative-15-er"
244 got_test "got-negative-12-13-14-34-ok"
245 got_test "got-negative-12-13-14-35-er"
246 got_test "got-multigot-14-ok"
247 got_test "got-multigot-15-er"
248 got_test "got-multigot-12-13-14-34-35-ok"
249 got_test "got-xgot-15-ok"
250 got_test "got-xgot-12-13-14-15-34-35-ok"