Skip to content

Commit 8f37419

Browse files
committed
Use the illumos libc SSP implementation for -fstack-protector
1 parent 0c81be3 commit 8f37419

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

gcc/config/i386/sol2.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,20 @@ along with GCC; see the file COPYING3. If not see
259259
/* We do not need NT_VERSION notes. */
260260
#undef X86_FILE_START_VERSION_DIRECTIVE
261261
#define X86_FILE_START_VERSION_DIRECTIVE false
262+
263+
/*
264+
* As of 5788, the illumos libc includes support for the stack protector
265+
* __stack_chk_fail() function and for the __stack_chk_guard variable.
266+
* That means that, for most cases, no extra objects need to be linked in
267+
* when compiling with one of the -fstack-protector options.
268+
* However, for 32-bit PIC/PIE objects, the gcc stack protector emits a
269+
* function call to __stack_chk_fail_local(); this symbol is provided in
270+
* illumos via the libssp_ns.a object. The spec below includes this in the
271+
* link when appropriate.
272+
*/
273+
#if defined(TARGET_LIBC_PROVIDES_SSP)
274+
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all|" \
275+
"fstack-protector-strong|fstack-protector-explicit:" \
276+
DEF_ARCH32_SPEC("-lssp_ns") \
277+
"}"
278+
#endif

gcc/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29283,7 +29283,7 @@ fi
2928329283
# realistically usable GNU/Hurd configurations.
2928429284
# All supported versions of musl provide it as well
2928529285
gcc_cv_libc_provides_ssp=yes;;
29286-
*-*-darwin* | *-*-freebsd* | *-*-netbsd*)
29286+
*-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*)
2928729287
ac_fn_cxx_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
2928829288
if test "x$ac_cv_func___stack_chk_fail" = xyes; then :
2928929289
gcc_cv_libc_provides_ssp=yes

gcc/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5965,7 +5965,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
59655965
# realistically usable GNU/Hurd configurations.
59665966
# All supported versions of musl provide it as well
59675967
gcc_cv_libc_provides_ssp=yes;;
5968-
*-*-darwin* | *-*-freebsd* | *-*-netbsd*)
5968+
*-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*)
59695969
AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
59705970
[echo "no __stack_chk_fail on this target"])
59715971
;;

0 commit comments

Comments
 (0)