2008-01-11 10:11:18 +01:00
|
|
|
# Expect script for ld-gc tests
|
2010-01-07 14:44:37 +01:00
|
|
|
# Copyright 2008, 2009, 2010
|
2008-01-11 10:11:18 +01:00
|
|
|
# Free Software Foundation, Inc.
|
|
|
|
#
|
|
|
|
# This file is part of the GNU Binutils.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (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
|
|
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
|
|
# MA 02110-1301, USA.
|
|
|
|
|
|
|
|
# These tests require --gc-sections
|
|
|
|
if ![check_gc_sections_available] {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
set cflags "-ffunction-sections -fdata-sections"
|
|
|
|
set objfile "tmpdir/gc.o"
|
|
|
|
|
2011-02-09 09:18:54 +01:00
|
|
|
if [istarget powerpc64*-*-*] {
|
|
|
|
# otherwise with -mcmodel=medium gcc we get XPASSes.
|
|
|
|
set cflags "$cflags -mminimal-toc"
|
|
|
|
}
|
|
|
|
|
2008-01-22 20:36:58 +01:00
|
|
|
if { [is_remote host] || [which $CC] != 0 } {
|
2008-01-14 20:52:43 +01:00
|
|
|
ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile
|
|
|
|
}
|
2008-01-11 10:11:18 +01:00
|
|
|
|
|
|
|
proc test_gc { testname filename linker ldflags} {
|
|
|
|
global nm
|
|
|
|
global srcdir
|
|
|
|
global subdir
|
|
|
|
global nm_output
|
|
|
|
global objfile
|
|
|
|
|
2008-01-14 20:52:43 +01:00
|
|
|
if ![file readable $objfile ] {
|
|
|
|
untested $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2008-01-11 10:11:18 +01:00
|
|
|
set outfile "tmpdir/$filename"
|
2009-10-02 01:29:29 +02:00
|
|
|
set options "-L$srcdir/$subdir"
|
|
|
|
append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile
|
2008-01-11 10:11:18 +01:00
|
|
|
|
2009-09-15 04:02:48 +02:00
|
|
|
# SH64 targets needs an extra ld option for this test.
|
|
|
|
if [istarget sh64*-*-*] {
|
|
|
|
if [istarget sh64*l*-*-*] {
|
|
|
|
set options "-mshlelf32 $options"
|
|
|
|
} else {
|
|
|
|
set options "-mshelf32 $options"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![ld_simple_link $linker $outfile $options] {
|
2008-07-27 06:40:58 +02:00
|
|
|
fail $testname
|
2008-01-11 10:11:18 +01:00
|
|
|
return
|
|
|
|
}
|
|
|
|
if ![ld_nm $nm "" $outfile] {
|
|
|
|
unresolved $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if {![info exists nm_output(used_func)] \
|
|
|
|
|| ![info exists nm_output(used_var)]} {
|
|
|
|
send_log "used sections do not exist\n"
|
|
|
|
verbose "used sections do not exist"
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
2008-07-27 06:40:58 +02:00
|
|
|
#ppc64_elf_gc_mark_hook needs to be taught how to look through
|
|
|
|
#the .toc section to properly mark variable sections for gc.
|
|
|
|
setup_xfail "powerpc64*-*-*"
|
2008-01-11 10:11:18 +01:00
|
|
|
if {[info exists nm_output(unused_func)] \
|
|
|
|
|| [info exists nm_output(unused_var)]} {
|
|
|
|
send_log "unused section still here\n"
|
|
|
|
verbose "unused section still here"
|
|
|
|
fail $testname
|
|
|
|
return
|
|
|
|
}
|
|
|
|
pass $testname
|
|
|
|
}
|
|
|
|
|
|
|
|
test_gc "Check --gc-section" "gcexe" $ld "--gc-sections -e main"
|
|
|
|
test_gc "Check --gc-section/-q" "gcrexe" $ld "--gc-sections -q -e main"
|
|
|
|
test_gc "Check --gc-section/-r/-e" "gcrel" $ld "-r --gc-sections -e main"
|
|
|
|
test_gc "Check --gc-section/-r/-u" "gcrel" $ld "-r --gc-sections -u used_func"
|
|
|
|
|
|
|
|
run_dump_test "noent"
|
2010-01-07 14:44:37 +01:00
|
|
|
run_dump_test "abi-note"
|
2010-01-08 02:43:23 +01:00
|
|
|
run_dump_test "start"
|
2011-10-19 09:17:21 +02:00
|
|
|
|
|
|
|
if { [is_elf_format] && [check_shared_lib_support] } then {
|
|
|
|
set gasopt ""
|
|
|
|
if { [istarget tic6x-*] } then {
|
|
|
|
set gasopt "-mpic -mpid=near"
|
|
|
|
}
|
|
|
|
if {![ld_assemble_flags $as $gasopt $srcdir/$subdir/libpersonality.s tmpdir/libpersonality.o]
|
|
|
|
|| ![ld_simple_link $ld tmpdir/libpersonality.so "-shared tmpdir/libpersonality.o"] } then {
|
|
|
|
fail libpersonality
|
|
|
|
} else {
|
|
|
|
run_dump_test "personality"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-26 14:21:36 +01:00
|
|
|
if { [is_remote host] || [which $CC] != 0 } {
|
2010-11-08 07:43:40 +01:00
|
|
|
if { [istarget "*-*-linux*"]
|
|
|
|
|| [istarget "*-*-gnu*"] } {
|
2010-01-26 14:21:36 +01:00
|
|
|
ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
|
|
|
|
ld_simple_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
|
|
|
|
ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
|
|
|
|
run_dump_test "pr11218"
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 17:27:35 +01:00
|
|
|
|
|
|
|
if { [is_remote host] || [which $CC] != 0 } {
|
|
|
|
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
|
|
|
|
run_dump_test "pr13683"
|
|
|
|
}
|