PR gas/3800
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / sec64k.exp
CommitLineData
0e406595 1# Expect script for tests for >64k sections
bac7e529 2# Copyright 2002, 2003, 2006 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 23if ![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
31set test1 "64ksec-r"
32set test2 "64ksec"
33
34if { ![runtest_file_p $runtests $test1] \
35 && ![runtest_file_p $runtests $test2] } {
36 return
37}
38
39set sfiles {}
40set max_sec 66000
41set secs_per_file 1000
0e406595
AM
42for { 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 } {
bac7e529
AM
53 puts $ofd " .global start"
54 puts $ofd "start:"
0e406595
AM
55 puts $ofd " .global _start"
56 puts $ofd "_start:"
bac7e529 57 puts $ofd " .global __start"
1cb571e9 58 puts $ofd "__start:"
bac7e529
AM
59 puts $ofd " .global main"
60 puts $ofd "main:"
0e406595 61 puts $ofd " .global foo_0"
bac7e529 62 puts $ofd "foo_0: .dc.a 0"
0e406595
AM
63 }
64
65 # Make sure the used section is not covered by common linker scripts.
66 # They should get separate section entries even without -r.
9ab80182
JB
67 puts $ofd " .altmacro"
68 puts $ofd " .macro sec secn, secp"
69 puts $ofd " .section .foo.\\secn,\"ax\""
70 puts $ofd " .global foo_\\secn"
71 puts $ofd "foo_\\secn:"
bac7e529 72 puts $ofd " .dc.a foo_\\secp"
9ab80182 73 puts $ofd "bar_\\secn:"
bac7e529 74 puts $ofd " .dc.a bar_\\secn"
9ab80182
JB
75 puts $ofd " .endm"
76 puts $ofd " secn = [expr $i * $secs_per_file]"
77 puts $ofd " .rept $secs_per_file"
78 puts $ofd " secn = secn + 1"
79 puts $ofd " sec %(secn), %(secn-1)"
80 puts $ofd " .endr"
0e406595
AM
81
82 close $ofd
83}
84
85if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
86 perror "$x"
87 unresolved $test1
88 unresolved $test2
89 return
90}
91
92# The ld-r linked file will contain relocation-sections too, so make it
93# half the size in order to try and keep the test-time down.
94foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
95 puts $ofd "#source: $sfile"
96}
97puts $ofd "#ld: -r"
98puts $ofd "#readelf: -W -Ss"
99puts $ofd "There are 680.. section headers.*:"
100puts $ofd "#..."
101puts $ofd " \\\[ 0\\\] .* 682\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
102puts $ofd "#..."
103puts $ofd " \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
104puts $ofd "#..."
105puts $ofd " \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
106puts $ofd " \\\[65536\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
107puts $ofd "#..."
f0b5bb34 108puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
0e406595 109puts $ofd "#..."
bac7e529 110puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[23\] bar_1$"
0e406595 111puts $ofd "#..."
bac7e529 112puts $ofd ".* bar_34000$"
0e406595
AM
113puts $ofd "#..."
114# Global symbols are not in "alphanumeric" order, so we just check
115# that the first and the last are present in any order (assuming no
116# duplicates).
bac7e529 117puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
0e406595 118puts $ofd "#..."
bac7e529 119puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
0e406595
AM
120puts $ofd "#pass"
121close $ofd
122run_dump_test "tmpdir/$test1"
123
124if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
125 perror "$x"
126 unresolved $test2
127 return
128}
129foreach sfile $sfiles { puts $ofd "#source: $sfile" }
e9f53129
AM
130if { [istarget spu*-*-*] } {
131 puts $ofd "#ld: --local-store 0:0"
132} else {
133 puts $ofd "#ld:"
134}
0e406595
AM
135puts $ofd "#readelf: -W -Ss"
136puts $ofd "There are 660.. section headers.*:"
137puts $ofd "#..."
138puts $ofd " \\\[ 0\\\] .* 662..\[ \]+0\[ \]+0"
139puts $ofd "#..."
140puts $ofd " \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
141puts $ofd " \\\[65536\\\] \\.foo\\.\[0-9\]+ .*"
142puts $ofd "#..."
f0b5bb34 143puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+662.. "
0e406595 144puts $ofd "#..."
bac7e529 145puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
0e406595 146puts $ofd "#..."
bac7e529 147puts $ofd ".* bar_66000$"
0e406595
AM
148puts $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).
bac7e529 152puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
0e406595 153puts $ofd "#..."
bac7e529 154puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
0e406595
AM
155puts $ofd "#pass"
156close $ofd
157run_dump_test "tmpdir/$test2"
9ab80182
JB
158
159for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
160 catch "exec rm -f tmpdir/dump$i.o" status
161}
This page took 0.181871 seconds and 4 git commands to generate.