Run PR ld/17618 test only with 64-bit ELF linker
[deliverable/binutils-gdb.git] / ld / testsuite / config / default.exp
index 8ccad111b5f930bcd4b599e34471657301a410c0..355d98f24a89fcdf0cc6b917a3c8bb5afe1b3bb6 100644 (file)
@@ -1,5 +1,5 @@
 # Basic expect script for LD Regression Tests
-#   Copyright (C) 1993-2016 Free Software Foundation, Inc.
+#   Copyright (C) 1993-2017 Free Software Foundation, Inc.
 #
 # This file is part of the GNU Binutils.
 #
@@ -76,6 +76,9 @@ if {[file exists tmpdir/libpath.exp]} {
     }
 }
 
+# Many ELF testcases expect that "-z relro" is off.
+set ld_elf_shared_opt "-z norelro"
+
 # The "make check" target in the Makefile passes in
 # "CC=$(CC_FOR_TARGET)".  But, if the user invokes runtest directly
 # (as when testing an installed linker), these flags may not be set.  
@@ -111,26 +114,6 @@ if { [istarget rx-*-*] } {
 # load the utility procedures
 load_lib ld-lib.exp
 
-proc get_link_files {varname} {
-    global $varname
-    global target_triplet
-    global srcdir
-    global CC
-    if ![info exists $varname] {
-       #configure.host returns variables that can be substituted into
-       #makefile rules, with embedded shell variable expansions.
-       #make wants $$shell_var, we want $shell_var ...
-       set cmd "host='$target_triplet' && . $srcdir/../configure.host && sed -e 's,\\\$\\\$,\$,g' <<EOF\n\$$varname\nEOF"
-       set status [catch "exec sh -c [list $cmd]" result]
-       if $status { error "Error getting native link files: $result" }
-       set cmd "CC='$CC' && eval echo \"$result\""
-       set status [catch "exec sh -c [list $cmd]" result]
-       if $status { error "Error getting native link files: $result" }
-       set $varname $result
-       send_log "$varname = $result\n"
-    }
-}
-
 proc get_target_emul {} {
     global target_triplet
     global srcdir
@@ -139,13 +122,6 @@ proc get_target_emul {} {
     return $result
 }
 
-if [isnative] {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} {
-       get_link_files $x
-    }
-} else {
-    foreach x {HOSTING_CRT0 HOSTING_SCRT0 HOSTING_LIBS HOSTING_SLIBS} { set $x "" }
-}
 if ![info exists HOSTING_EMU] { set HOSTING_EMU "-m [get_target_emul]" }
 
 #
@@ -186,14 +162,6 @@ proc ld_link { ld target objects } {
        default_ld_link $ld $target $objects
 }
 
-#
-# ld_simple_link 
-#      link a program using ld, without including any libraries
-#
-proc ld_simple_link { ld target objects } {
-       default_ld_simple_link $ld $target $objects
-}
-
 #
 # ld_compile 
 #      compile an object using $cc
@@ -283,6 +251,16 @@ if ![info exists LDFLAGS] then {
     set LDFLAGS {}
 }
 
+# Set LD_CLASS to "64bit" for 64-bit LD.
+if { ![info exists LD_CLASS] } then {
+    set readelf_output [run_host_cmd "$READELF" "-h $LD"]
+    if { [regexp {[ \t]+Class:[ \t]+ELF64} $readelf_output] } then {
+       set LD_CLASS "64bit"
+    } else {
+       set LD_CLASS "32bit"
+    }
+}
+
 # Set PLT_CFLAGS to "-fplt" if target compiler supports it.
 
 if { ![info exists PLT_CFLAGS] } then {
@@ -360,3 +338,40 @@ if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then {
        set NOPIE_LDFLAGS ""
     }
 }
+
+# Set GNU2_CFLAGS to "-mtls-dialect=gnu2" if target compiler supports it.
+
+if { ![info exists GNU2_CFLAGS] } then {
+    if { [which $CC] != 0 } {
+       # Check if gcc supports -mtls-dialect=gnu2
+       set flags ""
+       if [board_info [target_info name] exists cflags] {
+           append flags " [board_info [target_info name] cflags]"
+       }
+       if [board_info [target_info name] exists ldflags] {
+           append flags " [board_info [target_info name] ldflags]"
+       }
+
+       set basename "tmpdir/gnu2[pid]"
+       set src ${basename}.c
+       set output ${basename}.o
+       set f [open $src "w"]
+       puts $f "__thread int yyy = 100;"
+       close $f
+       if [is_remote host] {
+           set src [remote_download host $src]
+       }
+       set gnu2_available [run_host_cmd_yesno "$CC" "$flags -c -mtls-dialect=gnu2 $src -o $output"]
+       remote_file host delete $src
+       remote_file host delete $output
+       file delete $src
+
+       if { $gnu2_available == 1 } then {
+           set GNU2_CFLAGS "-mtls-dialect=gnu2"
+       } else {
+           set GNU2_CFLAGS ""
+       }
+    } else {
+       set GNU2_CFLAGS ""
+    }
+}
This page took 0.025626 seconds and 4 git commands to generate.