2002-11-21 13:30:31 +00:00
|
|
|
# Expect script for various ELF tests.
|
2011-06-14 02:55:29 +00:00
|
|
|
# Copyright 2002, 2003, 2005, 2007, 2009, 2010, 2011
|
|
|
|
# Free Software Foundation, Inc.
|
2002-11-11 10:16:57 +00:00
|
|
|
#
|
2007-07-06 14:09:45 +00:00
|
|
|
# This file is part of the GNU Binutils.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
2002-11-11 10:16:57 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-06 14:09:45 +00:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
2002-11-11 10:16:57 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2007-07-06 14:09:45 +00:00
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
2002-11-11 10:16:57 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# Exclude non-ELF targets.
|
|
|
|
|
2003-05-29 00:16:46 +00:00
|
|
|
if ![is_elf_format] {
|
2002-11-11 10:16:57 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2009-01-12 13:57:59 +00:00
|
|
|
set old_ldflags $LDFLAGS
|
2007-03-22 23:44:00 +00:00
|
|
|
if { [istarget spu*-*-*] } {
|
|
|
|
set LDFLAGS "$LDFLAGS --local-store 0:0"
|
|
|
|
}
|
2011-03-30 17:41:36 +00:00
|
|
|
if { [istarget alpha*-*-* ] } {
|
|
|
|
# The compress1 test is written expecting 32-bit addresses; force the
|
|
|
|
# executable down into the low address space to match.
|
|
|
|
# ??? How can we adjust just the one testcase?
|
|
|
|
set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000"
|
|
|
|
}
|
2007-03-22 23:44:00 +00:00
|
|
|
|
2007-08-28 13:21:58 +00:00
|
|
|
if { [is_remote host] } then {
|
|
|
|
remote_download host merge.ld
|
|
|
|
}
|
|
|
|
|
2011-06-14 02:55:29 +00:00
|
|
|
if { ![istarget hppa64*-hpux*] } {
|
|
|
|
run_ld_link_tests {
|
|
|
|
{"Build symbol3.a"
|
|
|
|
"" ""
|
|
|
|
{symbol3.s} {} "symbol3.a"}
|
|
|
|
{"Build symbol3w.a"
|
|
|
|
"" ""
|
|
|
|
{symbol3w.s} {} "symbol3w.a"}
|
|
|
|
}
|
2011-06-08 04:47:04 +00:00
|
|
|
}
|
|
|
|
|
2011-06-10 14:04:25 +00:00
|
|
|
# Run a test to check linking a shared library with a broken linker
|
|
|
|
# script that accidentally marks dynamic sections as notes. The
|
|
|
|
# resulting executable is not expected to work, but the linker
|
|
|
|
# should not seg-fault whilst creating the binary.
|
|
|
|
#
|
|
|
|
# Only run the test on targets thats support creating shared libraries.
|
2011-10-19 07:17:21 +00:00
|
|
|
if { [check_shared_lib_support] } then {
|
2011-06-10 14:04:25 +00:00
|
|
|
run_ld_link_tests {
|
|
|
|
{"Build shared library for next test"
|
|
|
|
"-shared" "" "note-3.s" {} "note-3.so" }
|
|
|
|
{"Link using broken linker script"
|
|
|
|
"--script note-3.t tmpdir/note-3.so" "" ""
|
|
|
|
{ { ld "note-3.l" } }
|
|
|
|
"a.out" }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-21 13:30:31 +00:00
|
|
|
set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
|
|
|
|
foreach t $test_list {
|
|
|
|
# We need to strip the ".d", but can leave the dirname.
|
|
|
|
verbose [file rootname $t]
|
|
|
|
run_dump_test [file rootname $t]
|
|
|
|
}
|
2005-07-14 17:02:11 +00:00
|
|
|
|
2010-11-08 06:43:40 +00:00
|
|
|
if { [istarget *-*-linux*]
|
|
|
|
|| [istarget *-*-gnu*] } {
|
2007-07-23 09:56:19 +00:00
|
|
|
run_ld_link_tests {
|
|
|
|
{"Weak symbols in dynamic objects 1 (support)"
|
|
|
|
"-shared" "" {weak-dyn-1a.s}
|
|
|
|
{}
|
|
|
|
"libweakdyn1a.so"}
|
|
|
|
{"Weak symbols in dynamic objects 1 (main test)"
|
|
|
|
"-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" {weak-dyn-1b.s}
|
|
|
|
{{readelf {--relocs --wide} weak-dyn-1.rd}}
|
|
|
|
"libweakdyn1b.so"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-23 12:24:41 +00:00
|
|
|
#v850 gas complains about .tbss.var section attributes.
|
|
|
|
if { [check_gc_sections_available] && ![istarget "v850-*-*"] } {
|
2007-11-20 15:08:25 +00:00
|
|
|
run_ld_link_tests {
|
|
|
|
{"--gc-sections on tls variable"
|
|
|
|
"--gc-section" "" {tls_gc.s} {} "tls_gc"}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-12 13:57:59 +00:00
|
|
|
set LDFLAGS $old_ldflags
|
|
|
|
|
2005-07-14 17:02:11 +00:00
|
|
|
# The following tests require running the executable generated by ld.
|
|
|
|
if ![isnative] {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-10-07 19:55:47 +00:00
|
|
|
if [check_gc_sections_available] {
|
|
|
|
run_cc_link_tests {
|
|
|
|
{"PR ld/13195" "-Wl,--gc-sections" ""
|
|
|
|
{pr13195.c} {} "pr13195"}
|
|
|
|
}
|
2011-09-29 00:13:14 +00:00
|
|
|
}
|
|
|
|
|
2005-07-14 17:02:11 +00:00
|
|
|
set array_tests {
|
|
|
|
{"preinit array" "" "" {preinit.c} "preinit" "preinit.out"}
|
|
|
|
{"init array" "" "" {init.c} "init" "init.out"}
|
|
|
|
{"fini array" "" "" {fini.c} "fini" "fini.out"}
|
2010-12-15 14:56:40 +00:00
|
|
|
{"init array mixed" "" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
|
2011-05-07 14:12:59 +00:00
|
|
|
}
|
|
|
|
set array_tests_pie {
|
|
|
|
{"PIE preinit array" "-pie" "" {preinit.c} "preinit" "preinit.out" "-fPIE" }
|
|
|
|
{"PIE init array" "-pie" "" {init.c} "init" "init.out" "-fPIE"}
|
|
|
|
{"PIE fini array" "-pie" "" {fini.c} "fini" "fini.out" "-fPIE"}
|
|
|
|
{"PIE init array mixed" "-pie" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
|
2010-11-08 06:43:40 +00:00
|
|
|
}
|
|
|
|
set array_tests_static {
|
|
|
|
{"static preinit array" "-static" "" {preinit.c} "preinit" "preinit.out"}
|
|
|
|
{"static init array" "-static" "" {init.c} "init" "init.out"}
|
2005-07-14 17:02:11 +00:00
|
|
|
{"static fini array" "-static" "" {fini.c} "fini" "fini.out"}
|
2011-05-07 14:12:59 +00:00
|
|
|
{"static init array mixed" "-static" "" {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
|
2005-07-14 17:02:11 +00:00
|
|
|
}
|
|
|
|
|
2005-07-27 21:29:12 +00:00
|
|
|
# NetBSD ELF systems do not currently support the .*_array sections.
|
2010-11-08 06:43:40 +00:00
|
|
|
set xfails [list "*-*-netbsdelf*"]
|
|
|
|
run_ld_link_exec_tests $xfails $array_tests
|
2011-05-07 14:12:59 +00:00
|
|
|
|
2011-06-22 05:55:05 +00:00
|
|
|
if { [istarget *-*-linux*]
|
|
|
|
|| [istarget *-*-gnu*] } {
|
2011-05-07 14:12:59 +00:00
|
|
|
run_ld_link_exec_tests $xfails $array_tests_pie
|
|
|
|
}
|
|
|
|
|
2010-11-08 06:43:40 +00:00
|
|
|
# Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
|
|
|
|
switch -regexp $target_triplet {
|
|
|
|
^\[^-\]*-\[^-\]*-gnu.*$ {
|
2010-12-21 11:00:48 +00:00
|
|
|
# <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>
|
2010-11-08 06:43:40 +00:00
|
|
|
lappend xfails "*-*-*"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
run_ld_link_exec_tests $xfails $array_tests_static
|
2005-11-15 08:32:02 +00:00
|
|
|
|
2010-12-15 14:56:40 +00:00
|
|
|
catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status
|