X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=ld%2Ftestsuite%2Fld-gc%2Fgc.exp;fp=ld%2Ftestsuite%2Fld-gc%2Fgc.exp;h=c85d4f2f33adde4dbacbf9462e054d02cc60d081;hp=0000000000000000000000000000000000000000;hb=88750007d7869f178f0ba528f41efd3b74c424cf;hpb=6df9443a374e2b81278c61b8afc0a1eef7db280b diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp new file mode 100644 index 0000000..c85d4f2 --- /dev/null +++ b/ld/testsuite/ld-gc/gc.exp @@ -0,0 +1,92 @@ +# Expect script for ld-gc tests +# Copyright 2008, 2009 +# 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" + +if { [is_remote host] || [which $CC] != 0 } { + ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile +} + +proc test_gc { testname filename linker ldflags} { + global nm + global srcdir + global subdir + global nm_output + global objfile + + if ![file readable $objfile ] { + untested $testname + return + } + + set outfile "tmpdir/$filename" + set options "-L$srcdir/$subdir" + append options " " $ldflags " " [ld_simple_link_defsyms] " " $objfile + + # 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] { + fail $testname + 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 + } + #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*-*-*" + 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"