diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-26 11:03:35 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-26 11:03:35 -0700 |
commit | 09797ba54abf3683ea66eedddf6afbe7653f9cb9 (patch) | |
tree | 8030b2ed79c7463c89d6da294782e9d503c84f50 /binutils-2.24/ld/testsuite/ld-gc | |
parent | 5a2caf34e4995860baf405552163df288000b7bf (diff) | |
download | toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.zip toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.tar.gz toolchain_binutils-09797ba54abf3683ea66eedddf6afbe7653f9cb9.tar.bz2 |
Initial checkin of binutils 2.24.
Change-Id: I0dfcbae6608dded6c3586bf5f4ac27e9612e70a2
Diffstat (limited to 'binutils-2.24/ld/testsuite/ld-gc')
20 files changed, 394 insertions, 0 deletions
diff --git a/binutils-2.24/ld/testsuite/ld-gc/abi-note.d b/binutils-2.24/ld/testsuite/ld-gc/abi-note.d new file mode 100644 index 0000000..d796ccc --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/abi-note.d @@ -0,0 +1,9 @@ +#name: --gc-sections with note section +#ld: --gc-sections -e _start +#readelf: -S --wide +#target: *-*-linux* *-*-gnu* +#notarget: *-*-*aout *-*-*oldld + +#... +.* .note.ABI-tag[ ]+NOTE.* +#... diff --git a/binutils-2.24/ld/testsuite/ld-gc/abi-note.s b/binutils-2.24/ld/testsuite/ld-gc/abi-note.s new file mode 100644 index 0000000..22536c0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/abi-note.s @@ -0,0 +1,15 @@ + .text + .global _start +_start: + .long 1 + + .section ".note.ABI-tag", "a" + .p2align 2 + .long 1f - 0f /* name length */ + .long 3f - 2f /* data length */ + .long 1 /* note type */ +0: .asciz "GNU" /* vendor name */ +1: .p2align 2 +2: .long 1 + .long 2 +3: .p2align 2 /* pad out section */ diff --git a/binutils-2.24/ld/testsuite/ld-gc/dummy.s b/binutils-2.24/ld/testsuite/ld-gc/dummy.s new file mode 100644 index 0000000..403f980 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/dummy.s @@ -0,0 +1 @@ +# Dummy diff --git a/binutils-2.24/ld/testsuite/ld-gc/gc.c b/binutils-2.24/ld/testsuite/ld-gc/gc.c new file mode 100644 index 0000000..3b0e655 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/gc.c @@ -0,0 +1,41 @@ +int unused_var = 7; +int used_var = 7; + +int +unused_func (int v) +{ + return 3 * unused_var; +} + +int +__attribute__((noinline)) +used_func (int v) +{ + return 2 * used_var; +} + +int +main (void) +{ + return used_func (5); +} + +void +dummy_func (void) +{ + /* These are here in case the target prepends an underscore to + the start of function names. They are inside a dummy function + so that they will appear at the end of gcc's assembler output, + after the definitions of main() and used_func(), rather than + at the beginning of the file. */ + + __asm__(".ifndef main\n\ +.global main\n\ +.set main, _main\n\ +.endif"); + + __asm__(".ifndef used_func\n\ +.global used_func\n\ +.set used_func, _used_func\n\ +.endif"); +} diff --git a/binutils-2.24/ld/testsuite/ld-gc/gc.exp b/binutils-2.24/ld/testsuite/ld-gc/gc.exp new file mode 100644 index 0000000..ddbbd51 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/gc.exp @@ -0,0 +1,138 @@ +# Expect script for ld-gc tests +# Copyright 2008, 2009, 2010, 2012 +# 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 { [istarget m681*-*-*] || [istarget m68hc1*-*-*] } { + # Otherwise tests FAIL due to _.frame + set cflags "$cflags -fomit-frame-pointer -mshort" +} + +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" + +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 } { + if { [istarget "*-*-linux*"] + || [istarget "*-*-nacl*"] + || [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" +} + +if { [is_remote host] || [which $CC] != 0 } { + ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o + run_dump_test "pr14265" +} diff --git a/binutils-2.24/ld/testsuite/ld-gc/libpersonality.s b/binutils-2.24/ld/testsuite/ld-gc/libpersonality.s new file mode 100644 index 0000000..b19ce2b --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/libpersonality.s @@ -0,0 +1,11 @@ + .weak __gxx_personality_v0 + .type __gxx_personality_v0,%function +__gxx_personality_v0: + .long 0 + .size __gxx_personality_v0, . - __gxx_personality_v0 + + .globl __gxx_personality_v1 + .type __gxx_personality_v1,%function +__gxx_personality_v1: + .long 0 + .size __gxx_personality_v1, . - __gxx_personality_v1 diff --git a/binutils-2.24/ld/testsuite/ld-gc/noent.d b/binutils-2.24/ld/testsuite/ld-gc/noent.d new file mode 100644 index 0000000..1741a74 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/noent.d @@ -0,0 +1,3 @@ +# name: --gc-sections -r without -e +# ld: --gc-sections -r +# error: gc-sections requires either an entry or an undefined symbol diff --git a/binutils-2.24/ld/testsuite/ld-gc/noent.s b/binutils-2.24/ld/testsuite/ld-gc/noent.s new file mode 100644 index 0000000..ea74bf4 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/noent.s @@ -0,0 +1,4 @@ + .text + .globl entry +entry: + .long 0 diff --git a/binutils-2.24/ld/testsuite/ld-gc/personality.d b/binutils-2.24/ld/testsuite/ld-gc/personality.d new file mode 100644 index 0000000..f3cf652 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/personality.d @@ -0,0 +1,10 @@ +#name: --gc-sections with __gxx_personality +#ld: --gc-sections -e main -L tmpdir -lpersonality +#nm: -n +#xfail: bfin-*-* cris*-*-* frv-*-* mn10300-*-* vax-*-* xtensa-*-* metag-*-* +# above targets don't support cfi + +#failif +#... +.*gxx_personality.* +#... diff --git a/binutils-2.24/ld/testsuite/ld-gc/personality.s b/binutils-2.24/ld/testsuite/ld-gc/personality.s new file mode 100644 index 0000000..6fac355 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/personality.s @@ -0,0 +1,28 @@ + .section .text.loseme,"ax",%progbits + .globl loseme + .type loseme,%function +loseme: + .cfi_startproc + .cfi_personality 0,__gxx_personality_v0 + .long 0 + .cfi_endproc + .size loseme, . - loseme + + .section .text.loseme2,"ax",%progbits + .globl loseme2 + .type loseme2,%function +loseme2: + .cfi_startproc + .cfi_personality 0,__gxx_personality_v1 + .long 0 + .cfi_endproc + .size loseme2, . - loseme2 + + .section .text.main,"ax",%progbits + .globl main + .type main, %function +main: + .cfi_startproc + .long 0 + .cfi_endproc + .size main, . - main diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr11218-1.c b/binutils-2.24/ld/testsuite/ld-gc/pr11218-1.c new file mode 100644 index 0000000..9cc79f0 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr11218-1.c @@ -0,0 +1,5 @@ +extern void unresolved_detected_at_runtime_not_at_linktime(void); +void foo_in_so(void) +{ + unresolved_detected_at_runtime_not_at_linktime(); +} diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr11218-2.c b/binutils-2.24/ld/testsuite/ld-gc/pr11218-2.c new file mode 100644 index 0000000..5f15802 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr11218-2.c @@ -0,0 +1,14 @@ +extern void foo_in_so(void); +extern void unresolved_detected_at_runtime_not_at_linktime (void); + +void call_unresolved(void) +{ + unresolved_detected_at_runtime_not_at_linktime(); +} + +int main(int argc, char *argv[]) +{ + foo_in_so(); + + return 0; +} diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr11218.d b/binutils-2.24/ld/testsuite/ld-gc/pr11218.d new file mode 100644 index 0000000..fc26940 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr11218.d @@ -0,0 +1,5 @@ +# name: --gc-sections with shared library +# source: dummy.s +# ld: --gc-sections -e main tmpdir/pr11218-2.o tmpdir/pr11218-1.so +# target: *-*-linux* *-*-gnu* +# error: undefined reference to `unresolved_detected_at_runtime_not_at_linktime' diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr13683.c b/binutils-2.24/ld/testsuite/ld-gc/pr13683.c new file mode 100644 index 0000000..c585e06 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr13683.c @@ -0,0 +1,28 @@ +void foo(void);
+
+int main(void)
+{
+ foo ();
+
+ for (;;)
+ ;
+}
+
+int a;
+
+void foo1(void)
+{
+ a = 1;
+}
+
+void foo2(void)
+{
+ a = 2;
+}
+
+void foo3(void)
+{
+ a = 3;
+}
+
+
diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr13683.d b/binutils-2.24/ld/testsuite/ld-gc/pr13683.d new file mode 100644 index 0000000..b38b9d1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr13683.d @@ -0,0 +1,12 @@ +#name: --gc-sections with --defsym +#source: dummy.s +#ld: --gc-sections -e main --defsym foo=foo2 tmpdir/pr13683.o +#nm: --format=bsd +#xfail: sh64*-*-* iq2000-*-* lm32-*-* epiphany-*-* mips64vr-*-* frv-*-* m32c-*-* rl78-*-* rx-*-* sh-*-* powerpc*-*-eabivle msp430-*-* + +# Note - look for both "foo" and "foo2" being defined, non-zero function symbols + +#... +0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo +0*[1-9a-f]+[0-9a-f]*[ ](T|D)[ ]_*foo2 +#... diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr14265.c b/binutils-2.24/ld/testsuite/ld-gc/pr14265.c new file mode 100644 index 0000000..6bb8f9a --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr14265.c @@ -0,0 +1,20 @@ +int foo0 __attribute__((used,section(".foo0.0"))); +int foo1 __attribute__((used,section(".foo1.0"))); +int foo2 __attribute__((used,section(".foo2.0"))); + +extern unsigned long __foo0_start; +extern unsigned long __foo0_end; + +extern unsigned long __foo1_start; +extern unsigned long __foo1_end; + +extern unsigned long __foo2_start; +extern unsigned long __foo2_end; + +int +main (void) +{ + return ((__foo0_end - __foo0_start) - + (__foo1_end - __foo1_start) - + (__foo2_end - __foo2_start)); +} diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr14265.d b/binutils-2.24/ld/testsuite/ld-gc/pr14265.d new file mode 100644 index 0000000..04af982 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr14265.d @@ -0,0 +1,13 @@ +#name: --gc-sections with KEEP +#source: dummy.s +#ld: --gc-sections -T pr14265.t -e 0 tmpdir/pr14265.o +#nm: --format=bsd --numeric-sort + +#... +[0-9a-f]+[ ]d[ ]_*foo1_start +[0-9a-f]+[ ]D[ ]_*foo1 +[0-9a-f]+[ ]d[ ]_*foo1_end +[0-9a-f]+[ ]d[ ]_*foo2_start +[0-9a-f]+[ ]D[ ]_*foo2 +[0-9a-f]+[ ]d[ ]_*foo2_end +#... diff --git a/binutils-2.24/ld/testsuite/ld-gc/pr14265.t b/binutils-2.24/ld/testsuite/ld-gc/pr14265.t new file mode 100644 index 0000000..12a2d67 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/pr14265.t @@ -0,0 +1,22 @@ +SECTIONS +{ + .text : { *(.text) } + + __foo0_start = .; + .foo0 : { *(.foo0.*) } + __foo0_end = .; + + __foo1_start = .; + .foo1 : { KEEP(*(.foo1.*)) } + __foo1_end = .; + + .foo2 : { + __foo2_start = .; + KEEP(*(.foo2.*)) + __foo2_end = .; + } + /DISCARD/ : { *(*) } +} + +ASSERT (__foo1_start < __foo1_end, "foo1 not KEPT"); +ASSERT ((__foo1_end - __foo1_start) == (__foo2_end - __foo2_start),"foo2 not KEPT"); diff --git a/binutils-2.24/ld/testsuite/ld-gc/start.d b/binutils-2.24/ld/testsuite/ld-gc/start.d new file mode 100644 index 0000000..18e74c1 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/start.d @@ -0,0 +1,9 @@ +#name: --gc-sections with __start_ +#ld: --gc-sections -e _start +#nm: -n +#target: *-*-linux* *-*-gnu* +#notarget: *-*-*aout *-*-*oldld frv-*-linux* metag-*-linux* + +#... +[0-9a-f]+ D +__start__foo +#... diff --git a/binutils-2.24/ld/testsuite/ld-gc/start.s b/binutils-2.24/ld/testsuite/ld-gc/start.s new file mode 100644 index 0000000..a417a97 --- /dev/null +++ b/binutils-2.24/ld/testsuite/ld-gc/start.s @@ -0,0 +1,6 @@ +.globl _start +_start: + .dc.a __start__foo + .section _foo,"aw",%progbits +foo: + .long 1 |