From 1d3b23e6bdbf53eb74161c37d8c355c2ec858a19 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:58:36 +0200 Subject: Adding debian version 14-20240201-3. Signed-off-by: Daniel Baumann --- debian/patches/gcc-distro-specs.diff | 326 +++++++++++++++++++++++++++++++++++ 1 file changed, 326 insertions(+) create mode 100644 debian/patches/gcc-distro-specs.diff (limited to 'debian/patches/gcc-distro-specs.diff') diff --git a/debian/patches/gcc-distro-specs.diff b/debian/patches/gcc-distro-specs.diff new file mode 100644 index 0000000..098d181 --- /dev/null +++ b/debian/patches/gcc-distro-specs.diff @@ -0,0 +1,326 @@ +# DP: Add empty distro and hardening specs + +--- a/src/gcc/gcc.cc ++++ b/src/gcc/gcc.cc +@@ -27,6 +27,11 @@ CC recognizes how to compile each input + Once it knows which kind of compilation to perform, the procedure for + compilation is specified by a string called a "spec". */ + ++/* Inject some default compilation flags which are used as the default. ++ Done by the packaging build system. Should that be done in the headers ++ gcc/config//*.h instead? */ ++#include "distro-defaults.h" ++ + #define INCLUDE_STRING + #include "config.h" + #include "system.h" +@@ -984,6 +989,90 @@ proper position among the other output f + #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}" + #endif + ++/* Generate full unwind information covering all program points. ++ Only needed for some architectures. */ ++#ifndef ASYNC_UNWIND_SPEC ++# ifdef DIST_DEFAULT_ASYNC_UNWIND ++# define ASYNC_UNWIND_SPEC "%{!fno-asynchronous-unwind-tables:-fasynchronous-unwind-tables}" ++# else ++# define ASYNC_UNWIND_SPEC "" ++# endif ++#endif ++ ++/* Turn on stack protector. ++ */ ++#ifndef SSP_DEFAULT_SPEC ++# ifdef DIST_DEFAULT_SSP ++# ifdef DIST_DEFAULT_SSP_STRONG ++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}}}}" ++# else ++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:-fstack-protector}}}}" ++# endif ++# else ++# define SSP_DEFAULT_SPEC "" ++# endif ++#endif ++ ++/* Turn on -Wformat -Wformat-security by default for C, C++, ++ ObjC, ObjC++. */ ++#ifndef FORMAT_SECURITY_SPEC ++# ifdef DIST_DEFAULT_FORMAT_SECURITY ++# define FORMAT_SECURITY_SPEC " %{!Wformat:%{!Wformat=2:%{!Wformat=0:%{!Wall:-Wformat} %{!Wno-format-security:-Wformat-security}}}}" ++# else ++# define FORMAT_SECURITY_SPEC "" ++# endif ++#endif ++ ++/* Enable -fstack-clash-protection by default. Only available ++ on some targets. */ ++#ifndef STACK_CLASH_SPEC ++# ifdef DIST_DEFAULT_STACK_CLASH ++# define STACK_CLASH_SPEC " %{!fno-stack-clash-protection:-fstack-clash-protection}" ++# else ++# define STACK_CLASH_SPEC "" ++# endif ++#endif ++ ++/* Enable code instrumentation of control-flow transfers. ++ Available on x86 and x86_64. */ ++#ifndef CF_PROTECTION_SPEC ++# ifdef DIST_DEFAULT_CF_PROTECTION ++# define CF_PROTECTION_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}" ++# else ++# define CF_PROTECTION_SPEC "" ++# endif ++#endif ++ ++#ifndef BIND_NOW_SPEC ++# if defined(DIST_DEFAULT_BIND_NOW) && !defined(ACCEL_COMPILER) ++# define BIND_NOW_SPEC " -z now" ++# else ++# define BIND_NOW_SPEC "" ++# endif ++#endif ++ ++#ifndef RELRO_SPEC ++# ifdef DIST_DEFAULT_RELRO ++# define RELRO_SPEC " -z relro " ++# else ++# define RELRO_SPEC "" ++# endif ++#endif ++ ++/* Don't enable any of those for the offload compilers, ++ unsupported. */ ++#if !defined(DISTRO_DEFAULT_SPEC) && !defined(ACCEL_COMPILER) ++# define DISTRO_DEFAULT_SPEC ASYNC_UNWIND_SPEC SSP_DEFAULT_SPEC \ ++ FORMAT_SECURITY_SPEC STACK_CLASH_SPEC CF_PROTECTION_SPEC ++#else ++# define DISTRO_DEFAULT_SPEC "" ++#endif ++#if !defined(DISTRO_DEFAULT_LINK_SPEC) && !defined(ACCEL_COMPILER) ++# define DISTRO_DEFAULT_LINK_SPEC RELRO_SPEC ++#else ++# define DISTRO_DEFAULT_LINK_SPEC "" ++#endif ++ + #ifndef LINK_SSP_SPEC + #ifdef TARGET_LIBC_PROVIDES_SSP + #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \ +@@ -1040,7 +1129,7 @@ proper position among the other output f + #ifndef LINK_PIE_SPEC + #ifdef HAVE_LD_PIE + #ifndef LD_PIE_SPEC +-#define LD_PIE_SPEC "-pie" ++#define LD_PIE_SPEC "-pie" BIND_NOW_SPEC + #endif + #else + #define LD_PIE_SPEC "" +@@ -1157,6 +1246,7 @@ proper position among the other output f + "%{flto|flto=*:%/ instead? */ ++#include "distro-defaults.h" ++ + #ifndef TARGET_OS_CPP_BUILTINS + # define TARGET_OS_CPP_BUILTINS() + #endif +@@ -1578,6 +1583,15 @@ c_cpp_builtins (cpp_reader *pfile) + builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0); + builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0); + ++#ifdef DIST_DEFAULT_FORTIFY_SOURCE ++ /* Fortify Source enabled by default for optimization levels > 0 */ ++ if (optimize && ++ !cpp_defined(parse_in, ++ (const unsigned char *) "_FORTIFY_SOURCE", ++ strlen("_FORTIFY_SOURCE"))) ++ builtin_define_with_int_value ("_FORTIFY_SOURCE", DIST_DEFAULT_FORTIFY_SOURCE); ++#endif ++ + /* Misc. */ + if (flag_gnu89_inline) + cpp_define (pfile, "__GNUC_GNU_INLINE__"); -- cgit v1.2.3