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(-)
@@ -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
@@ -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]]"
}
#
@@ -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