aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-05-01 11:02:55 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-05-01 11:02:55 -0700
commit0aae7e72a2a11ef1fd2a3b4fd18c8d8d49e0c21b (patch)
tree84262db1a870e6b7187b3c00bce5f52b7690b4a5 /ld/testsuite/lib/ld-lib.exp
parentgdb/MAINTAINERS: Move Daniel J and Mark to the Past Maintainers section. (diff)
downloadbinutils-gdb-0aae7e72a2a11ef1fd2a3b4fd18c8d8d49e0c21b.tar.gz
binutils-gdb-0aae7e72a2a11ef1fd2a3b4fd18c8d8d49e0c21b.tar.bz2
binutils-gdb-0aae7e72a2a11ef1fd2a3b4fd18c8d8d49e0c21b.zip
x86: Run GNU2 TLS tests with working GNU2 TLS support
Check if GNU2 TLS really works before running GNU2 TLS tests. * testsuite/ld-i386/tls.exp: Run GNU2 TLS tests only if there is working GNU2 TLS support. * testsuite/ld-x86-64/tls.exp: Likewise. * testsuite/lib/ld-lib.exp (check_gnu2_tls_available): New proc.
Diffstat (limited to 'ld/testsuite/lib/ld-lib.exp')
-rw-r--r--ld/testsuite/lib/ld-lib.exp64
1 files changed, 64 insertions, 0 deletions
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index b60fcadf058..aecc7008385 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -2210,3 +2210,67 @@ proc check_libdl_available { } {
}
return $libdl_available_saved
}
+
+# Returns true if GNU2 TLS works.
+
+proc check_gnu2_tls_available { } {
+ global gnu2_tls_available_saved
+ global CC
+ global GNU2_CFLAGS
+
+ if {![info exists gnu2_tls_available_saved]} {
+ if { [which $CC] == 0 || "$GNU2_CFLAGS" == "" } {
+ set gnu2_tls_available_saved 0
+ return 0
+ }
+ # Check if GNU2 TLS works.
+ set flags "$GNU2_CFLAGS"
+ 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_tls[pid]"
+ set src1 ${basename}1.c
+ set output1 ${basename}.so
+ set f [open $src1 "w"]
+ puts $f "extern __thread int zzz;"
+ puts $f "int foo (void)"
+ puts $f "{"
+ puts $f " return zzz;"
+ puts $f "}"
+ close $f
+ if [is_remote host] {
+ set src1 [remote_download host $src1]
+ }
+ set src2 ${basename}2.c
+ set output2 ${basename}.exe
+ set f [open $src2 "w"]
+ puts $f "__thread int zzz = 20;"
+ puts $f "extern int foo (void);"
+ puts $f "int main (void)"
+ puts $f "{"
+ puts $f " if (foo () != 20) __builtin_abort ();"
+ puts $f " return 0; "
+ puts $f "}"
+ close $f
+ if [is_remote host] {
+ set src2 [remote_download host $src2]
+ }
+ set gnu2_tls_available_saved [run_host_cmd_yesno "$CC" "-fPIC -shared $flags $src1 -o $output1"]
+ if { $gnu2_tls_available_saved == 1 } {
+ set gnu2_tls_available_saved [run_host_cmd_yesno "$CC" "$flags $src2 $output1 -o $output2"]
+ if { $gnu2_tls_available_saved == 1 } {
+ set gnu2_tls_available_saved [run_host_cmd_yesno "$output2" ""]
+ }
+ }
+ remote_file host delete $src1
+ remote_file host delete $output1
+ remote_file host delete $src2
+ remote_file host delete $output2
+ file delete $src1 $src2
+ }
+ return $gnu2_tls_available_saved
+}