Skip to content

Commit

Permalink
Use the illumos libc SSP implementation for -fstack-protector
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed May 31, 2023
1 parent 83b0705 commit 6073fa1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions gcc/config/i386/sol2.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,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
2 changes: 1 addition & 1 deletion gcc/configure
Original file line number Diff line number Diff line change
Expand Up @@ -31162,7 +31162,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
Expand Down
2 changes: 1 addition & 1 deletion gcc/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6772,7 +6772,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"])
;;
Expand Down

0 comments on commit 6073fa1

Please sign in to comment.