[2/7,MSP430,TESTSUITE] Add path to libssp to the linker search path when checking for -fstack-protector support
diff mbox series

Message ID e98e2778-edca-fa37-6481-e71001946713@mittosystems.com
State New
Headers show
Series
  • Fix GCC tests for msp430-elf
Related show

Commit Message

Jozef Lawrynowicz Nov. 14, 2018, 3:47 p.m. UTC
Patch 2 fixes issues finding libssp when linking tests or checking for
fstack_protector support.

Patch
diff mbox series

From 6c6f34bae386a5f396e6f9630514fc7080c2f940 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Sun, 11 Nov 2018 14:30:32 +0000
Subject: [PATCH 2/7] [TESTSUITE] Add path to libssp to the linker search path
 when checking for -fstack-protector support

2018-11-14  Jozef Lawrynowicz  <jozef.l@mittosystems.com>

	gcc/testsuite/ChangeLog:

	lib/g++.exp (g++_link_flags): Append path to libssp to link flags.
	lib/gcc.exp (gcc_link_flags): New.
	(gcc_init): Append gcc_link_flags result to TEST_EXTRA_LIBS. 
	lib/target-supports.exp (check_effective_target_fstack_protector): Pass
	path to libssp as extra flags to check_runtime.
---
 gcc/testsuite/lib/g++.exp             |  4 ++++
 gcc/testsuite/lib/gcc.exp             | 34 ++++++++++++++++++++++++++++++++++
 gcc/testsuite/lib/target-supports.exp |  2 +-
 3 files changed, 39 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/lib/g++.exp b/gcc/testsuite/lib/g++.exp
index c0ffcdf..710bc9b 100644
--- a/gcc/testsuite/lib/g++.exp
+++ b/gcc/testsuite/lib/g++.exp
@@ -149,6 +149,10 @@  proc g++_link_flags { paths } {
 	  append flags "-B${gccpath}/libitm/ -L${gccpath}/libitm/.libs"
 	  append ld_library_path ":${gccpath}/libitm/.libs"
       }
+      if [file exists "${gccpath}/libssp/.libs/libssp.a"] {
+	  append flags "-L${gccpath}/libssp/.libs "
+	  append ld_library_path ":${gccpath}/libssp/.libs"
+      }
       append ld_library_path [gcc-set-multilib-library-path $GXX_UNDER_TEST]
     } else {
       global tool_root_dir
diff --git a/gcc/testsuite/lib/gcc.exp b/gcc/testsuite/lib/gcc.exp
index 61e995a..4c5c652 100644
--- a/gcc/testsuite/lib/gcc.exp
+++ b/gcc/testsuite/lib/gcc.exp
@@ -78,6 +78,37 @@  proc gcc_version { } {
 }
 
 #
+# gcc_link_flags -- provide gcc_link_flags, based on g++_link_flags
+# (originally from libgloss.exp) which knows about the gcc tree structure
+#
+
+proc gcc_link_flags { paths } {
+    global ld_library_path
+
+    set gccpath ${paths}
+    set flags ""
+
+    if { $gccpath != "" } {
+	if [file exists "${gccpath}/libssp/.libs/libssp.a"] {
+	    append flags "-L${gccpath}/libssp/.libs "
+	    append ld_library_path ":${gccpath}/libssp/.libs"
+	}
+    } else {
+	global tool_root_dir
+
+	set libssp [lookfor_file ${tool_root_dir} libssp]
+	if { $libssp != "" } {
+	    append flags "-L${libssp} "
+	    append ld_library_path ":${libssp}"
+	}
+    }
+
+    set_ld_library_path_env_vars
+
+    return "$flags"
+}
+
+#
 # gcc_init -- called at the start of each .exp script.
 #
 # There currently isn't much to do, but always using it allows us to
@@ -95,6 +126,7 @@  proc gcc_init { args } {
     global TOOL_EXECUTABLE
     global gcc_warning_prefix
     global gcc_error_prefix
+    global TEST_EXTRA_LIBS
 
     if { $gcc_initialized == 1 } { return; }
 
@@ -114,6 +146,8 @@  proc gcc_init { args } {
     set gcc_error_prefix "(fatal )?error:"
 
     gcc_maybe_build_wrapper "${tmpdir}/gcc-testglue.o"
+
+    append TEST_EXTRA_LIBS "[gcc_link_flags [get_multilibs]]"
 }
 
 #
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 4966e50..093b12a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1062,7 +1062,7 @@  proc check_effective_target_fstack_protector {} {
 	  char buf[64];
 	  return !strcpy (buf, strrchr (argv[0], '/'));
 	}
-    } "-fstack-protector"]
+    } "-fstack-protector -B[get_multilibs]/libssp/ -L[get_multilibs]/libssp/.libs"]
 }
 
 # Return 1 if the target supports -fstack-check or -fstack-check=$stack_kind
-- 
2.7.4