0008-Disable-ssp-on-nostdlib-nodefaultlibs-and-ffreestand.patch 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. From 3503fd734a33b67ec6a9fdc2c52bb8310864b119 Mon Sep 17 00:00:00 2001
  2. From: Ariadne Conill <ariadne@dereferenced.org>
  3. Date: Fri, 21 Aug 2020 06:49:40 +0000
  4. Subject: [PATCH] Disable ssp on -nostdlib, -nodefaultlibs and -ffreestanding
  5. Change the buffer size.
  6. ---
  7. gcc/gcc.c | 8 +++++++-
  8. gcc/params.opt | 2 +-
  9. 2 files changed, 8 insertions(+), 2 deletions(-)
  10. diff --git a/gcc/gcc.c b/gcc/gcc.c
  11. index 1ad5da6d769..99314032ec2 100644
  12. --- a/gcc/gcc.c
  13. +++ b/gcc/gcc.c
  14. @@ -989,6 +989,12 @@ proper position among the other output files. */
  15. #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
  16. #endif
  17. +#ifdef ENABLE_DEFAULT_SSP
  18. +#define NO_SSP_SPEC "%{nostdlib|nodefaultlibs|ffreestanding:-fno-stack-protector} "
  19. +#else
  20. +#define NO_SSP_SPEC ""
  21. +#endif
  22. +
  23. #ifndef LINK_SSP_SPEC
  24. #ifdef TARGET_LIBC_PROVIDES_SSP
  25. #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
  26. @@ -1288,7 +1294,7 @@ static const char *cc1_options =
  27. %{-version:--version}\
  28. %{-help=*:--help=%*}\
  29. %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\
  30. - %{fsyntax-only:-o %j} %{-param*}\
  31. + %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\
  32. %{coverage:-fprofile-arcs -ftest-coverage}\
  33. %{fprofile-arcs|fprofile-generate*|coverage:\
  34. %{!fprofile-update=single:\
  35. diff --git a/gcc/params.opt b/gcc/params.opt
  36. index 8ba281b4cfa..bab39cdf8a2 100644
  37. --- a/gcc/params.opt
  38. +++ b/gcc/params.opt
  39. @@ -946,7 +946,7 @@ Common Joined UInteger Var(param_ssa_name_def_chain_limit) Init(512) Param Optim
  40. The maximum number of SSA_NAME assignments to follow in determining a value.
  41. -param=ssp-buffer-size=
  42. -Common Joined UInteger Var(param_ssp_buffer_size) Init(8) IntegerRange(1, 65536) Param Optimization
  43. +Common Joined UInteger Var(param_ssp_buffer_size) Init(4) IntegerRange(1, 65536) Param Optimization
  44. The lower bound for a buffer to be considered for stack smashing protection.
  45. -param=stack-clash-protection-guard-size=
  46. --
  47. 2.35.1