From c355364231395090e7223ec00d8a16065903c2c5 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Fri, 25 Jul 2025 01:49:03 -0700 Subject: [PATCH] gcc: disable SSP on -ffreestanding, -nostdlib and -nodefaultlibs --- gcc/gcc.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/gcc.cc b/gcc/gcc.cc index fc9c7d15b04..7b0d3d2743b 100644 --- a/gcc/gcc.cc +++ b/gcc/gcc.cc @@ -1009,6 +1009,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" \ @@ -1314,7 +1320,7 @@ static const char *cc1_options = %{-version:--version}\ %{-help=*:--help=%*}\ %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %w%b.s}}}\ - %{fsyntax-only:-o %j} %{-param*}\ + %{fsyntax-only:-o %j} %{-param*} " NO_SSP_SPEC "\ %{coverage:-fprofile-arcs -ftest-coverage}\ %{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\ %{!fprofile-update=single:\ -- 2.50.1