diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h index 09e401cca20cb..2741a48b25c4b 100644 --- a/gcc/config/i386/sol2.h +++ b/gcc/config/i386/sol2.h @@ -259,3 +259,20 @@ along with GCC; see the file COPYING3. If not see /* We do not need NT_VERSION notes. */ #undef X86_FILE_START_VERSION_DIRECTIVE #define X86_FILE_START_VERSION_DIRECTIVE false + +/* + * As of 5788, the illumos libc includes support for the stack protector + * __stack_chk_fail() function and for the __stack_chk_guard variable. + * That means that, for most cases, no extra objects need to be linked in + * when compiling with one of the -fstack-protector options. + * However, for 32-bit PIC/PIE objects, the gcc stack protector emits a + * function call to __stack_chk_fail_local(); this symbol is provided in + * illumos via the libssp_ns.a object. The spec below includes this in the + * link when appropriate. + */ +#if defined(TARGET_LIBC_PROVIDES_SSP) +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all|" \ + "fstack-protector-strong|fstack-protector-explicit:" \ + DEF_ARCH32_SPEC("-lssp_ns") \ + "}" +#endif diff --git a/gcc/configure b/gcc/configure index 10d503d8abcf1..e72841818e5e3 100755 --- a/gcc/configure +++ b/gcc/configure @@ -29283,7 +29283,7 @@ fi # realistically usable GNU/Hurd configurations. # All supported versions of musl provide it as well gcc_cv_libc_provides_ssp=yes;; - *-*-darwin* | *-*-freebsd* | *-*-netbsd*) + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*) ac_fn_cxx_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail" if test "x$ac_cv_func___stack_chk_fail" = xyes; then : gcc_cv_libc_provides_ssp=yes diff --git a/gcc/configure.ac b/gcc/configure.ac index b9fecd02a63a3..7107ab20098d0 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5965,7 +5965,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library, # realistically usable GNU/Hurd configurations. # All supported versions of musl provide it as well gcc_cv_libc_provides_ssp=yes;; - *-*-darwin* | *-*-freebsd* | *-*-netbsd*) + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*) AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes], [echo "no __stack_chk_fail on this target"]) ;;