]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - ld/testsuite/lib/ld-lib.exp
Emit a warning when -z relro is unsupported
[thirdparty/binutils-gdb.git] / ld / testsuite / lib / ld-lib.exp
index 5ebb7fa35fa512802a1b5a5581e499fcbc7a6c85..0a256c2395faa1df515e253c8a3b90f48ce2f702 100644 (file)
@@ -1,5 +1,5 @@
 # Support routines for LD testsuite.
-#   Copyright (C) 1994-2019 Free Software Foundation, Inc.
+#   Copyright (C) 1994-2020 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -463,12 +463,10 @@ proc run_ld_link_tests { ldtests args } {
     global CFLAGS
     global runtests
     global exec_output
-    global ld_elf_shared_opt
 
-    if { [is_elf_format] && [check_shared_lib_support] } {
-       set ld_extra_opt "$ld_elf_shared_opt"
-    } else {
-       set ld_extra_opt ""
+    set ld_extra_opt ""
+    if [check_relro_support] {
+       set ld_extra_opt "-z norelro"
     }
 
     foreach testitem $ldtests {
@@ -479,7 +477,10 @@ proc run_ld_link_tests { ldtests args } {
        }
 
        foreach target $args {
-           setup_xfail $target
+           if [match_target $target] {
+               setup_xfail "*-*-*"
+               break
+           }
        }
 
        set ld_options [lindex $testitem 1]
@@ -672,9 +673,6 @@ proc run_ld_link_exec_tests { ldtests args } {
     }
 
     foreach testitem $ldtests {
-       foreach target $args {
-           setup_xfail $target
-       }
        set testname [lindex $testitem 0]
        set ld_options [lindex $testitem 1]
        set as_options [lindex $testitem 2]
@@ -693,6 +691,13 @@ proc run_ld_link_exec_tests { ldtests args } {
            continue
        }
 
+       foreach target $args {
+           if [match_target $target] {
+               setup_xfail "*-*-*"
+               break
+           }
+       }
+
 #      verbose -log "Testname is $testname"
 #      verbose -log "ld_options is $ld_options"
 #      verbose -log "as_options is $as_options"
@@ -766,14 +771,9 @@ proc run_ld_link_exec_tests { ldtests args } {
                verbose "$exec_output" 1
                set failed 1
            } else {
-               send_log "diff $binfile.out $srcdir/$subdir/$expfile\n"
-               verbose "diff $binfile.out $srcdir/$subdir/$expfile"
-               catch "exec diff $binfile.out $srcdir/$subdir/$expfile" exec_output
-               set exec_output [prune_warnings $exec_output]
-
-               if ![string match "" $exec_output] then {
-                   send_log "$exec_output\n"
-                   verbose "$exec_output" 1
+               send_log [file_contents $binfile.out]
+               verbose [file_contents $binfile.out] 2
+               if [regexp_diff "$binfile.out" "$srcdir/$subdir/$expfile"] {
                    set failed 1
                }
            }
@@ -921,6 +921,7 @@ proc run_cc_link_tests { ldtests } {
 
        if { $binfile eq "tmpdir/" } {
            # compile only
+           set binfile $objfile
        } elseif { [regexp ".*\\.a$" $binfile] } {
            if { ![ar_simple_create $ar $ldflags $binfile "$objfiles"] } {
                set failed 1
@@ -1055,7 +1056,8 @@ proc check_gc_sections_available { } {
            || [istarget pj*-*-*]
            || [istarget pru*-*-*]
            || [istarget s12z-*-*]
-           || [istarget xgate-*-*] } {
+           || [istarget xgate-*-*]
+           || [istarget z80-*-*] } {
            set gc_sections_available_saved 0
            return 0
        }
@@ -1081,8 +1083,8 @@ proc check_gc_sections_available { } {
     return $gc_sections_available_saved
 }
 
-# Return true if target uses genelf.em (assuming it is ELF).
-proc is_generic_elf { } {
+# Return true if target uses genelf.em.
+proc uses_genelf { } {
     if { [istarget "d30v-*-*"]
         || [istarget "dlx-*-*"]
         || [istarget "fr30-*-*"]
@@ -1090,14 +1092,14 @@ proc is_generic_elf { } {
         || [istarget "ft32-*-*"]
         || [istarget "iq2000-*-*"]
         || [istarget "mn10200-*-*"]
-        || [istarget "moxie-*-*"]
         || [istarget "msp430-*-*"]
         || [istarget "mt-*-*"]
         || [istarget "pj*-*-*"]
+        || [istarget "s12z-*-*"]
         || [istarget "xgate-*-*"] } {
-       return 1;
+       return 1
     }
-    return 0;
+    return 0
 }
 
 proc is_underscore_target { } {
@@ -1126,7 +1128,8 @@ proc check_plugin_api_available { } {
     if {![info exists plugin_api_available_saved]} {
        # Check if the ld used by gcc supports --plugin.
        set ld_output [remote_exec host $ld "--help"]
-       if { [ string first "-plugin PLUGIN" $ld_output ] >= 0 } {
+       if { [regexp -- "-plugin PLUGIN \[^\n\r\]*" $ld_output line]
+            && ![regexp "ignored" $line] } {
            set plugin_api_available_saved 1
        } else {
            set plugin_api_available_saved 0