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