python/hypothesis: update to 6.122.3
[oi-userland.git] / components / developer / gcc-13 / patches / 0030-Use-the-illumos-libc-SSP-implementation-for-fstack-p.patch
blob265420ee49c99136e852c3c9563769fc80a28711
1 From 05ff12edd4943fe5b1862f4c0c0edc6a14ce7d4e Mon Sep 17 00:00:00 2001
2 From: Andy Fiddaman <omnios@citrus-it.co.uk>
3 Date: Wed, 4 Nov 2020 16:16:25 +0000
4 Subject: Use the illumos libc SSP implementation for
5 -fstack-protector
7 ---
8 gcc/config/i386/sol2.h | 17 +++++++++++++++++
9 gcc/configure | 2 +-
10 gcc/configure.ac | 2 +-
11 3 files changed, 19 insertions(+), 2 deletions(-)
13 diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
14 index 7093d90b191a..66a076ccd45e 100644
15 --- a/gcc/config/i386/sol2.h
16 +++ b/gcc/config/i386/sol2.h
17 @@ -252,3 +252,20 @@ along with GCC; see the file COPYING3. If not see
18 /* We do not need NT_VERSION notes. */
19 #undef X86_FILE_START_VERSION_DIRECTIVE
20 #define X86_FILE_START_VERSION_DIRECTIVE false
22 +/*
23 + * As of 5788, the illumos libc includes support for the stack protector
24 + * __stack_chk_fail() function and for the __stack_chk_guard variable.
25 + * That means that, for most cases, no extra objects need to be linked in
26 + * when compiling with one of the -fstack-protector options.
27 + * However, for 32-bit PIC/PIE objects, the gcc stack protector emits a
28 + * function call to __stack_chk_fail_local(); this symbol is provided in
29 + * illumos via the libssp_ns.a object. The spec below includes this in the
30 + * link when appropriate.
31 + */
32 +#if defined(TARGET_LIBC_PROVIDES_SSP)
33 +#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all|" \
34 + "fstack-protector-strong|fstack-protector-explicit:" \
35 + DEF_ARCH32_SPEC("-lssp_ns") \
36 + "}"
37 +#endif
38 diff --git a/gcc/configure b/gcc/configure
39 index 6d06fe9226d7..750f87e788ed 100755
40 --- a/gcc/configure
41 +++ b/gcc/configure
42 @@ -31162,7 +31162,7 @@ fi
43 # realistically usable GNU/Hurd configurations.
44 # All supported versions of musl provide it as well
45 gcc_cv_libc_provides_ssp=yes;;
46 - *-*-darwin* | *-*-freebsd* | *-*-netbsd*)
47 + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*)
48 ac_fn_cxx_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail"
49 if test "x$ac_cv_func___stack_chk_fail" = xyes; then :
50 gcc_cv_libc_provides_ssp=yes
51 diff --git a/gcc/configure.ac b/gcc/configure.ac
52 index 4a3f16924759..73346cd04de4 100644
53 --- a/gcc/configure.ac
54 +++ b/gcc/configure.ac
55 @@ -6772,7 +6772,7 @@ AC_CACHE_CHECK(__stack_chk_fail in target C library,
56 # realistically usable GNU/Hurd configurations.
57 # All supported versions of musl provide it as well
58 gcc_cv_libc_provides_ssp=yes;;
59 - *-*-darwin* | *-*-freebsd* | *-*-netbsd*)
60 + *-*-darwin* | *-*-freebsd* | *-*-netbsd* | *-*-solaris2*)
61 AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes],
62 [echo "no __stack_chk_fail on this target"])