merge from gcc
[external/binutils.git] / ld / testsuite / ld-gc / gc.exp
index 68a0ba1..648f732 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for ld-gc tests
-#   Copyright 2008
+#   Copyright 2008, 2009
 #   Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
@@ -27,7 +27,9 @@ if ![check_gc_sections_available] {
 set cflags "-ffunction-sections -fdata-sections"
 set objfile "tmpdir/gc.o"
 
-ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile
+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
@@ -36,10 +38,25 @@ proc test_gc { testname filename linker ldflags} {
     global nm_output
     global objfile
 
+    if ![file readable $objfile ] {
+       untested $testname
+       return
+    }
+
     set outfile "tmpdir/$filename"
+    set options "-L$srcdir/$subdir $ldflags $objfile"
 
-    if ![ld_simple_link $linker $outfile "-L$srcdir/$subdir $ldflags $objfile"] {
-           fail $testname
+    # 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] {
@@ -53,6 +70,9 @@ proc test_gc { testname filename linker ldflags} {
        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"