Commit | Line | Data |
---|---|---|
b7b0b729 HPN |
1 | # Expect script for tests for >64k sections |
2 | # Copyright 2002 Free Software Foundation, Inc. | |
3 | # | |
4 | # This file is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | # | |
18 | # Written by Hans-Peter Nilsson (hp@axis.com) | |
19 | # | |
20 | ||
21 | # Exclude non-ELF targets. | |
22 | ||
23 | if { ![istarget *-*-linux*] \ | |
24 | && ![istarget *-*-gnu] \ | |
25 | && ![istarget hppa*64*-*-hpux*] \ | |
26 | && ![istarget *-*-elf] } { | |
27 | return | |
28 | } | |
29 | ||
30 | if { [istarget *-*-linux*aout*] \ | |
31 | || [istarget *-*-linux*oldld*] } { | |
32 | return | |
33 | } | |
34 | ||
35 | # Per-port excludes, since this test takes an overwhelmingly long time | |
36 | # currently. | |
37 | if { ![istarget cris-*-*] } { | |
38 | return | |
39 | } | |
40 | ||
41 | # Test >64k sections, with and without -r. First, create the assembly | |
42 | # files. Have a relocation to another section and one within the local | |
43 | # section. | |
44 | ||
45 | set test1 "64ksec-r" | |
46 | set test2 "64ksec" | |
47 | ||
48 | if { ![runtest_file_p $runtests $test1] \ | |
49 | && ![runtest_file_p $runtests $test2] } { | |
50 | return | |
51 | } | |
52 | ||
53 | set sfiles {} | |
54 | set max_sec 66000 | |
55 | set secs_per_file 1000 | |
56 | set secn 0 | |
57 | for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } { | |
58 | set sfile "$objdir/tmpdir/sec64-$i.s" | |
59 | lappend sfiles $sfile | |
60 | if [catch { set ofd [open $sfile w] } x] { | |
61 | perror "$x" | |
62 | unresolved $test1 | |
63 | unresolved $test2 | |
64 | return | |
65 | } | |
66 | ||
67 | if { $secn == 0 } { | |
68 | puts $ofd " .global _start" | |
69 | puts $ofd "_start:" | |
70 | puts $ofd " .global foo_0" | |
71 | puts $ofd "foo_0: .long 0" | |
72 | } | |
73 | ||
74 | # Make sure the used section is not covered by common linker scripts. | |
75 | # They should get separate section entries even without -r. | |
76 | for { set j 0 } { $j < $secs_per_file } { incr j } { | |
77 | incr secn | |
78 | puts $ofd " .section .foo.$secn,\"ax\"" | |
79 | puts $ofd " .global foo_$secn" | |
80 | puts $ofd "foo_$secn:" | |
81 | puts $ofd " .long foo_[expr $secn - 1]" | |
82 | puts $ofd "bar_$secn:" | |
83 | puts $ofd " .long bar_$secn" | |
84 | } | |
85 | ||
86 | close $ofd | |
87 | } | |
88 | ||
89 | if [catch { set ofd [open "tmpdir/$test1.d" w] } x] { | |
90 | perror "$x" | |
91 | unresolved $test1 | |
92 | unresolved $test2 | |
93 | return | |
94 | } | |
95 | ||
96 | # The ld-r linked file will contain relocation-sections too, so make it | |
97 | # half the size in order to try and keep the test-time down. | |
98 | foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] { | |
99 | puts $ofd "#source: $sfile" | |
100 | } | |
101 | puts $ofd "#ld: -r" | |
102 | puts $ofd "#readelf: -W -Ss" | |
103 | puts $ofd "There are 680.. section headers.*:" | |
104 | puts $ofd "#..." | |
105 | puts $ofd " \\\[ 0\\\] .* 682\[0-9\]\[0-9\]\[ \]+0\[ \]+0" | |
106 | puts $ofd "#..." | |
107 | puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*" | |
108 | puts $ofd "#..." | |
109 | puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" | |
110 | puts $ofd " \\\[65536\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" | |
111 | puts $ofd "#..." | |
112 | puts $ofd " 680..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... " | |
113 | puts $ofd "#..." | |
114 | puts $ofd " 680..: 0+4\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+2 bar_1" | |
115 | puts $ofd "#..." | |
116 | puts $ofd ".* bar_34000" | |
117 | puts $ofd "#..." | |
118 | # Global symbols are not in "alphanumeric" order, so we just check | |
119 | # that the first and the last are present in any order (assuming no | |
120 | # duplicates). | |
121 | puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)" | |
122 | puts $ofd "#..." | |
123 | puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)" | |
124 | puts $ofd "#pass" | |
125 | close $ofd | |
126 | run_dump_test "tmpdir/$test1" | |
127 | ||
128 | if [catch { set ofd [open "tmpdir/$test2.d" w] } x] { | |
129 | perror "$x" | |
130 | unresolved $test2 | |
131 | return | |
132 | } | |
133 | foreach sfile $sfiles { puts $ofd "#source: $sfile" } | |
134 | puts $ofd "#ld:" | |
135 | puts $ofd "#readelf: -W -Ss" | |
136 | puts $ofd "There are 660.. section headers.*:" | |
137 | puts $ofd "#..." | |
138 | puts $ofd " \\\[ 0\\\] .* 662..\[ \]+0\[ \]+0" | |
139 | puts $ofd "#..." | |
140 | puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*" | |
141 | puts $ofd " \\\[65536\\\] \\.foo\\.\[0-9\]+ .*" | |
142 | puts $ofd "#..." | |
143 | puts $ofd " 660..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+662.. " | |
144 | puts $ofd "#..." | |
145 | puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1" | |
146 | puts $ofd "#..." | |
147 | puts $ofd ".* bar_66000" | |
148 | puts $ofd "#..." | |
149 | # Global symbols are not in "alphanumeric" order, so we just check | |
150 | # that the first and the last are present in any order (assuming no | |
151 | # duplicates). | |
152 | puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)" | |
153 | puts $ofd "#..." | |
154 | puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)" | |
155 | puts $ofd "#pass" | |
156 | close $ofd | |
157 | run_dump_test "tmpdir/$test2" |