]> git.ipfire.org Git - people/stevee/ipfire-3.x.git/blame - gcc/patches/0001-gcc-Build-with-PIE.patch
gcc: Harden this package
[people/stevee/ipfire-3.x.git] / gcc / patches / 0001-gcc-Build-with-PIE.patch
CommitLineData
48c0a841
MT
1From 8690dbe058f3ca8af0499a545c4b4cc6a5dc089a Mon Sep 17 00:00:00 2001
2From: Michael Tremer <michael.tremer@ipfire.org>
3Date: Tue, 21 Mar 2023 16:58:02 +0000
4Subject: [PATCH 1/2] gcc: Build with PIE
5
6This patch removes that GCC will be compiled with -fno-PIE/-no-pie.
7
8This will break PCH.
9
10Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
11---
12 gcc/Makefile.in | 9 ---------
13 gcc/configure.ac | 28 ----------------------------
14 2 files changed, 37 deletions(-)
15
16diff --git a/gcc/Makefile.in b/gcc/Makefile.in
17index 31ff95500c9..530928a3cde 100644
18--- a/gcc/Makefile.in
19+++ b/gcc/Makefile.in
20@@ -267,15 +267,6 @@ endif
21 CET_HOST_FLAGS = @CET_HOST_FLAGS@
22 COMPILER += $(CET_HOST_FLAGS)
23
24-NO_PIE_CFLAGS = @NO_PIE_CFLAGS@
25-NO_PIE_FLAG = @NO_PIE_FLAG@
26-
27-# We don't want to compile the compilers with -fPIE, it make PCH fail.
28-COMPILER += $(NO_PIE_CFLAGS)
29-
30-# Link with -no-pie since we compile the compiler with -fno-PIE.
31-LINKER += $(NO_PIE_FLAG)
32-
33 # Like LINKER, but use a mutex for serializing front end links.
34 ifeq (@DO_LINK_MUTEX@,true)
35 LLINKER = $(SHELL) $(srcdir)/lock-and-run.sh linkfe.lck $(LINKER)
36diff --git a/gcc/configure.ac b/gcc/configure.ac
37index 992a50e7b20..62cd94bffb8 100644
38--- a/gcc/configure.ac
39+++ b/gcc/configure.ac
40@@ -7641,34 +7641,6 @@ if test x$enable_default_pie = xyes ; then
41 fi
42 AC_SUBST([enable_default_pie])
43
44-# Check if -fno-PIE works.
45-AC_CACHE_CHECK([for -fno-PIE option],
46- [gcc_cv_c_no_fpie],
47- [saved_CXXFLAGS="$CXXFLAGS"
48- CXXFLAGS="$CXXFLAGS -fno-PIE"
49- AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
50- [gcc_cv_c_no_fpie=yes],
51- [gcc_cv_c_no_fpie=no])
52- CXXFLAGS="$saved_CXXFLAGS"])
53-if test "$gcc_cv_c_no_fpie" = "yes"; then
54- NO_PIE_CFLAGS="-fno-PIE"
55-fi
56-AC_SUBST([NO_PIE_CFLAGS])
57-
58-# Check if -no-pie works.
59-AC_CACHE_CHECK([for -no-pie option],
60- [gcc_cv_no_pie],
61- [saved_LDFLAGS="$LDFLAGS"
62- LDFLAGS="$LDFLAGS -no-pie"
63- AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) {return 0;}])],
64- [gcc_cv_no_pie=yes],
65- [gcc_cv_no_pie=no])
66- LDFLAGS="$saved_LDFLAGS"])
67-if test "$gcc_cv_no_pie" = "yes"; then
68- NO_PIE_FLAG="-no-pie"
69-fi
70-AC_SUBST([NO_PIE_FLAG])
71-
72 # Enable Intel CET on Intel CET enabled host if jit is enabled.
73 GCC_CET_HOST_FLAGS(CET_HOST_FLAGS)
74 case x$enable_languages in
75--
762.30.2
77