| 1 |
53 |
khays |
# Expect script for binutils tests
|
| 2 |
|
|
# Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
|
| 3 |
|
|
#
|
| 4 |
|
|
# This file is part of the GNU Binutils.
|
| 5 |
|
|
#
|
| 6 |
|
|
# This program is free software; you can redistribute it and/or modify
|
| 7 |
|
|
# it under the terms of the GNU General Public License as published by
|
| 8 |
|
|
# the Free Software Foundation; either version 3 of the License, or
|
| 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
|
| 18 |
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
| 19 |
|
|
# MA 02110-1301, USA.
|
| 20 |
|
|
#
|
| 21 |
|
|
# Written by H.J. Lu (hongjiu.lu@intel.com)
|
| 22 |
|
|
#
|
| 23 |
|
|
|
| 24 |
|
|
# Make sure that binutils can correctly handle ld output in ELF.
|
| 25 |
|
|
|
| 26 |
|
|
if { ![istarget *-*-linux*]
|
| 27 |
|
|
&& ![istarget *-*-gnu*]} {
|
| 28 |
|
|
return
|
| 29 |
|
|
}
|
| 30 |
|
|
|
| 31 |
|
|
if { [istarget *-*-linux*aout*]
|
| 32 |
|
|
|| [istarget *-*-linux*oldld*] } {
|
| 33 |
|
|
return
|
| 34 |
|
|
}
|
| 35 |
|
|
|
| 36 |
|
|
proc binutils_test { prog_name ld_options test } {
|
| 37 |
|
|
global as
|
| 38 |
|
|
global ld
|
| 39 |
|
|
global READELF
|
| 40 |
|
|
global objcopy
|
| 41 |
|
|
global strip
|
| 42 |
|
|
global srcdir
|
| 43 |
|
|
global subdir
|
| 44 |
|
|
global link_output
|
| 45 |
|
|
|
| 46 |
|
|
eval set prog \$$prog_name
|
| 47 |
|
|
set test_name "$prog_name $ld_options ($test)"
|
| 48 |
|
|
|
| 49 |
|
|
if { ![ld_assemble $as $srcdir/$subdir/$test.s tmpdir/$test.o ] } {
|
| 50 |
|
|
unresolved "$test_name"
|
| 51 |
|
|
return
|
| 52 |
|
|
}
|
| 53 |
|
|
|
| 54 |
|
|
if { ![ld_simple_link $ld tmpdir/$test "$ld_options tmpdir/$test.o"] } {
|
| 55 |
|
|
if { [string match "*not supported*" $link_output]
|
| 56 |
157 |
khays |
|| [string match "*unrecognized option*" $link_output]
|
| 57 |
|
|
|| [string match "*-z relro ignored*" $link_output] } {
|
| 58 |
53 |
khays |
unsupported "$ld_options is not supported by this target"
|
| 59 |
|
|
} else {
|
| 60 |
|
|
unresolved "$test_name"
|
| 61 |
|
|
}
|
| 62 |
|
|
return
|
| 63 |
|
|
}
|
| 64 |
|
|
|
| 65 |
|
|
send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.exp\n"
|
| 66 |
|
|
set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.exp"]
|
| 67 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 68 |
|
|
send_log "$got\n"
|
| 69 |
|
|
unresolved "$test_name"
|
| 70 |
|
|
return
|
| 71 |
|
|
}
|
| 72 |
|
|
|
| 73 |
|
|
send_log "$prog tmpdir/$test\n"
|
| 74 |
|
|
set got [remote_exec host "$prog tmpdir/$test"]
|
| 75 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 76 |
|
|
send_log "$got\n"
|
| 77 |
|
|
fail "$test_name"
|
| 78 |
|
|
return
|
| 79 |
|
|
}
|
| 80 |
|
|
|
| 81 |
|
|
send_log "$READELF -l --wide tmpdir/$test > tmpdir/$test.out\n"
|
| 82 |
|
|
set got [remote_exec host "$READELF -l --wide tmpdir/$test" "" "/dev/null" "tmpdir/$test.out"]
|
| 83 |
|
|
if { [lindex $got 0] != 0 || ![string match "" [lindex $got 1]] } then {
|
| 84 |
|
|
send_log "$got\n"
|
| 85 |
|
|
unresolved "$test_name"
|
| 86 |
|
|
return
|
| 87 |
|
|
}
|
| 88 |
|
|
|
| 89 |
|
|
if { [catch {exec cmp tmpdir/$test.exp tmpdir/$test.out}] } then {
|
| 90 |
|
|
send_log "tmpdir/$test.exp tmpdir/$test.out differ.\n"
|
| 91 |
|
|
fail "$test_name"
|
| 92 |
|
|
return
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
|
|
pass "$test_name"
|
| 96 |
|
|
}
|
| 97 |
|
|
|
| 98 |
|
|
binutils_test strip "-z max-page-size=0x200000" maxpage1
|
| 99 |
|
|
binutils_test strip "-z max-page-size=0x200000 -z common-page-size=0x100000" maxpage1
|
| 100 |
|
|
binutils_test strip "-z max-page-size=0x100000" maxpage1
|
| 101 |
|
|
binutils_test strip "-z max-page-size=0x100000 -z common-page-size=0x1000" maxpage1
|
| 102 |
|
|
|
| 103 |
|
|
binutils_test strip "" maxpage1
|
| 104 |
|
|
binutils_test strip "-shared" maxpage1
|
| 105 |
|
|
binutils_test objcopy "" maxpage1
|
| 106 |
|
|
binutils_test objcopy "-shared" maxpage1
|
| 107 |
|
|
|
| 108 |
|
|
binutils_test strip "-z relro" relro1
|
| 109 |
|
|
binutils_test strip "-z relro -shared" relro1
|
| 110 |
|
|
binutils_test objcopy "-z relro" relro1
|
| 111 |
|
|
binutils_test objcopy "-z relro -shared" relro1
|
| 112 |
|
|
if { ([istarget "i?86-*-elf*"]
|
| 113 |
|
|
|| (([istarget "i?86-*-linux*"]
|
| 114 |
|
|
|| [istarget "i?86-*-gnu*"])
|
| 115 |
|
|
&& ![istarget "*-*-*aout*"]
|
| 116 |
|
|
&& ![istarget "*-*-*oldld*"])
|
| 117 |
|
|
|| [istarget "x86_64-*-linux*"]
|
| 118 |
|
|
|| [istarget "amd64-*-linux*"]) } {
|
| 119 |
|
|
binutils_test strip "-z relro -shared" relro2
|
| 120 |
|
|
binutils_test objcopy "-z relro -shared" relro2
|
| 121 |
|
|
}
|
| 122 |
|
|
|
| 123 |
|
|
binutils_test strip "-T ${srcdir}/${subdir}/lma.lnk" lma
|
| 124 |
|
|
|
| 125 |
|
|
set tls_tests { "tdata1" "tdata2" }
|
| 126 |
|
|
# hppa64 has its own .tbss section, with different flags.
|
| 127 |
|
|
if { ![istarget "hppa64-*-*"] } {
|
| 128 |
|
|
lappend tls_tests "tdata3" "tbss1" "tbss2" "tbss3"
|
| 129 |
|
|
}
|
| 130 |
|
|
set tls_opts {
|
| 131 |
|
|
""
|
| 132 |
|
|
"-z relro"
|
| 133 |
|
|
"-shared"
|
| 134 |
|
|
"-shared -z relro"
|
| 135 |
|
|
"-z max-page-size=0x100000"
|
| 136 |
|
|
"-z max-page-size=0x100000 -z common-page-size=0x1000"
|
| 137 |
|
|
}
|
| 138 |
|
|
|
| 139 |
|
|
foreach testitem $tls_tests {
|
| 140 |
|
|
foreach testopt $tls_opts {
|
| 141 |
|
|
binutils_test objcopy $testopt $testitem
|
| 142 |
|
|
}
|
| 143 |
|
|
}
|