aboutsummaryrefslogtreecommitdiffstats
path: root/main/gcc/0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch
blob: 0b3ce1a78136938beadf78e3ac50980f2218a008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
From 23fd86ff34670873dd294bd87b93f45c3624903a Mon Sep 17 00:00:00 2001
From: Ariadne Conill <ariadne@dereferenced.org>
Date: Fri, 21 Aug 2020 06:49:40 +0000
Subject: [PATCH 08/30] Disable ssp on -nostdlib, -nodefaultlibs and
 -ffreestanding Change the buffer size.

---
 gcc/gcc.c      | 8 +++++++-
 gcc/params.opt | 2 +-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 7aec9d3a016..daeb4d0c8ea 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -886,6 +886,12 @@ 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" \
@@ -1170,7 +1176,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:\
diff --git a/gcc/params.opt b/gcc/params.opt
index 4aec480798b..eaecfab37ad 100644
--- 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=
-- 
2.27.0