]>
Commit | Line | Data |
---|---|---|
0e406595 | 1 | # Expect script for tests for >64k sections |
aef6203b | 2 | # Copyright 2002, 2003 Free Software Foundation, Inc. |
0e406595 AM |
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 | |
75be928b | 16 | # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
0e406595 AM |
17 | # |
18 | # Written by Hans-Peter Nilsson (hp@axis.com) | |
19 | # | |
20 | ||
21 | # Exclude non-ELF targets. | |
22 | ||
43f9d75b | 23 | if ![is_elf_format] { |
0e406595 AM |
24 | return |
25 | } | |
26 | ||
0e406595 AM |
27 | # Test >64k sections, with and without -r. First, create the assembly |
28 | # files. Have a relocation to another section and one within the local | |
29 | # section. | |
30 | ||
31 | set test1 "64ksec-r" | |
32 | set test2 "64ksec" | |
33 | ||
34 | if { ![runtest_file_p $runtests $test1] \ | |
35 | && ![runtest_file_p $runtests $test2] } { | |
36 | return | |
37 | } | |
38 | ||
39 | set sfiles {} | |
40 | set max_sec 66000 | |
41 | set secs_per_file 1000 | |
0e406595 AM |
42 | for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } { |
43 | set sfile "$objdir/tmpdir/sec64-$i.s" | |
44 | lappend sfiles $sfile | |
45 | if [catch { set ofd [open $sfile w] } x] { | |
46 | perror "$x" | |
47 | unresolved $test1 | |
48 | unresolved $test2 | |
49 | return | |
50 | } | |
51 | ||
9ab80182 | 52 | if { $i == 0 } { |
0e406595 AM |
53 | puts $ofd " .global _start" |
54 | puts $ofd "_start:" | |
55 | puts $ofd " .global foo_0" | |
56 | puts $ofd "foo_0: .long 0" | |
57 | } | |
58 | ||
59 | # Make sure the used section is not covered by common linker scripts. | |
60 | # They should get separate section entries even without -r. | |
9ab80182 JB |
61 | puts $ofd " .altmacro" |
62 | puts $ofd " .macro sec secn, secp" | |
63 | puts $ofd " .section .foo.\\secn,\"ax\"" | |
64 | puts $ofd " .global foo_\\secn" | |
65 | puts $ofd "foo_\\secn:" | |
66 | puts $ofd " .long foo_\\secp" | |
67 | puts $ofd "bar_\\secn:" | |
68 | puts $ofd " .long bar_\\secn" | |
69 | puts $ofd " .endm" | |
70 | puts $ofd " secn = [expr $i * $secs_per_file]" | |
71 | puts $ofd " .rept $secs_per_file" | |
72 | puts $ofd " secn = secn + 1" | |
73 | puts $ofd " sec %(secn), %(secn-1)" | |
74 | puts $ofd " .endr" | |
0e406595 AM |
75 | |
76 | close $ofd | |
77 | } | |
78 | ||
79 | if [catch { set ofd [open "tmpdir/$test1.d" w] } x] { | |
80 | perror "$x" | |
81 | unresolved $test1 | |
82 | unresolved $test2 | |
83 | return | |
84 | } | |
85 | ||
86 | # The ld-r linked file will contain relocation-sections too, so make it | |
87 | # half the size in order to try and keep the test-time down. | |
88 | foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] { | |
89 | puts $ofd "#source: $sfile" | |
90 | } | |
91 | puts $ofd "#ld: -r" | |
92 | puts $ofd "#readelf: -W -Ss" | |
93 | puts $ofd "There are 680.. section headers.*:" | |
94 | puts $ofd "#..." | |
95 | puts $ofd " \\\[ 0\\\] .* 682\[0-9\]\[0-9\]\[ \]+0\[ \]+0" | |
96 | puts $ofd "#..." | |
97 | puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*" | |
98 | puts $ofd "#..." | |
99 | puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" | |
100 | puts $ofd " \\\[65536\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*" | |
101 | puts $ofd "#..." | |
102 | puts $ofd " 680..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... " | |
103 | puts $ofd "#..." | |
104 | puts $ofd " 680..: 0+4\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+2 bar_1" | |
105 | puts $ofd "#..." | |
106 | puts $ofd ".* bar_34000" | |
107 | puts $ofd "#..." | |
108 | # Global symbols are not in "alphanumeric" order, so we just check | |
109 | # that the first and the last are present in any order (assuming no | |
110 | # duplicates). | |
111 | puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)" | |
112 | puts $ofd "#..." | |
113 | puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)" | |
114 | puts $ofd "#pass" | |
115 | close $ofd | |
116 | run_dump_test "tmpdir/$test1" | |
117 | ||
118 | if [catch { set ofd [open "tmpdir/$test2.d" w] } x] { | |
119 | perror "$x" | |
120 | unresolved $test2 | |
121 | return | |
122 | } | |
123 | foreach sfile $sfiles { puts $ofd "#source: $sfile" } | |
124 | puts $ofd "#ld:" | |
125 | puts $ofd "#readelf: -W -Ss" | |
126 | puts $ofd "There are 660.. section headers.*:" | |
127 | puts $ofd "#..." | |
128 | puts $ofd " \\\[ 0\\\] .* 662..\[ \]+0\[ \]+0" | |
129 | puts $ofd "#..." | |
130 | puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*" | |
131 | puts $ofd " \\\[65536\\\] \\.foo\\.\[0-9\]+ .*" | |
132 | puts $ofd "#..." | |
133 | puts $ofd " 660..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+662.. " | |
134 | puts $ofd "#..." | |
135 | puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1" | |
136 | puts $ofd "#..." | |
137 | puts $ofd ".* bar_66000" | |
138 | puts $ofd "#..." | |
139 | # Global symbols are not in "alphanumeric" order, so we just check | |
140 | # that the first and the last are present in any order (assuming no | |
141 | # duplicates). | |
142 | puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)" | |
143 | puts $ofd "#..." | |
144 | puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)" | |
145 | puts $ofd "#pass" | |
146 | close $ofd | |
147 | run_dump_test "tmpdir/$test2" | |
9ab80182 JB |
148 | |
149 | for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } { | |
150 | catch "exec rm -f tmpdir/dump$i.o" status | |
151 | } |