Fix some AVR test failures.
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / sec64k.exp
CommitLineData
0e406595 1# Expect script for tests for >64k sections
6f2750fe 2# Copyright (C) 2002-2016 Free Software Foundation, Inc.
0e406595 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
0e406595 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
0e406595
AM
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
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
0e406595
AM
20#
21# Written by Hans-Peter Nilsson (hp@axis.com)
22#
23
24# Exclude non-ELF targets.
25
43f9d75b 26if ![is_elf_format] {
0e406595
AM
27 return
28}
29
78336cd6
AM
30# Targets using the generic linker backend don't sort section symbols
31# before local symbols, so don't bother testing them.
9a5f28ae 32if { [istarget "arc*-*-*"]
78336cd6
AM
33 || [istarget "d30v-*-*"]
34 || [istarget "dlx-*-*"]
35 || [istarget "i960-*-*"]
13761a11 36 || [istarget "msp430*-*-*"]
73589c9d 37 || [istarget "or1k*-*-*"]
78336cd6
AM
38 || [istarget "pj*-*-*"]
39 || [istarget "m32r-*-*"] } {
40 return
41}
42
b3066ae8
AM
43# m68hc11, m68hc12 and xgate run out of address space.
44if { [istarget "m68hc1*-*"] || [istarget "xgate-*"] } {
45 return
46}
47
0e406595
AM
48# Test >64k sections, with and without -r. First, create the assembly
49# files. Have a relocation to another section and one within the local
50# section.
51
52set test1 "64ksec-r"
53set test2 "64ksec"
54
55if { ![runtest_file_p $runtests $test1] \
56 && ![runtest_file_p $runtests $test2] } {
57 return
58}
59
60set sfiles {}
61set max_sec 66000
62set secs_per_file 1000
0e406595
AM
63for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } {
64 set sfile "$objdir/tmpdir/sec64-$i.s"
65 lappend sfiles $sfile
66 if [catch { set ofd [open $sfile w] } x] {
67 perror "$x"
68 unresolved $test1
69 unresolved $test2
70 return
71 }
72
9ab80182 73 if { $i == 0 } {
bac7e529
AM
74 puts $ofd " .global start"
75 puts $ofd "start:"
0e406595
AM
76 puts $ofd " .global _start"
77 puts $ofd "_start:"
bac7e529 78 puts $ofd " .global __start"
1cb571e9 79 puts $ofd "__start:"
bac7e529
AM
80 puts $ofd " .global main"
81 puts $ofd "main:"
0e406595 82 puts $ofd " .global foo_0"
bac7e529 83 puts $ofd "foo_0: .dc.a 0"
0e406595
AM
84 }
85
86 # Make sure the used section is not covered by common linker scripts.
87 # They should get separate section entries even without -r.
9ab80182
JB
88 puts $ofd " .altmacro"
89 puts $ofd " .macro sec secn, secp"
53b0eb27
AM
90 if {![istarget "frv-*-*linux*"]} then {
91 puts $ofd " .section .foo.\\secn,\"ax\""
92 } else {
93 puts $ofd " .section .foo.\\secn,\"aw\""
94 }
9ab80182
JB
95 puts $ofd " .global foo_\\secn"
96 puts $ofd "foo_\\secn:"
bac7e529 97 puts $ofd " .dc.a foo_\\secp"
9ab80182 98 puts $ofd "bar_\\secn:"
bac7e529 99 puts $ofd " .dc.a bar_\\secn"
9ab80182 100 puts $ofd " .endm"
f8739b83
JZ
101 if {![istarget "bfin-*-*"]} then {
102 puts $ofd " secn = [expr $i * $secs_per_file]"
103 } else {
104 puts $ofd " .set secn, [expr $i * $secs_per_file]"
105 }
9ab80182 106 puts $ofd " .rept $secs_per_file"
f8739b83
JZ
107 if {![istarget "bfin-*-*"]} then {
108 puts $ofd " secn = secn + 1"
109 } else {
110 puts $ofd " .set secn, secn + 1"
111 }
9ab80182
JB
112 puts $ofd " sec %(secn), %(secn-1)"
113 puts $ofd " .endr"
0e406595
AM
114
115 close $ofd
116}
117
118if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
119 perror "$x"
120 unresolved $test1
121 unresolved $test2
122 return
123}
124
125# The ld-r linked file will contain relocation-sections too, so make it
126# half the size in order to try and keep the test-time down.
cc9fe443
NC
127
128# The m32r target generates both REL and RELA relocs (for historical
129# reasons) so the expected number of sections will be much more than
130# 68000, which throws this particular test right off.
78336cd6 131if { ![istarget "m32r-*-*"] } then {
cc9fe443
NC
132 foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
133 puts $ofd "#source: $sfile"
134 }
135 puts $ofd "#ld: -r"
136 puts $ofd "#readelf: -W -Ss"
137 puts $ofd "There are 680.. section headers.*:"
138 puts $ofd "#..."
4fbb74a6 139 puts $ofd " \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
cc9fe443
NC
140 puts $ofd "#..."
141 puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
142 puts $ofd "#..."
143 puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
4fbb74a6 144 puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
cc9fe443
NC
145 puts $ofd "#..."
146 puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
147 puts $ofd "#..."
78336cd6 148 puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-5\] bar_1$"
cc9fe443
NC
149 puts $ofd "#..."
150 puts $ofd ".* bar_34000$"
151 puts $ofd "#..."
152 # Global symbols are not in "alphanumeric" order, so we just check
153 # that the first and the last are present in any order (assuming no
154 # duplicates).
155 puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
156 puts $ofd "#..."
157 puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
158 puts $ofd "#pass"
159 close $ofd
160 run_dump_test "tmpdir/$test1"
0e406595 161}
0e406595
AM
162
163if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
164 perror "$x"
165 unresolved $test2
166 return
167}
78336cd6 168
4a85cc09 169# too big for avr, d10v and msp
78336cd6
AM
170# lack of fancy orphan section handling causes overlap on fr30 and iq2000
171if { ![istarget "d10v-*-*"]
4a85cc09 172 && ![istarget "avr-*-*"]
78336cd6
AM
173 && ![istarget "msp*-*-*"]
174 && ![istarget "fr30-*-*"]
175 && ![istarget "iq2000-*-*"] } {
176 foreach sfile $sfiles { puts $ofd "#source: $sfile" }
4a85cc09 177 if { [istarget spu*-*-*] } {
78336cd6
AM
178 puts $ofd "#ld: --local-store 0:0"
179 } else {
180 puts $ofd "#ld:"
181 }
182 puts $ofd "#readelf: -W -Ss"
183 puts $ofd "There are 660.. section headers.*:"
184 puts $ofd "#..."
185 puts $ofd " \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0"
186 puts $ofd "#..."
187 puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
188 puts $ofd " \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
189 puts $ofd "#..."
190 puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. "
191 puts $ofd "#..."
192 puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
193 puts $ofd "#..."
194 puts $ofd ".* bar_66000$"
195 puts $ofd "#..."
196 # Global symbols are not in "alphanumeric" order, so we just check
197 # that the first and the last are present in any order (assuming no
198 # duplicates).
199 puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
200 puts $ofd "#..."
201 puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
202 puts $ofd "#pass"
203 close $ofd
204 run_dump_test "tmpdir/$test2"
e9f53129 205}
9ab80182
JB
206
207for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
208 catch "exec rm -f tmpdir/dump$i.o" status
209}
This page took 0.573517 seconds and 4 git commands to generate.