void-packages/srcpkgs/gcc/files/libssp-musl.patch
2021-06-21 19:22:07 +07:00

70 lines
2.7 KiB
Diff

First part taken from Alpine.
Second part added to prevent gccgo from thinking it can -fsplit-stack on musl.
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -874,10 +874,15 @@ proper position among the other output files. */
#define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
#endif
+#ifdef ENABLE_DEFAULT_SSP
+#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
+#else
+#define NO_SSP_SPEC ""
+#endif
+
#ifndef LINK_SSP_SPEC
#ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
- "|fstack-protector-strong|fstack-protector-explicit:}"
+#define LINK_SSP_SPEC "-lssp_nonshared"
#else
#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
"|fstack-protector-strong|fstack-protector-explicit" \
@@ -1155,7 +1160,7 @@ static const char *cc1_options =
%{-version:--version}\
%{-help=*:--help=%*}\
%{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
- %{fsyntax-only:-o %j} %{-param*}\
+ %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
%{coverage:-fprofile-arcs -ftest-coverage}\
%{fprofile-arcs|fprofile-generate*|coverage:\
%{!fprofile-update=single:\
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -853,7 +853,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
The maximum number of SSA_NAME assignments to follow in determining a value.
-param=ssp-buffer-size=
-Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
+Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
The lower bound for a buffer to be considered for stack smashing protection.
-param=stack-clash-protection-guard-size=
--- a/gcc/config/i386/gnu-user-common.h
+++ b/gcc/config/i386/gnu-user-common.h
@@ -64,9 +64,3 @@ along with GCC; see the file COPYING3. If not see
/* Static stack checking is supported by means of probes. */
#define STACK_CHECK_STATIC_BUILTIN 1
-
-/* We only build the -fsplit-stack support in libgcc if the
- assembler has full support for the CFI directives. */
-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
-#define TARGET_CAN_SPLIT_STACK
-#endif
--- a/gcc/config/i386/gnu.h
+++ b/gcc/config/i386/gnu.h
@@ -40,11 +40,6 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
/* i386 glibc provides __stack_chk_guard in %gs:0x14. */
#define TARGET_THREAD_SSP_OFFSET 0x14
-/* We only build the -fsplit-stack support in libgcc if the
- assembler has full support for the CFI directives. */
-#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
-#define TARGET_CAN_SPLIT_STACK
-#endif
/* We steal the last transactional memory word. */
#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
#endif