From 36847977cb95e319ec67ab2edf85e6ea96783628 Mon Sep 17 00:00:00 2001 From: Felix Singer Date: Thu, 1 Dec 2022 11:36:17 +0000 Subject: util/crossgcc: Update GCC from 11.2 to 11.3 While the work on updating GCC to version 12 is still WIP, update it to the latest minor release 11.3. Signed-off-by: Felix Singer Change-Id: I8810bbb238b01985774ff8da1e246ab1b192e663 Reviewed-on: https://review.coreboot.org/c/coreboot/+/70221 Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) Reviewed-by: Lean Sheng Tan --- util/crossgcc/buildgcc | 2 +- .../patches/gcc-11.2.0_ada-musl_workaround.patch | 120 --------------------- .../gcc-11.2.0_asan_shadow_offset_callback.patch | 88 --------------- util/crossgcc/patches/gcc-11.2.0_gnat.patch | 41 ------- util/crossgcc/patches/gcc-11.2.0_libcpp.patch | 56 ---------- util/crossgcc/patches/gcc-11.2.0_libgcc.patch | 60 ----------- .../patches/gcc-11.3.0_ada-musl_workaround.patch | 120 +++++++++++++++++++++ .../gcc-11.3.0_asan_shadow_offset_callback.patch | 88 +++++++++++++++ util/crossgcc/patches/gcc-11.3.0_gnat.patch | 41 +++++++ util/crossgcc/patches/gcc-11.3.0_libcpp.patch | 56 ++++++++++ util/crossgcc/patches/gcc-11.3.0_libgcc.patch | 60 +++++++++++ util/crossgcc/sum/gcc-11.2.0.tar.xz.cksum | 1 - util/crossgcc/sum/gcc-11.3.0.tar.xz.cksum | 1 + 13 files changed, 367 insertions(+), 367 deletions(-) delete mode 100644 util/crossgcc/patches/gcc-11.2.0_ada-musl_workaround.patch delete mode 100644 util/crossgcc/patches/gcc-11.2.0_asan_shadow_offset_callback.patch delete mode 100644 util/crossgcc/patches/gcc-11.2.0_gnat.patch delete mode 100644 util/crossgcc/patches/gcc-11.2.0_libcpp.patch delete mode 100644 util/crossgcc/patches/gcc-11.2.0_libgcc.patch create mode 100644 util/crossgcc/patches/gcc-11.3.0_ada-musl_workaround.patch create mode 100644 util/crossgcc/patches/gcc-11.3.0_asan_shadow_offset_callback.patch create mode 100644 util/crossgcc/patches/gcc-11.3.0_gnat.patch create mode 100644 util/crossgcc/patches/gcc-11.3.0_libcpp.patch create mode 100644 util/crossgcc/patches/gcc-11.3.0_libgcc.patch delete mode 100644 util/crossgcc/sum/gcc-11.2.0.tar.xz.cksum create mode 100644 util/crossgcc/sum/gcc-11.3.0.tar.xz.cksum (limited to 'util/crossgcc') diff --git a/util/crossgcc/buildgcc b/util/crossgcc/buildgcc index 0de27ed6e8..edf3c116ab 100755 --- a/util/crossgcc/buildgcc +++ b/util/crossgcc/buildgcc @@ -37,7 +37,7 @@ COREBOOT_MIRROR_URL="https://www.coreboot.org/releases/crossgcc-sources" GMP_VERSION=6.2.1 MPFR_VERSION=4.2.0 MPC_VERSION=1.3.1 -GCC_VERSION=11.2.0 +GCC_VERSION=11.3.0 BINUTILS_VERSION=2.37 IASL_VERSION="R10_20_22" # CLANG version number diff --git a/util/crossgcc/patches/gcc-11.2.0_ada-musl_workaround.patch b/util/crossgcc/patches/gcc-11.2.0_ada-musl_workaround.patch deleted file mode 100644 index 1f504a4b5e..0000000000 --- a/util/crossgcc/patches/gcc-11.2.0_ada-musl_workaround.patch +++ /dev/null @@ -1,120 +0,0 @@ -diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c -index 3b0aea92c05..998f2c66289 100644 ---- a/gcc/ada/adaint.c -+++ b/gcc/ada/adaint.c -@@ -107,6 +107,15 @@ - #define xmalloc(S) malloc (S) - #define xrealloc(V,S) realloc (V,S) - #else -+#if !defined(__ANDROID__) && defined(__linux__) -+#ifdef __cplusplus -+extern "C" { -+#endif -+#include -+#ifdef __cplusplus -+} -+#endif -+#endif - #include "config.h" - #include "system.h" - #include "version.h" -@@ -3265,7 +3274,7 @@ __gnat_lwp_self (void) - - /* Dynamic cpu sets */ - --cpu_set_t * -+void * - __gnat_cpu_alloc (size_t count) - { - return CPU_ALLOC (count); -@@ -3278,33 +3287,33 @@ __gnat_cpu_alloc_size (size_t count) - } - - void --__gnat_cpu_free (cpu_set_t *set) -+__gnat_cpu_free (void *set) - { -- CPU_FREE (set); -+ CPU_FREE ((cpu_set_t *)set); - } - - void --__gnat_cpu_zero (size_t count, cpu_set_t *set) -+__gnat_cpu_zero (size_t count, void *set) - { - CPU_ZERO_S (count, set); - } - - void --__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) -+__gnat_cpu_set (int cpu, size_t count, void *set) - { - /* Ada handles CPU numbers starting from 1, while C identifies the first - CPU by a 0, so we need to adjust. */ -- CPU_SET_S (cpu - 1, count, set); -+ CPU_SET_S (cpu - 1, count, (cpu_set_t *)set); - } - - #else /* !CPU_ALLOC */ - - /* Static cpu sets */ - --cpu_set_t * -+void * - __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) - { -- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); -+ return xmalloc (sizeof (cpu_set_t)); - } - - size_t -@@ -3314,23 +3323,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) - } - - void --__gnat_cpu_free (cpu_set_t *set) -+__gnat_cpu_free (void *set) - { - free (set); - } - - void --__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) -+__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) - { - CPU_ZERO (set); - } - - void --__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) -+__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) - { - /* Ada handles CPU numbers starting from 1, while C identifies the first - CPU by a 0, so we need to adjust. */ -- CPU_SET (cpu - 1, set); -+ CPU_SET (cpu - 1, (cpu_set_t *)set); - } - #endif /* !CPU_ALLOC */ - #endif /* __linux__ */ -diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h -index 0d12f7e9020..7b3def03fb0 100644 ---- a/gcc/ada/adaint.h -+++ b/gcc/ada/adaint.h -@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); - - /* Routines for interface to required CPU set primitives */ - --#include -- --extern cpu_set_t *__gnat_cpu_alloc (size_t); -+extern void *__gnat_cpu_alloc (size_t); - extern size_t __gnat_cpu_alloc_size (size_t); --extern void __gnat_cpu_free (cpu_set_t *); --extern void __gnat_cpu_zero (size_t, cpu_set_t *); --extern void __gnat_cpu_set (int, size_t, cpu_set_t *); -+extern void __gnat_cpu_free (void *); -+extern void __gnat_cpu_zero (size_t, void *); -+extern void __gnat_cpu_set (int, size_t, void *); - #endif - - #if defined (_WIN32) diff --git a/util/crossgcc/patches/gcc-11.2.0_asan_shadow_offset_callback.patch b/util/crossgcc/patches/gcc-11.2.0_asan_shadow_offset_callback.patch deleted file mode 100644 index 25963b3211..0000000000 --- a/util/crossgcc/patches/gcc-11.2.0_asan_shadow_offset_callback.patch +++ /dev/null @@ -1,88 +0,0 @@ -From 41a82fb711f3637b4b7f57756492b628058f9d5f Mon Sep 17 00:00:00 2001 -From: Harshit Sharma -Date: Fri, 10 Jul 2020 13:06:08 -0700 -Subject: [PATCH] crossgcc: Enable GCC to get asan shadow offset at runtime - -Unlike Linux kernel which has a static shadow region layout, we have multiple stages in -coreboot and thus require a different shadow offset address. Unfortunately, GCC currently -only supports adding a static shadow offset at compile time using -fasan-shadow-offset flag. - -For this reason, we enable GCC to determine asan shadow offset address at runtime using a -callback function named __asan_shadow_offset(). This supersedes the need to specify this -address at compile time. GCC then makes use of this shadow offset to protect stack buffers -by inserting red zones around them. - -Some other benefits of having this GCC patch are: -a. We can place the shadow region in a separate linker section with all its advantages like - automatic fit insurance. This ensures if a platform doesn't have enough memory space to - hold shadow region, the build will fail. (However, if we use a fixed shadow offset on a - platform that actually doesn't have enough memory, it may still build without any errors.) -b. We don't modify the memory layout compared to the current one, as we are placing the - shadow region at the end of the space already occupied by the program. -c. We can be much more flexible later if needed (thinking of other stages like bootblock). -d. Since we are appending the shadow buffer to the region already occupied, we make efficient - use of the limited memory available which is highly beneficial when using cache as ram. - -Further, we have made sure that if you compile you tree with ASan enabled but missed this -patch, it will end up in the following compilation error: -"invalid --param name 'asan-use-shadow-offset-callback'" -So, you cannot accidentally enable the feature without having your compiler patched. - -[pgeorgi: Updated for gcc 11.1] - -Signed-off-by: Harshit Sharma -Signed-off-by: Patrick Georgi - -diff --git a/gcc/asan.c b/gcc/asan.c -index 235e21947..713bf994d 100644 ---- a/gcc/asan.c -+++ b/gcc/asan.c -@@ -1389,13 +1389,28 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, - TREE_ASM_WRITTEN (decl) = 1; - TREE_ASM_WRITTEN (id) = 1; - emit_move_insn (mem, expand_normal (build_fold_addr_expr (decl))); -- shadow_base = expand_binop (Pmode, lshr_optab, base, -- gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), -- NULL_RTX, 1, OPTAB_DIRECT); -- shadow_base -- = plus_constant (Pmode, shadow_base, -- asan_shadow_offset () -- + (base_align_bias >> ASAN_SHADOW_SHIFT)); -+ if (param_asan_use_shadow_offset_callback) { -+ rtx addr, shadow_offset_rtx; -+ ret = init_one_libfunc ("__asan_shadow_offset"); -+ addr = convert_memory_address (ptr_mode, base); -+ ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode, -+ addr, ptr_mode); -+ shadow_offset_rtx = convert_memory_address (Pmode, ret); -+ shadow_base = expand_binop (Pmode, lshr_optab, base, -+ gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), -+ NULL_RTX, 1, OPTAB_DIRECT); -+ shadow_base = expand_binop (Pmode, add_optab, shadow_base, -+ shadow_offset_rtx, NULL_RTX, 1, OPTAB_LIB_WIDEN); -+ shadow_base = plus_constant (Pmode, shadow_base, -+ (base_align_bias >> ASAN_SHADOW_SHIFT)); -+ } else { -+ shadow_base = expand_binop (Pmode, lshr_optab, base, -+ gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), -+ NULL_RTX, 1, OPTAB_DIRECT); -+ shadow_base = plus_constant (Pmode, shadow_base, -+ asan_shadow_offset () -+ + (base_align_bias >> ASAN_SHADOW_SHIFT)); -+ } - gcc_assert (asan_shadow_set != -1 - && (ASAN_RED_ZONE_SIZE >> ASAN_SHADOW_SHIFT) == 4); - shadow_mem = gen_rtx_MEM (SImode, shadow_base); ---- gcc-11.1.0/gcc/params.opt~ 2021-05-11 09:02:51.897508677 +0200 -+++ gcc-11.1.0/gcc/params.opt 2021-05-11 09:10:43.692610696 +0200 -@@ -50,6 +50,10 @@ - Common Joined UInteger Var(param_asan_instrumentation_with_call_threshold) Init(7000) Param Optimization - Use callbacks instead of inline code if number of accesses in function becomes greater or equal to this number. - -+-param=asan-use-shadow-offset-callback= -+Common Joined UInteger Var(param_asan_use_shadow_offset_callback) Init(0) IntegerRange(0, 1) Param Optimization -+Use shadow offset callback function at runtime instead of fixed value at compile time at the cost of runtime overhead. -+ - -param=asan-memintrin= - Common Joined UInteger Var(param_asan_memintrin) Init(1) IntegerRange(0, 1) Param Optimization - Enable asan builtin functions protection. diff --git a/util/crossgcc/patches/gcc-11.2.0_gnat.patch b/util/crossgcc/patches/gcc-11.2.0_gnat.patch deleted file mode 100644 index c22cec45d0..0000000000 --- a/util/crossgcc/patches/gcc-11.2.0_gnat.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- gcc-6.1.0/gcc/ada/gcc-interface/Make-lang.in.bak 2015-08-24 16:23:25.004493665 +0200 -+++ gcc-6.1.0/gcc/ada/gcc-interface/Make-lang.in 2015-08-24 17:53:52.496636113 +0200 -@@ -45,7 +45,7 @@ - - - # Extra flags to pass to recursive makes. --COMMON_ADAFLAGS= -gnatpg -+COMMON_ADAFLAGS= -gnatpg -gnatwn - ifeq ($(TREECHECKING),) - CHECKING_ADAFLAGS= - else -diff -Nurp gcc-11.2.0/gcc/ada/gcc-interface/Make-lang.in gcc-11.2.0.new/gcc/ada/gcc-interface/Make-lang.in ---- gcc-11.2.0/gcc/ada/gcc-interface/Make-lang.in 2022-06-03 00:31:57.993273717 +0200 -+++ gcc-11.2.0.new/gcc/ada/gcc-interface/Make-lang.in 2022-06-03 00:30:50.214166847 +0200 -@@ -334,6 +334,7 @@ GNAT_ADA_OBJS = \ - ada/hostparm.o \ - ada/impunit.o \ - ada/inline.o \ -+ ada/libgnat/i-c.o \ - ada/libgnat/interfac.o \ - ada/itypes.o \ - ada/krunch.o \ -@@ -364,7 +365,10 @@ GNAT_ADA_OBJS = \ - ada/rtsfind.o \ - ada/libgnat/s-addope.o \ - ada/libgnat/s-addima.o \ -+ ada/libgnat/s-aotase.o \ - ada/libgnat/s-assert.o \ -+ ada/libgnat/s-atoope.o \ -+ ada/libgnat/s-atopri.o \ - ada/libgnat/s-bitops.o \ - ada/libgnat/s-carun8.o \ - ada/libgnat/s-casuti.o \ -@@ -548,6 +552,7 @@ GNATBIND_OBJS = \ - ada/hostparm.o \ - ada/init.o \ - ada/initialize.o \ -+ ada/libgnat/i-c.o \ - ada/libgnat/interfac.o \ - ada/krunch.o \ - ada/lib.o \ diff --git a/util/crossgcc/patches/gcc-11.2.0_libcpp.patch b/util/crossgcc/patches/gcc-11.2.0_libcpp.patch deleted file mode 100644 index df28c01c71..0000000000 --- a/util/crossgcc/patches/gcc-11.2.0_libcpp.patch +++ /dev/null @@ -1,56 +0,0 @@ -GCC with `-Wformat-security -Werror=format-security` hardening options enabled -by default rejects some codes in libcpp. This patch fixes them. - ---- gcc-8.3.0/libcpp/expr.c.bak 2020-09-11 15:44:45.770000000 +0900 -+++ gcc-8.3.0/libcpp/expr.c 2020-09-11 15:46:22.370000000 +0900 -@@ -794,10 +794,10 @@ - - if (CPP_OPTION (pfile, c99)) - cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location, -- 0, message); -+ 0, "%s", message); - else - cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG, -- virtual_location, 0, message); -+ virtual_location, 0, "%s", message); - } - - result |= CPP_N_INTEGER; ---- gcc-8.3.0/libcpp/macro.c.bak 2020-09-11 16:01:42.550000000 +0900 -+++ gcc-8.3.0/libcpp/macro.c 2020-09-11 16:03:47.850000000 +0900 -@@ -160,7 +160,7 @@ - if (m_state == 2 && token->type == CPP_PASTE) - { - cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, -- vaopt_paste_error); -+ "%s", vaopt_paste_error); - return ERROR; - } - /* Advance states before further considering this token, in -@@ -189,7 +189,7 @@ - if (was_paste) - { - cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, -- vaopt_paste_error); -+ "%s", vaopt_paste_error); - return ERROR; - } - -@@ -3361,7 +3361,7 @@ - function-like macros, but not at the end. */ - if (following_paste_op) - { -- cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); -+ cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); - goto out; - } - if (!vaopt_tracker.completed ()) -@@ -3374,7 +3374,7 @@ - function-like macros, but not at the beginning. */ - if (macro->count == 1) - { -- cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); -+ cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); - goto out; - } - diff --git a/util/crossgcc/patches/gcc-11.2.0_libgcc.patch b/util/crossgcc/patches/gcc-11.2.0_libgcc.patch deleted file mode 100644 index 2f75c92b41..0000000000 --- a/util/crossgcc/patches/gcc-11.2.0_libgcc.patch +++ /dev/null @@ -1,60 +0,0 @@ -This enables building on Mac OS and FreeBSD by adding support to their -variants of the sed utility. - -diff -urN gcc-5.2.0.orig/libgcc/config/t-hardfp gcc-5.2.0/libgcc/config/t-hardfp ---- gcc-5.2.0.orig/libgcc/config/t-hardfp 2015-01-05 04:33:28.000000000 -0800 -+++ gcc-8.1.0/libgcc/config/t-hardfp 2016-04-06 12:04:51.000000000 -0700 -@@ -59,21 +59,52 @@ - - hardfp_func_list := $(filter-out $(hardfp_exclusions),$(hardfp_func_list)) - -+HOST_OS ?= $(shell uname) -+ - # Regexp for matching a floating-point mode. -+ifeq ($(HOST_OS), Darwin) -+hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /|/g') -+else -+ifeq ($(HOST_OS), FreeBSD) -+hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /|/g') -+else - hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g') -+endif -+endif - - # Regexp for matching the end of a function name, after the last - # floating-point mode. -+ifeq ($(HOST_OS), Darwin) -+hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /|/g') -+else -+ifeq ($(HOST_OS), FreeBSD) -+hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /|/g') -+else - hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g') -+endif -+endif - - # Add -D options to define: - # FUNC: the function name (e.g. __addsf3) - # OP: the function name without the leading __ and with the last - # floating-point mode removed (e.g. add3) - # TYPE: the last floating-point mode (e.g. sf) -+ -+ifeq ($(HOST_OS), Darwin) - hardfp_defines_for = \ - $(shell echo $1 | \ -- sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') -+ sed -E 's/(.*)($(hardfp_mode_regexp))($(hardfp_suffix_regexp)|.*)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') -+else -+ifeq ($(HOST_OS), FreeBSD) -+hardfp_defines_for = \ -+ $(shell echo $1 | \ -+ sed -r 's/(.*)($(hardfp_mode_regexp))($(hardfp_suffix_regexp)|.*)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') -+else -+hardfp_defines_for = \ -+ $(shell echo $1 | \ -+ sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') -+endif -+endif - - hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list)) - $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c diff --git a/util/crossgcc/patches/gcc-11.3.0_ada-musl_workaround.patch b/util/crossgcc/patches/gcc-11.3.0_ada-musl_workaround.patch new file mode 100644 index 0000000000..1f504a4b5e --- /dev/null +++ b/util/crossgcc/patches/gcc-11.3.0_ada-musl_workaround.patch @@ -0,0 +1,120 @@ +diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c +index 3b0aea92c05..998f2c66289 100644 +--- a/gcc/ada/adaint.c ++++ b/gcc/ada/adaint.c +@@ -107,6 +107,15 @@ + #define xmalloc(S) malloc (S) + #define xrealloc(V,S) realloc (V,S) + #else ++#if !defined(__ANDROID__) && defined(__linux__) ++#ifdef __cplusplus ++extern "C" { ++#endif ++#include ++#ifdef __cplusplus ++} ++#endif ++#endif + #include "config.h" + #include "system.h" + #include "version.h" +@@ -3265,7 +3274,7 @@ __gnat_lwp_self (void) + + /* Dynamic cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count) + { + return CPU_ALLOC (count); +@@ -3278,33 +3287,33 @@ __gnat_cpu_alloc_size (size_t count) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { +- CPU_FREE (set); ++ CPU_FREE ((cpu_set_t *)set); + } + + void +-__gnat_cpu_zero (size_t count, cpu_set_t *set) ++__gnat_cpu_zero (size_t count, void *set) + { + CPU_ZERO_S (count, set); + } + + void +-__gnat_cpu_set (int cpu, size_t count, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET_S (cpu - 1, count, set); ++ CPU_SET_S (cpu - 1, count, (cpu_set_t *)set); + } + + #else /* !CPU_ALLOC */ + + /* Static cpu sets */ + +-cpu_set_t * ++void * + __gnat_cpu_alloc (size_t count ATTRIBUTE_UNUSED) + { +- return (cpu_set_t *) xmalloc (sizeof (cpu_set_t)); ++ return xmalloc (sizeof (cpu_set_t)); + } + + size_t +@@ -3314,23 +3323,23 @@ __gnat_cpu_alloc_size (size_t count ATTRIBUTE_UNUSED) + } + + void +-__gnat_cpu_free (cpu_set_t *set) ++__gnat_cpu_free (void *set) + { + free (set); + } + + void +-__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_zero (size_t count ATTRIBUTE_UNUSED, void *set) + { + CPU_ZERO (set); + } + + void +-__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, cpu_set_t *set) ++__gnat_cpu_set (int cpu, size_t count ATTRIBUTE_UNUSED, void *set) + { + /* Ada handles CPU numbers starting from 1, while C identifies the first + CPU by a 0, so we need to adjust. */ +- CPU_SET (cpu - 1, set); ++ CPU_SET (cpu - 1, (cpu_set_t *)set); + } + #endif /* !CPU_ALLOC */ + #endif /* __linux__ */ +diff --git a/gcc/ada/adaint.h b/gcc/ada/adaint.h +index 0d12f7e9020..7b3def03fb0 100644 +--- a/gcc/ada/adaint.h ++++ b/gcc/ada/adaint.h +@@ -316,13 +316,11 @@ extern void *__gnat_lwp_self (void); + + /* Routines for interface to required CPU set primitives */ + +-#include +- +-extern cpu_set_t *__gnat_cpu_alloc (size_t); ++extern void *__gnat_cpu_alloc (size_t); + extern size_t __gnat_cpu_alloc_size (size_t); +-extern void __gnat_cpu_free (cpu_set_t *); +-extern void __gnat_cpu_zero (size_t, cpu_set_t *); +-extern void __gnat_cpu_set (int, size_t, cpu_set_t *); ++extern void __gnat_cpu_free (void *); ++extern void __gnat_cpu_zero (size_t, void *); ++extern void __gnat_cpu_set (int, size_t, void *); + #endif + + #if defined (_WIN32) diff --git a/util/crossgcc/patches/gcc-11.3.0_asan_shadow_offset_callback.patch b/util/crossgcc/patches/gcc-11.3.0_asan_shadow_offset_callback.patch new file mode 100644 index 0000000000..25963b3211 --- /dev/null +++ b/util/crossgcc/patches/gcc-11.3.0_asan_shadow_offset_callback.patch @@ -0,0 +1,88 @@ +From 41a82fb711f3637b4b7f57756492b628058f9d5f Mon Sep 17 00:00:00 2001 +From: Harshit Sharma +Date: Fri, 10 Jul 2020 13:06:08 -0700 +Subject: [PATCH] crossgcc: Enable GCC to get asan shadow offset at runtime + +Unlike Linux kernel which has a static shadow region layout, we have multiple stages in +coreboot and thus require a different shadow offset address. Unfortunately, GCC currently +only supports adding a static shadow offset at compile time using -fasan-shadow-offset flag. + +For this reason, we enable GCC to determine asan shadow offset address at runtime using a +callback function named __asan_shadow_offset(). This supersedes the need to specify this +address at compile time. GCC then makes use of this shadow offset to protect stack buffers +by inserting red zones around them. + +Some other benefits of having this GCC patch are: +a. We can place the shadow region in a separate linker section with all its advantages like + automatic fit insurance. This ensures if a platform doesn't have enough memory space to + hold shadow region, the build will fail. (However, if we use a fixed shadow offset on a + platform that actually doesn't have enough memory, it may still build without any errors.) +b. We don't modify the memory layout compared to the current one, as we are placing the + shadow region at the end of the space already occupied by the program. +c. We can be much more flexible later if needed (thinking of other stages like bootblock). +d. Since we are appending the shadow buffer to the region already occupied, we make efficient + use of the limited memory available which is highly beneficial when using cache as ram. + +Further, we have made sure that if you compile you tree with ASan enabled but missed this +patch, it will end up in the following compilation error: +"invalid --param name 'asan-use-shadow-offset-callback'" +So, you cannot accidentally enable the feature without having your compiler patched. + +[pgeorgi: Updated for gcc 11.1] + +Signed-off-by: Harshit Sharma +Signed-off-by: Patrick Georgi + +diff --git a/gcc/asan.c b/gcc/asan.c +index 235e21947..713bf994d 100644 +--- a/gcc/asan.c ++++ b/gcc/asan.c +@@ -1389,13 +1389,28 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb, + TREE_ASM_WRITTEN (decl) = 1; + TREE_ASM_WRITTEN (id) = 1; + emit_move_insn (mem, expand_normal (build_fold_addr_expr (decl))); +- shadow_base = expand_binop (Pmode, lshr_optab, base, +- gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), +- NULL_RTX, 1, OPTAB_DIRECT); +- shadow_base +- = plus_constant (Pmode, shadow_base, +- asan_shadow_offset () +- + (base_align_bias >> ASAN_SHADOW_SHIFT)); ++ if (param_asan_use_shadow_offset_callback) { ++ rtx addr, shadow_offset_rtx; ++ ret = init_one_libfunc ("__asan_shadow_offset"); ++ addr = convert_memory_address (ptr_mode, base); ++ ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode, ++ addr, ptr_mode); ++ shadow_offset_rtx = convert_memory_address (Pmode, ret); ++ shadow_base = expand_binop (Pmode, lshr_optab, base, ++ gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), ++ NULL_RTX, 1, OPTAB_DIRECT); ++ shadow_base = expand_binop (Pmode, add_optab, shadow_base, ++ shadow_offset_rtx, NULL_RTX, 1, OPTAB_LIB_WIDEN); ++ shadow_base = plus_constant (Pmode, shadow_base, ++ (base_align_bias >> ASAN_SHADOW_SHIFT)); ++ } else { ++ shadow_base = expand_binop (Pmode, lshr_optab, base, ++ gen_int_shift_amount (Pmode, ASAN_SHADOW_SHIFT), ++ NULL_RTX, 1, OPTAB_DIRECT); ++ shadow_base = plus_constant (Pmode, shadow_base, ++ asan_shadow_offset () ++ + (base_align_bias >> ASAN_SHADOW_SHIFT)); ++ } + gcc_assert (asan_shadow_set != -1 + && (ASAN_RED_ZONE_SIZE >> ASAN_SHADOW_SHIFT) == 4); + shadow_mem = gen_rtx_MEM (SImode, shadow_base); +--- gcc-11.1.0/gcc/params.opt~ 2021-05-11 09:02:51.897508677 +0200 ++++ gcc-11.1.0/gcc/params.opt 2021-05-11 09:10:43.692610696 +0200 +@@ -50,6 +50,10 @@ + Common Joined UInteger Var(param_asan_instrumentation_with_call_threshold) Init(7000) Param Optimization + Use callbacks instead of inline code if number of accesses in function becomes greater or equal to this number. + ++-param=asan-use-shadow-offset-callback= ++Common Joined UInteger Var(param_asan_use_shadow_offset_callback) Init(0) IntegerRange(0, 1) Param Optimization ++Use shadow offset callback function at runtime instead of fixed value at compile time at the cost of runtime overhead. ++ + -param=asan-memintrin= + Common Joined UInteger Var(param_asan_memintrin) Init(1) IntegerRange(0, 1) Param Optimization + Enable asan builtin functions protection. diff --git a/util/crossgcc/patches/gcc-11.3.0_gnat.patch b/util/crossgcc/patches/gcc-11.3.0_gnat.patch new file mode 100644 index 0000000000..c22cec45d0 --- /dev/null +++ b/util/crossgcc/patches/gcc-11.3.0_gnat.patch @@ -0,0 +1,41 @@ +--- gcc-6.1.0/gcc/ada/gcc-interface/Make-lang.in.bak 2015-08-24 16:23:25.004493665 +0200 ++++ gcc-6.1.0/gcc/ada/gcc-interface/Make-lang.in 2015-08-24 17:53:52.496636113 +0200 +@@ -45,7 +45,7 @@ + + + # Extra flags to pass to recursive makes. +-COMMON_ADAFLAGS= -gnatpg ++COMMON_ADAFLAGS= -gnatpg -gnatwn + ifeq ($(TREECHECKING),) + CHECKING_ADAFLAGS= + else +diff -Nurp gcc-11.2.0/gcc/ada/gcc-interface/Make-lang.in gcc-11.2.0.new/gcc/ada/gcc-interface/Make-lang.in +--- gcc-11.2.0/gcc/ada/gcc-interface/Make-lang.in 2022-06-03 00:31:57.993273717 +0200 ++++ gcc-11.2.0.new/gcc/ada/gcc-interface/Make-lang.in 2022-06-03 00:30:50.214166847 +0200 +@@ -334,6 +334,7 @@ GNAT_ADA_OBJS = \ + ada/hostparm.o \ + ada/impunit.o \ + ada/inline.o \ ++ ada/libgnat/i-c.o \ + ada/libgnat/interfac.o \ + ada/itypes.o \ + ada/krunch.o \ +@@ -364,7 +365,10 @@ GNAT_ADA_OBJS = \ + ada/rtsfind.o \ + ada/libgnat/s-addope.o \ + ada/libgnat/s-addima.o \ ++ ada/libgnat/s-aotase.o \ + ada/libgnat/s-assert.o \ ++ ada/libgnat/s-atoope.o \ ++ ada/libgnat/s-atopri.o \ + ada/libgnat/s-bitops.o \ + ada/libgnat/s-carun8.o \ + ada/libgnat/s-casuti.o \ +@@ -548,6 +552,7 @@ GNATBIND_OBJS = \ + ada/hostparm.o \ + ada/init.o \ + ada/initialize.o \ ++ ada/libgnat/i-c.o \ + ada/libgnat/interfac.o \ + ada/krunch.o \ + ada/lib.o \ diff --git a/util/crossgcc/patches/gcc-11.3.0_libcpp.patch b/util/crossgcc/patches/gcc-11.3.0_libcpp.patch new file mode 100644 index 0000000000..df28c01c71 --- /dev/null +++ b/util/crossgcc/patches/gcc-11.3.0_libcpp.patch @@ -0,0 +1,56 @@ +GCC with `-Wformat-security -Werror=format-security` hardening options enabled +by default rejects some codes in libcpp. This patch fixes them. + +--- gcc-8.3.0/libcpp/expr.c.bak 2020-09-11 15:44:45.770000000 +0900 ++++ gcc-8.3.0/libcpp/expr.c 2020-09-11 15:46:22.370000000 +0900 +@@ -794,10 +794,10 @@ + + if (CPP_OPTION (pfile, c99)) + cpp_warning_with_line (pfile, CPP_W_LONG_LONG, virtual_location, +- 0, message); ++ 0, "%s", message); + else + cpp_pedwarning_with_line (pfile, CPP_W_LONG_LONG, +- virtual_location, 0, message); ++ virtual_location, 0, "%s", message); + } + + result |= CPP_N_INTEGER; +--- gcc-8.3.0/libcpp/macro.c.bak 2020-09-11 16:01:42.550000000 +0900 ++++ gcc-8.3.0/libcpp/macro.c 2020-09-11 16:03:47.850000000 +0900 +@@ -160,7 +160,7 @@ + if (m_state == 2 && token->type == CPP_PASTE) + { + cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, +- vaopt_paste_error); ++ "%s", vaopt_paste_error); + return ERROR; + } + /* Advance states before further considering this token, in +@@ -189,7 +189,7 @@ + if (was_paste) + { + cpp_error_at (m_pfile, CPP_DL_ERROR, token->src_loc, +- vaopt_paste_error); ++ "%s", vaopt_paste_error); + return ERROR; + } + +@@ -3361,7 +3361,7 @@ + function-like macros, but not at the end. */ + if (following_paste_op) + { +- cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); ++ cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); + goto out; + } + if (!vaopt_tracker.completed ()) +@@ -3374,7 +3374,7 @@ + function-like macros, but not at the beginning. */ + if (macro->count == 1) + { +- cpp_error (pfile, CPP_DL_ERROR, paste_op_error_msg); ++ cpp_error (pfile, CPP_DL_ERROR, "%s", paste_op_error_msg); + goto out; + } + diff --git a/util/crossgcc/patches/gcc-11.3.0_libgcc.patch b/util/crossgcc/patches/gcc-11.3.0_libgcc.patch new file mode 100644 index 0000000000..2f75c92b41 --- /dev/null +++ b/util/crossgcc/patches/gcc-11.3.0_libgcc.patch @@ -0,0 +1,60 @@ +This enables building on Mac OS and FreeBSD by adding support to their +variants of the sed utility. + +diff -urN gcc-5.2.0.orig/libgcc/config/t-hardfp gcc-5.2.0/libgcc/config/t-hardfp +--- gcc-5.2.0.orig/libgcc/config/t-hardfp 2015-01-05 04:33:28.000000000 -0800 ++++ gcc-8.1.0/libgcc/config/t-hardfp 2016-04-06 12:04:51.000000000 -0700 +@@ -59,21 +59,52 @@ + + hardfp_func_list := $(filter-out $(hardfp_exclusions),$(hardfp_func_list)) + ++HOST_OS ?= $(shell uname) ++ + # Regexp for matching a floating-point mode. ++ifeq ($(HOST_OS), Darwin) ++hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /|/g') ++else ++ifeq ($(HOST_OS), FreeBSD) ++hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /|/g') ++else + hardfp_mode_regexp := $(shell echo $(hardfp_float_modes) | sed 's/ /\\|/g') ++endif ++endif + + # Regexp for matching the end of a function name, after the last + # floating-point mode. ++ifeq ($(HOST_OS), Darwin) ++hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /|/g') ++else ++ifeq ($(HOST_OS), FreeBSD) ++hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /|/g') ++else + hardfp_suffix_regexp := $(shell echo $(hardfp_int_modes) 2 3 | sed 's/ /\\|/g') ++endif ++endif + + # Add -D options to define: + # FUNC: the function name (e.g. __addsf3) + # OP: the function name without the leading __ and with the last + # floating-point mode removed (e.g. add3) + # TYPE: the last floating-point mode (e.g. sf) ++ ++ifeq ($(HOST_OS), Darwin) + hardfp_defines_for = \ + $(shell echo $1 | \ +- sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') ++ sed -E 's/(.*)($(hardfp_mode_regexp))($(hardfp_suffix_regexp)|.*)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') ++else ++ifeq ($(HOST_OS), FreeBSD) ++hardfp_defines_for = \ ++ $(shell echo $1 | \ ++ sed -r 's/(.*)($(hardfp_mode_regexp))($(hardfp_suffix_regexp)|.*)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') ++else ++hardfp_defines_for = \ ++ $(shell echo $1 | \ ++ sed 's/\(.*\)\($(hardfp_mode_regexp)\)\($(hardfp_suffix_regexp)\|\)$$/-DFUNC=__& -DOP_\1\3 -DTYPE=\2/') ++endif ++endif + + hardfp-o = $(patsubst %,%$(objext),$(hardfp_func_list)) + $(hardfp-o): %$(objext): $(srcdir)/config/hardfp.c diff --git a/util/crossgcc/sum/gcc-11.2.0.tar.xz.cksum b/util/crossgcc/sum/gcc-11.2.0.tar.xz.cksum deleted file mode 100644 index 071c352c93..0000000000 --- a/util/crossgcc/sum/gcc-11.2.0.tar.xz.cksum +++ /dev/null @@ -1 +0,0 @@ -f902ccacecf8949978d6261e9f1d034cff73ffdb tarballs/gcc-11.2.0.tar.xz diff --git a/util/crossgcc/sum/gcc-11.3.0.tar.xz.cksum b/util/crossgcc/sum/gcc-11.3.0.tar.xz.cksum new file mode 100644 index 0000000000..a4d2bd5780 --- /dev/null +++ b/util/crossgcc/sum/gcc-11.3.0.tar.xz.cksum @@ -0,0 +1 @@ +cf86a48278f9a6f4b03d4390550577b20353b4e9 tarballs/gcc-11.3.0.tar.xz -- cgit v1.2.3