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