binutils-gdb/ld/testsuite/ld-gc/gc.exp

128 lines
3.8 KiB
Plaintext
Raw Normal View History

# Expect script for ld-gc tests
# Copyright 2008, 2009, 2010
# 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 [istarget powerpc64*-*-*] {
# otherwise with -mcmodel=medium gcc we get XPASSes.
set cflags "$cflags -mminimal-toc"
}
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"
run_dump_test "abi-note"
run_dump_test "start"
PR ld/13177 bfd/ * elflink.c (_bfd_elf_gc_mark_rsec): Set symbol "mark". (elf_gc_sweep_symbol): Don't test plt/got refcounts, instead test "mark". Hide undefweak too. Clear def_regular and ref_regular. * elf-m10300.c (mn10300_elf_relocate_section): Ignore unresolved reloc errors from garbage-collected code. * elf32-arm.c (elf32_arm_relocate_section): Likewise. * elf32-bfin.c (bfin_relocate_section): Likewise. (bfinfdpic_relocate_section): Likewise. * elf32-cris.c (cris_elf_relocate_section): Likewise. * elf32-frv.c (elf32_frv_relocate_section): Likewise. * elf32-i386.c (elf_i386_relocate_section): Likewise. * elf32-m32r.c (m32r_elf_relocate_section): Likewise. * elf32-m68k.c (elf_m68k_relocate_section): Likewise. * elf32-ppc.c (ppc_elf_relocate_section): Likewise. * elf32-s390.c (elf_s390_relocate_section): Likewise. * elf32-sh.c (sh_elf_relocate_section): Likewise. * elf32-spu.c (spu_elf_relocate_section): Likewise. * elf32-tilepro.c (tilepro_elf_relocate_section): Likewise. * elf32-xtensa.c (elf_xtensa_relocate_section): Likewise. * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. * elf64-ppc.c (ppc64_elf_relocate_section): Likewise. * elf64-s390.c (elf_s390_relocate_section): Likewise. * elf64-sh64.c (sh_elf64_relocate_section): Likewise. * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise. * elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Likewise. * elfxx-tilegx.c (tilegx_elf_relocate_section): Likewise. ld/testsuite/ * ld-elf/elf.exp: Move test for shared lib support.. * lib/ld-lib.exp (check_shared_lib_support): ..to here. Add m68hc1*, and s/ms1/mt/. (check_gc_sections_available): Match hppa*64 not hppa64. Comment. * ld-gc/libpersonality.s: New. * ld-gc/personality.s, * ld-gc/personality.d: New. * ld-gc/gc.exp: Run personality test.
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"
}
}
if { [is_remote host] || [which $CC] != 0 } {
Improve binutils testsuite coverage for GNU/Hurd. binutils/testsuite/ * lib/utils-lib.exp (is_elf_format): Consider for *-*-gnu*, too. * binutils-all/elfedit-2.d (target): Likewise. * binutils-all/elfedit-3.d (target): Likewise. * binutils-all/i386/i386.exp: Likewise. * binutils-all/objcopy.exp: Likewise. * binutils-all/strip-3.d (target): Likewise. gas/testsuite/ * lib/gas-defs.exp (is_elf_format): Consider for *-*-gnu*, too. * gas/elf/elf.exp: Likewise. * gas/symver/symver.exp: Likewise. ld/ * configure.host: Add stanza for *-*-gnu*. ld/testsuite/ * lib/ld-lib.exp (is_elf_format): Consider for *-*-gnu*, too. * ld-discard/discard.exp: Likewise. * ld-elf/binutils.exp: Likewise. * ld-elf/commonpage1.d (target): Likewise. * ld-elf/compress1c.d (target): Likewise. * ld-elf/discard1.d (target): Likewise. * ld-elf/discard2.d (target): Likewise. * ld-elf/discard3.d (target): Likewise. * ld-elf/dynsym1.d (target): Likewise. * ld-elf/eh6.d (target): Likewise. * ld-elf/elf.exp: Likewise. (array_tests): Move -static tests to... (array_tests_static): ... here, and handle it accordingly. * ld-elf/hash.d (target): Likewise. * ld-elf/header.d (target): Likewise. * ld-elf/loadaddr1.d (target): Likewise. * ld-elf/loadaddr2.d (target): Likewise. * ld-elf/loadaddr3a.d (target): Likewise. * ld-elf/loadaddr3b.d (target): Likewise. * ld-elf/local1.d (target): Likewise. * ld-elf/maxpage1.d (target): Likewise. * ld-elf/maxpage2.d (target): Likewise. * ld-elf/maxpage3a.d (target): Likewise. * ld-elf/multibss1.d (target): Likewise. * ld-elf/noload-2.d (target): Likewise. * ld-elf/seg.d (target): Likewise. * ld-elf/textaddr1.d (target): Likewise. * ld-elf/textaddr2.d (target): Likewise. * ld-elf/textaddr3.d (target): Likewise. * ld-elf/textaddr4.d (target): Likewise. * ld-elf/textaddr5.d (target): Likewise. * ld-elf/textaddr6.d (target): Likewise. * ld-elf/textaddr7.d (target): Likewise. * ld-elf/tls_common.exp: Likewise. * ld-elf/unknown2.d (target): Likewise. * ld-elfvers/vers.exp: Likewise. * ld-elfvsb/elfvsb.exp: Likewise. * ld-elfweak/elfweak.exp: Likewise. (setup_xfail_gnu_hurd): New function. Use it where appropriate. * ld-gc/abi-note.d (target): Likewise. * ld-gc/gc.exp: Likewise. * ld-gc/pr11218.d (target): Likewise. * ld-gc/start.d (target): Likewise. * ld-i386/i386.exp: Likewise. * ld-ifunc/binutils.exp: Likewise. * ld-ifunc/ifunc.exp: Likewise. * ld-linkonce/linkonce.exp: Likewise. * ld-linkonce/zeroehl32.d (target): Likewise. * ld-pie/pie.exp: Likewise. * ld-scripts/phdrs2.exp: Likewise. * ld-scripts/rgn-at5.d (target): Likewise. * ld-shared/shared.exp: Likewise. * ld-undefined/entry-3.d (target): Likewise. * ld-undefined/entry-4.d (target): Likewise. * ld-undefined/weak-undef.exp: Likewise.
2010-11-08 07:43:40 +01:00
if { [istarget "*-*-linux*"]
|| [istarget "*-*-gnu*"] } {
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"
}
}
if { [is_remote host] || [which $CC] != 0 } {
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
run_dump_test "pr13683"
}