1 # Expect script for tests for >64k sections
2 # Copyright (C) 2002-2018 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,
21 # Written by Hans-Peter Nilsson (hp@axis.com)
24 # Exclude non-ELF targets.
30 # Targets using _bfd_generic_final_link don't sort section symbols
31 # before local symbols, so don't bother testing them.
32 if { [istarget "d30v-*-*"]
33 || [istarget "dlx-*-*"]
34 || [istarget "pj*-*-*"] } {
38 # ft32, h8300, ip2k, m68hc11, m68hc12 and xgate run out of address space.
39 if {[istarget "ft32-*-*"]
40 || [istarget "h8300-*-*"]
41 || [istarget "ip2k-*-*"]
42 || [istarget "m68hc1*-*"]
43 || [istarget "s12z-*"]
44 || [istarget "xgate-*"] } {
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
55 if { ![runtest_file_p $runtests $test1] \
56 && ![runtest_file_p $runtests $test2] } {
62 set secs_per_file 1000
63 for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } {
64 set sfile "$objdir/tmpdir/sec64-$i.s"
66 if [catch { set ofd [open $sfile w] } x] {
74 puts $ofd " .global start"
76 puts $ofd " .global _start"
78 puts $ofd " .global __start"
80 puts $ofd " .global main"
82 puts $ofd " .global foo_0"
83 puts $ofd "foo_0: .dc.a 0"
86 # Make sure the used section is not covered by common linker scripts.
87 # They should get separate section entries even without -r.
88 puts $ofd " .altmacro"
89 puts $ofd " .macro sec secn, secp"
90 if {![istarget "frv-*-*linux*"]} then {
91 puts $ofd " .section .foo.\\secn,\"ax\""
93 puts $ofd " .section .foo.\\secn,\"aw\""
95 puts $ofd " .global foo_\\secn"
96 puts $ofd "foo_\\secn:"
97 puts $ofd " .dc.a foo_\\secp"
98 puts $ofd "bar_\\secn:"
99 puts $ofd " .dc.a bar_\\secn"
101 if {![istarget "bfin-*-*"]} then {
102 puts $ofd " secn = [expr $i * $secs_per_file]"
104 puts $ofd " .set secn, [expr $i * $secs_per_file]"
106 puts $ofd " .rept $secs_per_file"
107 if {![istarget "bfin-*-*"]} then {
108 puts $ofd " secn = secn + 1"
110 puts $ofd " .set secn, secn + 1"
112 puts $ofd " sec %(secn), %(secn-1)"
118 if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
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.
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.
131 if { ![istarget "m32r-*-*"] } then {
132 foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
133 puts $ofd "#source: $sfile"
136 puts $ofd "#readelf: -W -Ss"
137 puts $ofd "There are 680.. section headers.*:"
139 puts $ofd " \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
141 puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
143 puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
144 puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
146 puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
148 puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-7\] bar_1$"
150 puts $ofd ".* bar_34000$"
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
155 puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
157 puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
160 run_dump_test "tmpdir/$test1"
163 if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
169 # too big for avr, d10v and msp
170 # lack of fancy orphan section handling causes overlap on fr30 and iq2000
171 if { ![istarget "d10v-*-*"]
172 && ![istarget "avr-*-*"]
173 && ![istarget "msp*-*-*"]
174 && ![istarget "fr30-*-*"]
175 && ![istarget "iq2000-*-*"]
176 && ![istarget "pru-*-*"] } {
177 foreach sfile $sfiles { puts $ofd "#source: $sfile" }
178 if { [istarget spu*-*-*] } {
179 puts $ofd "#ld: --local-store 0:0"
183 puts $ofd "#readelf: -W -Ss"
184 puts $ofd "There are 660.. section headers.*:"
186 puts $ofd " \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0"
188 puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
189 puts $ofd " \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
191 puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. "
193 puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
195 puts $ofd ".* bar_66000$"
197 # Global symbols are not in "alphanumeric" order, so we just check
198 # that the first and the last are present in any order (assuming no
200 puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
202 puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
205 run_dump_test "tmpdir/$test2"
208 for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
209 catch "exec rm -f tmpdir/dump$i.o" status