1 |
205 |
julius |
# Expect script for tests for >64k sections
|
2 |
|
|
# Copyright 2002, 2003, 2005, 2006, 2007, 2008
|
3 |
|
|
# Free Software Foundation, Inc.
|
4 |
|
|
#
|
5 |
|
|
# This file is part of the GNU Binutils.
|
6 |
|
|
#
|
7 |
|
|
# This program is free software; you can redistribute it and/or modify
|
8 |
|
|
# it under the terms of the GNU General Public License as published by
|
9 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
10 |
|
|
# (at your option) any later version.
|
11 |
|
|
#
|
12 |
|
|
# This program is distributed in the hope that it will be useful,
|
13 |
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
# GNU General Public License for more details.
|
16 |
|
|
#
|
17 |
|
|
# You should have received a copy of the GNU General Public License
|
18 |
|
|
# along with this program; if not, write to the Free Software
|
19 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
20 |
|
|
# MA 02110-1301, USA.
|
21 |
|
|
#
|
22 |
|
|
# Written by Hans-Peter Nilsson (hp@axis.com)
|
23 |
|
|
#
|
24 |
|
|
|
25 |
|
|
# Exclude non-ELF targets.
|
26 |
|
|
|
27 |
|
|
if ![is_elf_format] {
|
28 |
|
|
return
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
# Test >64k sections, with and without -r. First, create the assembly
|
32 |
|
|
# files. Have a relocation to another section and one within the local
|
33 |
|
|
# section.
|
34 |
|
|
|
35 |
|
|
set test1 "64ksec-r"
|
36 |
|
|
set test2 "64ksec"
|
37 |
|
|
|
38 |
|
|
if { ![runtest_file_p $runtests $test1] \
|
39 |
|
|
&& ![runtest_file_p $runtests $test2] } {
|
40 |
|
|
return
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
set sfiles {}
|
44 |
|
|
set max_sec 66000
|
45 |
|
|
set secs_per_file 1000
|
46 |
|
|
for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } {
|
47 |
|
|
set sfile "$objdir/tmpdir/sec64-$i.s"
|
48 |
|
|
lappend sfiles $sfile
|
49 |
|
|
if [catch { set ofd [open $sfile w] } x] {
|
50 |
|
|
perror "$x"
|
51 |
|
|
unresolved $test1
|
52 |
|
|
unresolved $test2
|
53 |
|
|
return
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
if { $i == 0 } {
|
57 |
|
|
puts $ofd " .global start"
|
58 |
|
|
puts $ofd "start:"
|
59 |
|
|
puts $ofd " .global _start"
|
60 |
|
|
puts $ofd "_start:"
|
61 |
|
|
puts $ofd " .global __start"
|
62 |
|
|
puts $ofd "__start:"
|
63 |
|
|
puts $ofd " .global main"
|
64 |
|
|
puts $ofd "main:"
|
65 |
|
|
puts $ofd " .global foo_0"
|
66 |
|
|
puts $ofd "foo_0: .dc.a 0"
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
# Make sure the used section is not covered by common linker scripts.
|
70 |
|
|
# They should get separate section entries even without -r.
|
71 |
|
|
puts $ofd " .altmacro"
|
72 |
|
|
puts $ofd " .macro sec secn, secp"
|
73 |
|
|
if {![istarget "frv-*-*linux*"]} then {
|
74 |
|
|
puts $ofd " .section .foo.\\secn,\"ax\""
|
75 |
|
|
} else {
|
76 |
|
|
puts $ofd " .section .foo.\\secn,\"aw\""
|
77 |
|
|
}
|
78 |
|
|
puts $ofd " .global foo_\\secn"
|
79 |
|
|
puts $ofd "foo_\\secn:"
|
80 |
|
|
puts $ofd " .dc.a foo_\\secp"
|
81 |
|
|
puts $ofd "bar_\\secn:"
|
82 |
|
|
puts $ofd " .dc.a bar_\\secn"
|
83 |
|
|
puts $ofd " .endm"
|
84 |
|
|
if {![istarget "bfin-*-*"]} then {
|
85 |
|
|
puts $ofd " secn = [expr $i * $secs_per_file]"
|
86 |
|
|
} else {
|
87 |
|
|
puts $ofd " .set secn, [expr $i * $secs_per_file]"
|
88 |
|
|
}
|
89 |
|
|
puts $ofd " .rept $secs_per_file"
|
90 |
|
|
if {![istarget "bfin-*-*"]} then {
|
91 |
|
|
puts $ofd " secn = secn + 1"
|
92 |
|
|
} else {
|
93 |
|
|
puts $ofd " .set secn, secn + 1"
|
94 |
|
|
}
|
95 |
|
|
puts $ofd " sec %(secn), %(secn-1)"
|
96 |
|
|
puts $ofd " .endr"
|
97 |
|
|
|
98 |
|
|
close $ofd
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
|
102 |
|
|
perror "$x"
|
103 |
|
|
unresolved $test1
|
104 |
|
|
unresolved $test2
|
105 |
|
|
return
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
# The ld-r linked file will contain relocation-sections too, so make it
|
109 |
|
|
# half the size in order to try and keep the test-time down.
|
110 |
|
|
|
111 |
|
|
# The m32r target generates both REL and RELA relocs (for historical
|
112 |
|
|
# reasons) so the expected number of sections will be much more than
|
113 |
|
|
# 68000, which throws this particular test right off.
|
114 |
|
|
if {![istarget "m32r-*-*"]} then {
|
115 |
|
|
foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
|
116 |
|
|
puts $ofd "#source: $sfile"
|
117 |
|
|
}
|
118 |
|
|
puts $ofd "#ld: -r"
|
119 |
|
|
puts $ofd "#readelf: -W -Ss"
|
120 |
|
|
puts $ofd "There are 680.. section headers.*:"
|
121 |
|
|
puts $ofd "#..."
|
122 |
|
|
puts $ofd " \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
|
123 |
|
|
puts $ofd "#..."
|
124 |
|
|
puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
|
125 |
|
|
puts $ofd "#..."
|
126 |
|
|
puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
|
127 |
|
|
puts $ofd " \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
|
128 |
|
|
puts $ofd "#..."
|
129 |
|
|
puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
|
130 |
|
|
puts $ofd "#..."
|
131 |
|
|
puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[23\] bar_1$"
|
132 |
|
|
puts $ofd "#..."
|
133 |
|
|
puts $ofd ".* bar_34000$"
|
134 |
|
|
puts $ofd "#..."
|
135 |
|
|
# Global symbols are not in "alphanumeric" order, so we just check
|
136 |
|
|
# that the first and the last are present in any order (assuming no
|
137 |
|
|
# duplicates).
|
138 |
|
|
puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
|
139 |
|
|
puts $ofd "#..."
|
140 |
|
|
puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
|
141 |
|
|
puts $ofd "#pass"
|
142 |
|
|
close $ofd
|
143 |
|
|
run_dump_test "tmpdir/$test1"
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
|
147 |
|
|
perror "$x"
|
148 |
|
|
unresolved $test2
|
149 |
|
|
return
|
150 |
|
|
}
|
151 |
|
|
foreach sfile $sfiles { puts $ofd "#source: $sfile" }
|
152 |
|
|
if { [istarget spu*-*-*] } {
|
153 |
|
|
puts $ofd "#ld: --local-store 0:0"
|
154 |
|
|
} else {
|
155 |
|
|
puts $ofd "#ld:"
|
156 |
|
|
}
|
157 |
|
|
puts $ofd "#readelf: -W -Ss"
|
158 |
|
|
puts $ofd "There are 660.. section headers.*:"
|
159 |
|
|
puts $ofd "#..."
|
160 |
|
|
puts $ofd " \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0"
|
161 |
|
|
puts $ofd "#..."
|
162 |
|
|
puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
|
163 |
|
|
puts $ofd " \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
|
164 |
|
|
puts $ofd "#..."
|
165 |
|
|
puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. "
|
166 |
|
|
puts $ofd "#..."
|
167 |
|
|
puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
|
168 |
|
|
puts $ofd "#..."
|
169 |
|
|
puts $ofd ".* bar_66000$"
|
170 |
|
|
puts $ofd "#..."
|
171 |
|
|
# Global symbols are not in "alphanumeric" order, so we just check
|
172 |
|
|
# that the first and the last are present in any order (assuming no
|
173 |
|
|
# duplicates).
|
174 |
|
|
puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
|
175 |
|
|
puts $ofd "#..."
|
176 |
|
|
puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
|
177 |
|
|
puts $ofd "#pass"
|
178 |
|
|
close $ofd
|
179 |
|
|
run_dump_test "tmpdir/$test2"
|
180 |
|
|
|
181 |
|
|
for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
|
182 |
|
|
catch "exec rm -f tmpdir/dump$i.o" status
|
183 |
|
|
}
|