]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/testsuite/ld-shared/shared.exp
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-shared / shared.exp
index 01940579a3b7a7a6beb373eb52e7c057220f7ad3..ffa6d246de15f8de5bf9f9a6b421928efd4e0f24 100644 (file)
@@ -1,5 +1,5 @@
 # Expect script for ld-shared tests
-#   Copyright (C) 1994-2018 Free Software Foundation, Inc.
+#   Copyright (C) 1994-2021 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -26,7 +26,7 @@
 # bootstrap test.
 
 # Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
     return
 }
 
@@ -50,7 +50,6 @@ if { ![istarget hppa*64*-*-hpux*] \
      && ![istarget powerpc*-*-sysv4*] \
      && ![istarget sparc*-*-elf] \
      && ![istarget sparc*-*-solaris2*] \
-     && ![istarget sparc*-*-sunos4*] \
      && ![istarget sparc*-*-linux*] \
      && ![istarget arm*-*-linux*] \
      && ![istarget alpha*-*-linux*] \
@@ -62,15 +61,14 @@ if { ![istarget hppa*64*-*-hpux*] \
     return
 }
 
-if { [istarget *-*-linux*aout*] \
-     || [istarget *-*-linux*oldld*] } {
-    return
-}
-
 set tmpdir tmpdir
 set SHCFLAG ""
 set shared_needs_pic "no"
 
+# Disable all sanitizers.
+set old_CFLAGS "$CFLAGS"
+append CFLAGS " $NOSANITIZE_CFLAGS"
+
 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 
     # AIX shared libraries do not seem to support useful features,
@@ -139,6 +137,9 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
        set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
     }
+    if { [is_elf_format] && [check_shared_lib_support] } {
+       append shared " -Wl,-z,notext"
+    }
     if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
         fail "$testname"
        return
@@ -205,11 +206,7 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
         || [string match "*option ignored*" $exec_output] \
         || [string match "*unrecognized option*" $exec_output] \
         || [string match "*passed to ld*" $exec_output] } {
-       if [istarget *-*-sunos4*] {
-           set picflag "-pic"
-       } else {
-           set picflag "-KPIC"
-       }
+       set picflag "-KPIC"
     }
 }
 verbose "Using $picflag to compile PIC code"
@@ -232,9 +229,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
     } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
        shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff
     } else {
-       # SunOS non PIC shared libraries don't permit some cases of
-       # overriding.
-       setup_xfail "*-*-sunos4*"
+       # Solaris defaults to -z text.
+       setup_xfail "*-*-solaris2*"
        setup_xfail "ia64-*-linux*"
        setup_xfail "alpha*-*-linux*"
        setup_xfail "powerpc64*-*-*"
@@ -259,7 +255,6 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
        # address for the library.  Near as I can tell, the R_*_RELATIVE
        # relocations for various targets are broken in the case where
        # the load address is not zero (which is the default).
-       setup_xfail "*-*-sunos4*"
        setup_xfail "*-*-linux*libc1"
        setup_xfail "powerpc*-*-linux*"
        setup_xfail "ia64-*-linux*"
@@ -280,6 +275,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
            setup_xfail "arm*-*-linux*"
        }
        setup_xfail "aarch64*-*-linux*"
+       # Solaris defaults to -z text.
+       setup_xfail "*-*-solaris2*"
        shared_test shnp "shared (non PIC, load offset)" \
                mainnp.o sh1np.o sh2np.o shared \
                "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv"
@@ -291,10 +288,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
         || ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
        unresolved "shared"
     } else {
-       # SunOS can not compare function pointers correctly
-       if [istarget "*-*-sunos4*"] {
-           shared_test shp "shared" mainnp.o sh1p.o sh2p.o sun4
-       } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+       if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
            shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff
        } else {
            shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared
@@ -303,7 +297,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
            shared_test shp "shared -Bsymbolic" mainnp.o sh1p.o sh2p.o symbolic "-Bsymbolic"
            ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
            ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o
-       } }
+       }
     }
 }
 
@@ -316,9 +310,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m
         if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
            shared_test shmpnp "shared (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff
        } else {
-           # SunOS non PIC shared libraries don't permit some cases of
-           # overriding.
-           setup_xfail "*-*-sunos4*"
+           # Solaris defaults to -z text.
+           setup_xfail "*-*-solaris2*"
            setup_xfail "ia64-*-linux*"
            setup_xfail "alpha*-*-linux*"
            setup_xfail "powerpc64*-*-*"
@@ -354,6 +347,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m
     }
 }
 
+set CFLAGS "$old_CFLAGS"
+
 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
     # Remove the temporary directory.
     catch "exec rm -rf $tmpdir" exec_status