gdb: Convert language la_word_break_characters field to a method
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elfvsb / elfvsb.exp
index e2c1b4cd5fcb6f004bc0e007461dad31d96b99c3..5e19d32ae619dee6f4a7947796c989c3db2aa195 100644 (file)
@@ -1,6 +1,5 @@
 # Expect script for ld-visibility tests
-#   Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012
-#   Free Software Foundation, Inc.
+#   Copyright (C) 2000-2020 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
 
 # Make sure that ld can generate ELF shared libraries with visibility.
 
+# Check to see if the C compiler works
+if { ![check_compiler_available] } {
+    return
+}
+
 # This test can only be run on a couple of ELF platforms.
 # Square bracket expressions seem to confuse istarget.
 if { ![istarget hppa*64*-*-hpux*] \
@@ -45,11 +49,6 @@ if { ![istarget hppa*64*-*-hpux*] \
     return
 }
 
-if { [istarget *-*-linux*aout*] \
-     || [istarget *-*-linux*oldld*] } {
-    return
-}
-
 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
 foreach t $test_list {
     # We need to strip the ".d", but can leave the dirname.
@@ -57,12 +56,10 @@ foreach t $test_list {
     run_dump_test [file rootname $t]
 }
 
-# The remaining tests can only be run if ld generates native executables.
-if ![isnative] then {return}
-
 set tmpdir tmpdir
 set SHCFLAG ""
 set shared_needs_pic "no"
+set COMPRESS_LDFLAG "-Wl,--compress-debug-sections=zlib-gabi"
 
 if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
 
@@ -104,8 +101,8 @@ if [istarget arm*-*-linux*] {
     # the linker doesn't support when compiling -shared without -fpic.  The
     # test to find out whether we want to XFAIL the non-PIC tests requires
     # a compile - so we pre-calculate it here.  We also note that this can
-    # only affect arm*-*-*eabi targets as the old ABI doesn't support v7.
-    if [istarget arm*-*-*eabi] {
+    # only affect arm*-*-*eabi* targets as the old ABI doesn't support v7.
+    if [istarget arm*-*-*eabi*] {
        set file [open $tmpdir/movw-detect.c w]
        puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
        close $file
@@ -121,7 +118,7 @@ if { [istarget *-*-linux*]
      || [istarget *-*-nacl*]
      || [istarget *-*-gnu*] } {
     if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
-      if [ld_simple_link $CC $tmpdir/main "$tmpdir/main.o"] {
+      if [ld_link $CC $tmpdir/main "$tmpdir/main.o"] {
        catch "exec $tmpdir/main" support_protected
       }
     }
@@ -145,7 +142,10 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
        set shared "-bM:SRE -bE:$tmpdir/xcoff.exp"
     }
-    if {![ld_simple_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
+    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"]} {
        if { [ string match $visibility "hidden_undef" ]
             && [regexp "undefined reference to \`\.?visibility\'" $link_output]
             && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@@ -168,7 +168,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
     if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
        set rpath /lib:$tmpdir
     }
-    if ![ld_simple_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
+    if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
        if { [ string match $visibility "hidden" ]
             && [regexp "undefined reference to \`\.?visibility\'" $link_output]
             && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@@ -191,6 +191,11 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
        fail "$testname"
     }
 
+    if ![isnative] {
+       unsupported "$testname"
+       return
+    }
+
     # Run the resulting program
     send_log "$tmpdir/$progname >$tmpdir/$progname.out\n"
     verbose "$tmpdir/$progname >$tmpdir/$progname.out"
@@ -228,6 +233,9 @@ proc visibility_run {visibility} {
     global target_triplet
     global support_protected
     global shared_needs_pic
+    global PLT_CFLAGS
+    global NOPIE_CFLAGS
+    global COMPRESS_LDFLAG
 
     if [ string match $visibility "hidden" ] {
        set VSBCFLAG "-DHIDDEN_TEST"
@@ -251,6 +259,10 @@ proc visibility_run {visibility} {
        set VSBCFLAG ""
     }}}}}}}}}
 
+    # Ensure we always start with a clean slate, for the "file exists"
+    # tests below.
+    remote_file host delete $tmpdir/sh1p.o $tmpdir/sh2p.o $tmpdir/sh1np.o $tmpdir/sh2np.o
+
     if { [istarget powerpc*-*-linux*] \
         || ( [istarget mips*-*-linux*] && [at_least_gcc_version 4 3] )} {
        # Testing non-PIC libraries is a waste of effort on any target.
@@ -260,8 +272,9 @@ proc visibility_run {visibility} {
        # functions and variables not being overridable.  Newer versions
        # of gcc are more likely to do this.
     } else {
-    # Compile the main program.
-    if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+    # Compile the main program.  Make sure that PLT is used since PLT
+    # is expected.
+    if ![ld_compile "$CC -g $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
        unresolved "visibility ($visibility) (non PIC)"
        unresolved "visibility ($visibility)"
     } else {
@@ -270,9 +283,9 @@ proc visibility_run {visibility} {
        # although it will be less efficient because the dynamic linker
        # will need to do more relocation work.  However, note that not
        # using -fpic will cause some of the tests to return different
-       # results.
-       if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
-            || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
+       # results.  Make sure that PLT is used since PLT is expected.
+       if { ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
+            || ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
            unresolved "visibility ($visibility) (non PIC)"
        } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
            visibility_test $visibility vnp "visibility ($visibility) (non PIC)" mainnp.o sh1np.o sh2np.o xcoff
@@ -284,8 +297,6 @@ proc visibility_run {visibility} {
                if [ string match $support_protected "no" ] {
                    setup_xfail $target_triplet
                }
-           } else {
-               setup_xfail "*-*-sunos4*"
            }
 
            # Non-pic code uses name binding rules for applications to
@@ -308,6 +319,7 @@ proc visibility_run {visibility} {
            if { [is_elf64 $tmpdir/mainnp.o] } {
                setup_xfail "x86_64-*-linux*"
            }
+           setup_xfail "x86_64-*-linux-gnux32"
            if { ![istarget hppa*64*-*-linux*] } {
                setup_xfail "hppa*-*-linux*"
            }
@@ -326,9 +338,6 @@ proc visibility_run {visibility} {
                if [ string match $support_protected "no" ] {
                    setup_xfail $target_triplet
                }
-           } else {
-               setup_xfail "*-*-sunos4*"
-               setup_xfail "*-*-linux*libc1"
            }
            if { [ string match $visibility "hidden_normal" ]
                 || [ string match $visibility "hidden_weak" ]
@@ -351,6 +360,7 @@ proc visibility_run {visibility} {
            if { [is_elf64 $tmpdir/mainnp.o] } {
                setup_xfail "x86_64-*-linux*"
            }
+           setup_xfail "x86_64-*-linux-gnux32"
            if { ![istarget hppa*64*-*-linux*] } {
                setup_xfail "hppa*-*-linux*"
            }
@@ -360,7 +370,7 @@ proc visibility_run {visibility} {
 
            visibility_test $visibility vnp "visibility ($visibility) (non PIC, load offset)" \
                mainnp.o sh1np.o sh2np.o elfvsb \
-               "-T $srcdir/$subdir/elf-offset.ld"
+               "-Wl,-T,$srcdir/$subdir/elf-offset.ld,--hash-style=sysv"
        } }
 
        # Now compile the code using -fpic.
@@ -375,14 +385,11 @@ proc visibility_run {visibility} {
                    setup_xfail $target_triplet
                }
            }
-           # SunOS can not compare function pointers correctly
-           if [istarget "*-*-sunos4*"] {
-               visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o sun4
-           } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
+           if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
                visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o xcoff
            } else {
-               visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o elfvsb
-           } }
+               visibility_test $visibility vp "visibility ($visibility)" mainnp.o sh1p.o sh2p.o elfvsb $COMPRESS_LDFLAG
+           }
        }
     }}
 
@@ -394,7 +401,8 @@ proc visibility_run {visibility} {
        unresolved "visibility ($visibility) (PIC main, non PIC so)"
        unresolved "visibility ($visibility) (PIC main)"
     } else {
-       if { [file exists $tmpdir/sh1np.o ] && [ file exists $tmpdir/sh2np.o ] } {
+       if { [ remote_file host exists $tmpdir/sh1np.o ]
+            && [ remote_file host exists $tmpdir/sh2np.o ] } {
            if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
                visibility_test $visibility vmpnp "visibility ($visibility) (PIC main, non PIC so)" mainp.o sh1np.o sh2np.o xcoff
            } else {
@@ -405,8 +413,6 @@ proc visibility_run {visibility} {
                    if [ string match $support_protected "no" ] {
                        setup_xfail $target_triplet
                    }
-               } else {
-                   setup_xfail "*-*-sunos4*"
                }
                if { ![ string match $visibility "hidden_undef" ]
                     && ![ string match $visibility "protected_undef" ] } {
@@ -425,6 +431,7 @@ proc visibility_run {visibility} {
                if { [is_elf64 $tmpdir/mainp.o] } {
                    setup_xfail "x86_64-*-linux*"
                }
+               setup_xfail "x86_64-*-linux-gnux32"
                if { ![istarget hppa*64*-*-linux*] } {
                    setup_xfail "hppa*-*-linux*"
                }
@@ -438,7 +445,8 @@ proc visibility_run {visibility} {
            unresolved "visibility (PIC main, non PIC so)"
        }
 
-       if { [file exists $tmpdir/sh1p.o ] && [ file exists $tmpdir/sh2p.o ] } {
+       if { [ remote_file host exists $tmpdir/sh1p.o ]
+            && [ remote_file host exists $tmpdir/sh2p.o ] } {
            if { [ string match $visibility "protected" ]
                 || [ string match $visibility "protected_undef_def" ] } {
                if [ string match $support_protected "no" ] {
@@ -473,11 +481,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"
@@ -496,7 +500,7 @@ visibility_run normal
 if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
     unresolved "common hidden symbol"
 } else {
-    if ![ld_simple_link $ld tmpdir/common "tmpdir/common.o"] {
+    if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
        fail "common hidden symbol"
     } else {
        pass "common hidden symbol"
@@ -509,15 +513,15 @@ if { ![ld_compile "$CC -g $CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
    if { ![ld_compile "$CC -g $CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
        unresolved "weak hidden symbol"
     } else {
-       if ![ld_simple_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
+       if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
            fail "weak hidden symbol"
        } else {
-           if ![ld_simple_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
+           if ![ld_link $ld tmpdir/weak "tmpdir/test.o tmpdir/sh3.o"] {
                fail "weak hidden symbol DSO last"
            } else {
                pass "weak hidden symbol DSO last"
            }
-           if ![ld_simple_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
+           if ![ld_link $ld tmpdir/weak "tmpdir/sh3.so tmpdir/test.o"] {
                fail "weak hidden symbol DSO first"
            } else {
                pass "weak hidden symbol DSO first"
This page took 0.026971 seconds and 4 git commands to generate.