~ubuntu-branches/ubuntu/utopic/binutils-arm64-cross/utopic

« back to all changes in this revision

Viewing changes to binutils-2.23.52.20130611/ld/testsuite/ld-elf/sec64k.exp

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-06-20 17:38:09 UTC
  • Revision ID: package-import@ubuntu.com-20130620173809-app8lzgvymy5fg6c
Tags: 0.7
Build-depend on binutils-source (>= 2.23.52.20130620-1~).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Expect script for tests for >64k sections
 
2
#   Copyright 2002, 2003, 2005, 2006, 2007, 2008
 
3
#   Free Software Foundation, Inc.
 
4
#
 
5
# This file is part of the GNU Binutils.
 
6
#
 
7
# This program is free software; you can redistribute it and/or modify
 
8
# it under the terms of the GNU General Public License as published by
 
9
# the Free Software Foundation; either version 3 of the License, or
 
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
 
19
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
 
20
# MA 02110-1301, USA.
 
21
#
 
22
# Written by Hans-Peter Nilsson (hp@axis.com)
 
23
#
 
24
 
 
25
# Exclude non-ELF targets.
 
26
 
 
27
if ![is_elf_format] {
 
28
    return
 
29
}
 
30
 
 
31
# Targets using the generic linker backend don't sort section symbols
 
32
# before local symbols, so don't bother testing them.
 
33
if { [istarget "arc-*-*"]
 
34
     || [istarget "d30v-*-*"]
 
35
     || [istarget "dlx-*-*"]
 
36
     || [istarget "i960-*-*"]
 
37
     || [istarget "msp430*-*-*"]
 
38
     || [istarget "or32-*-*"]
 
39
     || [istarget "pj*-*-*"]
 
40
     || [istarget "m32r-*-*"] } {
 
41
    return
 
42
}
 
43
 
 
44
# Test >64k sections, with and without -r.  First, create the assembly
 
45
# files.  Have a relocation to another section and one within the local
 
46
# section.
 
47
 
 
48
set test1 "64ksec-r"
 
49
set test2 "64ksec"
 
50
 
 
51
if { ![runtest_file_p $runtests $test1] \
 
52
        && ![runtest_file_p $runtests $test2] } {
 
53
    return
 
54
}
 
55
 
 
56
set sfiles {}
 
57
set max_sec 66000
 
58
set secs_per_file 1000
 
59
for { set i 0 } { $i < $max_sec / $secs_per_file } { incr i } {
 
60
    set sfile "$objdir/tmpdir/sec64-$i.s"
 
61
    lappend sfiles $sfile
 
62
    if [catch { set ofd [open $sfile w] } x] {
 
63
        perror "$x"
 
64
        unresolved $test1
 
65
        unresolved $test2
 
66
        return
 
67
    }
 
68
 
 
69
    if { $i == 0 } {
 
70
        puts $ofd " .global start"
 
71
        puts $ofd "start:"
 
72
        puts $ofd " .global _start"
 
73
        puts $ofd "_start:"
 
74
        puts $ofd " .global __start"
 
75
        puts $ofd "__start:"
 
76
        puts $ofd " .global main"
 
77
        puts $ofd "main:"
 
78
        puts $ofd " .global foo_0"
 
79
        puts $ofd "foo_0: .dc.a 0"
 
80
    }
 
81
 
 
82
    # Make sure the used section is not covered by common linker scripts.
 
83
    # They should get separate section entries even without -r.
 
84
    puts $ofd " .altmacro"
 
85
    puts $ofd " .macro sec secn, secp"
 
86
    if {![istarget "frv-*-*linux*"]} then {
 
87
        puts $ofd "  .section .foo.\\secn,\"ax\""
 
88
    } else {
 
89
        puts $ofd "  .section .foo.\\secn,\"aw\""
 
90
    }
 
91
    puts $ofd "  .global foo_\\secn"
 
92
    puts $ofd "foo_\\secn:"
 
93
    puts $ofd "  .dc.a foo_\\secp"
 
94
    puts $ofd "bar_\\secn:"
 
95
    puts $ofd "  .dc.a bar_\\secn"
 
96
    puts $ofd " .endm"
 
97
    if {![istarget "bfin-*-*"]} then {
 
98
        puts $ofd " secn = [expr $i * $secs_per_file]"
 
99
    } else {
 
100
        puts $ofd " .set secn, [expr $i * $secs_per_file]"
 
101
    }
 
102
    puts $ofd " .rept $secs_per_file"
 
103
    if {![istarget "bfin-*-*"]} then {
 
104
        puts $ofd "  secn = secn + 1"
 
105
    } else {
 
106
        puts $ofd "  .set secn, secn + 1"
 
107
    }
 
108
    puts $ofd "  sec %(secn), %(secn-1)"
 
109
    puts $ofd " .endr"
 
110
 
 
111
    close $ofd
 
112
}
 
113
 
 
114
if [catch { set ofd [open "tmpdir/$test1.d" w] } x] {
 
115
    perror "$x"
 
116
    unresolved $test1
 
117
    unresolved $test2
 
118
    return
 
119
}
 
120
 
 
121
# The ld-r linked file will contain relocation-sections too, so make it
 
122
# half the size in order to try and keep the test-time down.
 
123
 
 
124
# The m32r target generates both REL and RELA relocs (for historical
 
125
# reasons) so the expected number of sections will be much more than
 
126
# 68000, which throws this particular test right off.
 
127
if { ![istarget "m32r-*-*"] } then {
 
128
    foreach sfile [lrange $sfiles 0 [expr [llength $sfiles] / 2]] {
 
129
        puts $ofd "#source: $sfile"
 
130
    }
 
131
    puts $ofd "#ld: -r"
 
132
    puts $ofd "#readelf: -W -Ss"
 
133
    puts $ofd "There are 680.. section headers.*:"
 
134
    puts $ofd "#..."
 
135
    puts $ofd "  \\\[ 0\\\] .* 680\[0-9\]\[0-9\]\[ \]+0\[ \]+0"
 
136
    puts $ofd "#..."
 
137
    puts $ofd "  \\\[ \[0-9\]\\\] \.foo\.1\[ \]+PROGBITS\[ \]+.*"
 
138
    puts $ofd "#..."
 
139
    puts $ofd "  \\\[65279\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
 
140
    puts $ofd "  \\\[65280\\\] (.rel\[a\]?)?\\.foo\\.\[0-9\]+ .*"
 
141
    puts $ofd "#..."
 
142
    puts $ofd " 340..: 0+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+68... "
 
143
    puts $ofd "#..."
 
144
    puts $ofd " 340..: 0+(2|4|8)\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[2-5\] bar_1$"
 
145
    puts $ofd "#..."
 
146
    puts $ofd ".* bar_34000$"
 
147
    puts $ofd "#..."
 
148
    # Global symbols are not in "alphanumeric" order, so we just check
 
149
    # that the first and the last are present in any order (assuming no
 
150
    # duplicates).
 
151
    puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
 
152
    puts $ofd "#..."
 
153
    puts $ofd ".* (\[0-9\] foo_1|68... foo_34000)$"
 
154
    puts $ofd "#pass"
 
155
    close $ofd
 
156
    run_dump_test "tmpdir/$test1"
 
157
}
 
158
 
 
159
if [catch { set ofd [open "tmpdir/$test2.d" w] } x] {
 
160
    perror "$x"
 
161
    unresolved $test2
 
162
    return
 
163
}
 
164
 
 
165
# too big for d10v and msp
 
166
# lack of fancy orphan section handling causes overlap on fr30 and iq2000
 
167
if { ![istarget "d10v-*-*"]
 
168
     && ![istarget "msp*-*-*"]
 
169
     && ![istarget "fr30-*-*"] 
 
170
     && ![istarget "iq2000-*-*"] } {
 
171
    foreach sfile $sfiles { puts $ofd "#source: $sfile" }
 
172
    if { [istarget "avr-*-*"] } then {
 
173
        puts $ofd "#as: -mmcu=avr6"
 
174
        puts $ofd "#ld: -mavr6"
 
175
    } elseif { [istarget spu*-*-*] } {
 
176
        puts $ofd "#ld: --local-store 0:0"
 
177
    } else {
 
178
        puts $ofd "#ld:"
 
179
    }
 
180
    puts $ofd "#readelf: -W -Ss"
 
181
    puts $ofd "There are 660.. section headers.*:"
 
182
    puts $ofd "#..."
 
183
    puts $ofd "  \\\[ 0\\\] .* 660..\[ \]+0\[ \]+0"
 
184
    puts $ofd "#..."
 
185
    puts $ofd "  \\\[65279\\\] \\.foo\\.\[0-9\]+ .*"
 
186
    puts $ofd "  \\\[65280\\\] \\.foo\\.\[0-9\]+ .*"
 
187
    puts $ofd "#..."
 
188
    puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+SECTION\[ \]+LOCAL\[ \]+DEFAULT\[ \]+660.. "
 
189
    puts $ofd "#..."
 
190
    puts $ofd " 660..: \[0-9a-f\]+\[ \]+0\[ \]+NOTYPE\[ \]+LOCAL\[ \]+DEFAULT\[ \]+\[0-9\] bar_1$"
 
191
    puts $ofd "#..."
 
192
    puts $ofd ".* bar_66000$"
 
193
    puts $ofd "#..."
 
194
    # Global symbols are not in "alphanumeric" order, so we just check
 
195
    # that the first and the last are present in any order (assuming no
 
196
    # duplicates).
 
197
    puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
 
198
    puts $ofd "#..."
 
199
    puts $ofd ".* (\[0-9\] foo_1|66... foo_66000)$"
 
200
    puts $ofd "#pass"
 
201
    close $ofd
 
202
    run_dump_test "tmpdir/$test2"
 
203
}
 
204
 
 
205
for { set i 1 } { $i < $max_sec / $secs_per_file } { incr i } {
 
206
    catch "exec rm -f tmpdir/dump$i.o" status
 
207
}