Update release readme after making 2.43.1 release
[binutils-gdb.git] / ld / testsuite / ld-elf / sec64k.exp
blob1eddfd261458212a138d13b2525808914db41359
1 # Expect script for tests for >64k sections
2 #   Copyright (C) 2002-2024 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.
21 # Written by Hans-Peter Nilsson (hp@axis.com)
24 # Exclude non-ELF targets.
26 if ![is_elf_format] {
27     return
30 # Targets using _bfd_generic_final_link don't sort section symbols
31 # before local symbols, so don't bother testing them.
32 if { [is_generic] } {
33     return
36 # ft32, h8300, ip2k, m68hc11 and m68hc12 run out of address space.
37 if {[istarget "ft32-*-*"]
38     || [istarget "h8300-*-*"]
39     || [istarget "ip2k-*-*"]
40     || [istarget "m68hc1*-*"] } {
41     return
44 # Test >64k sections, with and without -r.  First, create the assembly
45 # files.  Have a relocation to another section and one within the local
46 # section.
48 set test1 "64ksec-r"
49 set test2 "64ksec"
51 if { ![runtest_file_p $runtests $test1] \
52         && ![runtest_file_p $runtests $test2] } {
53     return
56 set sfiles {}
57 set max_sec 66000
58 set secs_per_file 1000
59 for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } {
60     set sfile "./tmpdir/sec64-$i.s"
61     lappend sfiles $sfile
62     if [catch { set ofd [open $sfile w] } x] {
63         perror "$x"
64         unresolved $test1
65         unresolved $test2
66         return
67     }
69     if { $i == 0 } {
70         puts $ofd " .global start"
71         puts $ofd "start:"
72         puts $ofd " .global _start"
73         puts $ofd "_start:"
74         puts $ofd " .global __start"
75         puts $ofd "__start:"
76         puts $ofd " .global main"
77         puts $ofd "main:"
78         puts $ofd " .global _main"
79         puts $ofd "_main:"
80         puts $ofd " .global foo_0"
81         puts $ofd "foo_0: .dc.a 0"
82     }
84     # Make sure the used section is not covered by common linker scripts.
85     # They should get separate section entries even without -r.
86     puts $ofd " .altmacro"
87     puts $ofd " .macro sec secn, secp"
88     if {![istarget "frv-*-*linux*"]} then {
89         puts $ofd "  .section .foo.\\secn,\"ax\""
90     } else {
91         puts $ofd "  .section .foo.\\secn,\"aw\""
92     }
93     puts $ofd "  .global foo_\\secn"
94     puts $ofd "foo_\\secn:"
95     puts $ofd "  .dc.a foo_\\secp"
96     puts $ofd "bar_\\secn:"
97     puts $ofd "  .dc.a bar_\\secn"
98     puts $ofd " .endm"
99     if {![istarget "bfin-*-*"]} then {
100         puts $ofd " secn = [expr $i * $secs_per_file]"
101     } else {
102         puts $ofd " .set secn, [expr $i * $secs_per_file]"
103     }
104     puts $ofd " .rept $secs_per_file"
105     if {![istarget "bfin-*-*"]} then {
106         puts $ofd "  secn = secn + 1"
107     } else {
108         puts $ofd "  .set secn, secn + 1"
109     }
110     puts $ofd "  sec %(secn), %(secn-1)"
111     puts $ofd " .endr"
113     close $ofd
116 if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
117     perror "$x"
118     unresolved $test1
119     unresolved $test2
120     return
123 # The ld-r linked file will contain relocation-sections too, so make it
124 # half the size in order to try and keep the test-time down.
126 # The m32r target generates both REL and RELA relocs (for historical
127 # reasons) so the expected number of sections will be much more than
128 # 68000, which throws this particular test right off.
129 if { ![istarget "m32r-*-*"] } then {
130     foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
131         puts $ofd "#source: $sfile"
132     }
133     #force z80 target to compile for eZ80 in ADL mode
134     if { [istarget "z80-*-*"] } then {
135         puts $ofd "#as: -ez80-adl"
136     }
137     puts $ofd "#ld: -r"
138     puts $ofd "#readelf: -W -wN -Ss"
139     puts $ofd "There are 680.. section headers.*:"
140     puts $ofd "#..."
141     puts $ofd "  \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
142     puts $ofd "#..."
143     puts $ofd "  \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
144     puts $ofd "#..."
145     puts $ofd "  \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
146     puts $ofd "  \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
147     puts $ofd "#..."
148     puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... .*"
149     puts $ofd "#..."
150     puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-7\] bar_1$"
151     puts $ofd "#..."
152     puts $ofd ".* bar_34000$"
153     puts $ofd "#..."
154     # Global symbols are not in "alphanumeric" order, so we just check
155     # that the first and the last are present in any order (assuming no
156     # duplicates).
157     puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
158     puts $ofd "#..."
159     puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
160     puts $ofd "#pass"
161     close $ofd
162     run_dump_test "tmpdir/$test1"
165 if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
166     perror "$x"
167     unresolved $test2
168     return
171 # too big for avr, d10v and msp
172 # lack of fancy orphan section handling causes overlap on fr30 and iq2000
173 # bfin and lm32 complain about relocations in read-only sections
174 if { ![istarget "d10v-*-*"]
175      && ![istarget "avr-*-*"]
176      && ![istarget "msp*-*-*"]
177      && ![istarget "fr30-*-*"] 
178      && ![istarget "iq2000-*-*"]
179      && ![istarget "bfin-*-linux*"]
180      && ![istarget "lm32-*-linux*"]
181      && ![istarget "pru-*-*"] } {
182     foreach sfile $sfiles { puts $ofd "#source: $sfile" }
183     if { [istarget spu*-*-*] } {
184         puts $ofd "#ld: --local-store 0:0"
185     } elseif { [istarget "i?86-*-linux*"] || [istarget "x86_64-*-linux*"] } {
186         puts $ofd "#ld: -z noseparate-code"
187     } else {
188         puts $ofd "#ld:"
189     }
190     #force z80 target to compile for eZ80 in ADL mode
191     if { [istarget "z80-*-*"] } then {
192         puts $ofd "#as: -ez80-adl"
193     }
194     puts $ofd "#readelf: -W -wN -Ss"
195     puts $ofd "There are 660.. section headers.*:"
196     puts $ofd "#..."
197     puts $ofd "  \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0"
198     puts $ofd "#..."
199     puts $ofd "  \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
200     puts $ofd "  \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
201     puts $ofd "#..."
202     if { [is_elf_unused_section_symbols ] } {
203         puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660...*"
204         puts $ofd "#..."
205         puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
206         puts $ofd "#..."
207         puts $ofd ".* bar_66000$"
208     } else {
209         puts $ofd " 66...: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. bar_66000$"
210     }
211     puts $ofd "#..."
212     # Global symbols are not in "alphanumeric" order, so we just check
213     # that the first and the last are present in any order (assuming no
214     # duplicates).
215     puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
216     puts $ofd "#..."
217     puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
218     puts $ofd "#pass"
219     close $ofd
220     run_dump_test "tmpdir/$test2"
223 for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
224     catch "exec rm -f tmpdir/dump$i.o" status