Update year range in copyright notice of all files.
[external/binutils.git] / ld / testsuite / ld-elfweak / elfweak.exp
index 91e683b..88df180 100644 (file)
@@ -1,6 +1,5 @@
 # Expect script for ld-weak tests
-#   Copyright 2001, 2002, 2003, 2004, 2005, 2007, 2010, 2012
-#   Free Software Foundation, Inc.
+#   Copyright (C) 2001-2017 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -50,6 +49,7 @@ if {    ![istarget alpha*-*-linux*]
      && ![istarget sparc*-*-elf]
      && ![istarget sparc*-*-solaris2*]
      && ![istarget sparc*-*-linux*]
+     && ![istarget x86_64-*-linux*]
      && ![istarget *-*-nacl*] } {
     return
 }
@@ -67,20 +67,9 @@ set diff diff
 set tmpdir tmpdir
 set DOBJDUMP_FLAGS --dynamic-syms
 set SOBJDUMP_FLAGS --syms
-set shared --shared
+set shared "--shared -Wl,--no-as-needed"
 
 
-# <http://www.gnu.org/software/hurd/open_issues/binutils.html#weak>
-proc setup_xfail_gnu_hurd {} {
-    global target_triplet
-    # Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
-    switch -regexp $target_triplet {
-       ^\[^-\]*-\[^-\]*-gnu.*$ {
-           setup_xfail "*-*-*"
-       }
-    }
-}
-
 #
 # objdump_symstuff
 #      Dump non-dynamic symbol stuff and make sure that it is sane.
@@ -93,9 +82,9 @@ proc objdump_symstuff { objdump object expectfile } {
 
     if ![info exists SOBJDUMP_FLAGS] { set SOBJDUMP_FLAGS "" }
 
-    verbose -log "$objdump $SOBJDUMP_FLAGS $object | grep foo$  > $tmpdir/objdump.out"
-
-    catch "exec $objdump $SOBJDUMP_FLAGS $object | grep foo$  > $tmpdir/objdump.out" exec_output
+    set cmd "$objdump $SOBJDUMP_FLAGS $object | sed -n {s/^\\(\[0-9a-f\]* *\\)\\(\[gw\]\\)\\( *\\)\\(\[FO\]\\)/\\1\\2\\4\\3/;/foo$/p} > $tmpdir/objdump.out"
+    verbose -log $cmd
+    catch "exec $cmd" exec_output
     set exec_output [prune_warnings $exec_output]
     if [string match "" $exec_output] then {
 
@@ -134,7 +123,8 @@ proc objdump_symstuff { objdump object expectfile } {
        close $file_a
 
        while { [gets $file_b line] != $eof } {
-           if [regexp "^#.*$" $line] then {
+           if [regexp {\.text.* \.[^ ]*$} $line] then {
+               # Discard defined powerpc64 dot-symbols
                continue
            } else {
                lappend list_b $line
@@ -188,9 +178,9 @@ proc objdump_dynsymstuff { objdump object expectfile } {
 
     if ![info exists DOBJDUMP_FLAGS] { set DOBJDUMP_FLAGS "" }
 
-    verbose -log "$objdump $DOBJDUMP_FLAGS $object | grep foo$ > $tmpdir/objdump.out"
-
-    catch "exec $objdump $DOBJDUMP_FLAGS $object | grep foo$ > $tmpdir/objdump.out" exec_output
+    set cmd "$objdump $DOBJDUMP_FLAGS $object | grep foo$ > $tmpdir/objdump.out"
+    verbose -log $cmd
+    catch "exec $cmd" exec_output
     set exec_output [prune_warnings $exec_output]
     if [string match "" $exec_output] then {
 
@@ -229,7 +219,8 @@ proc objdump_dynsymstuff { objdump object expectfile } {
        close $file_a
 
        while { [gets $file_b line] != $eof } {
-           if [regexp "^#.*$" $line] then {
+           if [regexp {\.text.* \.[^ ]*$} $line] then {
+               # Discard defined powerpc64 dot-symbols
                continue
            } else {
                lappend list_b $line
@@ -316,7 +307,6 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
     global CC
     global objdump
     global tmpdir
-    global shared
     global srcdir
     global subdir
     global exec_output
@@ -442,7 +432,7 @@ if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o]
     return
 }
 
-if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main1.c $tmpdir/main1.o] {
+if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o] {
     unresolved "ELF weak"
     return
 }
@@ -468,10 +458,8 @@ build_lib "ELF DSO weak func first DSO" libfoo "foo.o libbar.so" dsow.dsym
 build_lib "ELF DSO weak func last DSO" libfoo "libbar.so foo.o" dsow.dsym
 build_exec "ELF weak func first" foo "main.o bar.o" "" strong "" strong.sym
 build_exec "ELF weak func last" foo "bar.o main.o" "" strong "" strong.sym
-setup_xfail_gnu_hurd
-build_exec "ELF weak func first DSO" foo "main.o libbar.so" "-Wl,-rpath,." weak weak.dsym ""
-setup_xfail_gnu_hurd
-build_exec "ELF weak func last DSO" foo "libbar.so main.o" "-Wl,-rpath,." weak weak.dsym ""
+build_exec "ELF weak func first DSO" foo "main.o libbar.so" "-Wl,-rpath,.,--no-as-needed" weak weak.dsym ""
+build_exec "ELF weak func last DSO" foo "libbar.so main.o" "-Wl,-rpath,.,--no-as-needed" weak weak.dsym ""
 
 build_lib "ELF DSO weak data first" libfoo "bar1a.o foo1a.o" dsodata.dsym
 build_lib "ELF DSO weak data last" libfoo "foo1a.o bar1a.o" dsodata.dsym
@@ -483,14 +471,10 @@ build_exec "ELF weak data first" foo "main1.o bar1a.o foo1a.o" "" strongdata ""
 build_exec "ELF weak data last" foo "foo1a.o main1.o bar1a.o" "" strongdata "" strongdata.sym
 build_exec "ELF weak data first common" foo "main1.o bar1a.o foo1b.o" "" strongdata "" strongcomm.sym
 build_exec "ELF weak data last common" foo "foo1b.o main1.o bar1a.o" "" strongdata "" strongcomm.sym
-setup_xfail_gnu_hurd
-build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-Wl,-rpath,." weakdata weakdata.dsym ""
-setup_xfail_gnu_hurd
-build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym ""
-setup_xfail_gnu_hurd
-build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,-rpath,." weakdata weakdata.dsym ""
-setup_xfail_gnu_hurd
-build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,-rpath,." weakdata weakdata.dsym ""
+build_exec "ELF weak data first DSO" foo "main1.o libbar1a.so libfoo1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
+build_exec "ELF weak data last DSO" foo "libfoo1a.so main1.o libbar1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
+build_exec "ELF weak data first DSO common" foo "main1.o libbar1a.so libfoo1b.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
+build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,-rpath,.,--no-as-needed" weakdata weakdata.dsym ""
 
 if ![ld_compile "$CC $CFLAGS $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o] {
     unresolved "ELF weak (size)"
@@ -517,7 +501,7 @@ if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/size_main.c $tmpdir/size_main.o] {
     return
 }
 
-build_exec "ELF weak size" size_main "size_main.o libsize_foo.so libsize_bar.so" "-Wl,-rpath,." size "" ""
+build_exec "ELF weak size" size_main "size_main.o libsize_foo.so libsize_bar.so" "-Wl,-rpath,.,--no-as-needed" size "" ""
 
 verbose "size2"
 run_dump_test $srcdir/$subdir/size2