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