update gcc defaultpie patch to be switchable at configure time

the sample config.mak.dist is also updated to show usage.
This commit is contained in:
Rich Felker 2015-11-05 23:37:39 +00:00
parent 527fca9755
commit eeaae9e133
2 changed files with 27 additions and 2 deletions

View File

@ -15,3 +15,7 @@ GCC_VER = 5.2.0
# GCC_CONFIG += --with-cpu=mj2 # GCC_CONFIG += --with-cpu=mj2
# GCC_CONFIG += --enable-fdpic # GCC_CONFIG += --enable-fdpic
# Options for using (plain, non-FDPIC) ELF on NOMMU targets
# GCC_CONFIG += --enable-default-pie

View File

@ -1,12 +1,33 @@
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 3779369..a6d95ca 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3101,6 +3101,12 @@ case ${target} in
;;
esac
+case "x${enable_default_pie}" in
+xyes)
+ tm_defines="${tm_defines} ENABLE_DEFAULT_PIE=1"
+ ;;
+esac
+
t=
all_defaults="abi cpu arch tune schedule float mode fpu divide"
for option in $all_defaults
--- gcc-5.2.0.orig/gcc/gcc.c 2015-03-10 09:37:41.000000000 +0000 --- gcc-5.2.0.orig/gcc/gcc.c 2015-03-10 09:37:41.000000000 +0000
+++ gcc-5.2.0/gcc/gcc.c 2015-08-25 07:47:12.895060530 +0000 +++ gcc-5.2.0/gcc/gcc.c 2015-08-25 07:47:12.895060530 +0000
@@ -1012,10 +1012,15 @@ @@ -1012,10 +1012,19 @@
#define CILK_SELF_SPECS "%{fcilkplus: -pthread}" #define CILK_SELF_SPECS "%{fcilkplus: -pthread}"
#endif #endif
+/* Default to PIE */ +/* Default to PIE */
+#ifndef PIE_SELF_SPECS +#ifndef PIE_SELF_SPECS
+#define PIE_SELF_SPECS "%{shared|pie|r|nostdlib|nopie:;:-pie} %{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE|D__KERNEL__:;:-fPIE}" +#ifdef ENABLE_DEFAULT_PIE
+#define PIE_SELF_SPECS "%{shared|pie|r|nostdlib|nopie|no-pie:;:-pie} %{fpic|fPIC|fpie|fPIE|fno-pic|fno-PIC|fno-pie|fno-PIE|D__KERNEL__:;:-fPIE}"
+#else
+#define PIE_SELF_SPECS ""
+#endif
+#endif +#endif
+ +
static const char *const driver_self_specs[] = { static const char *const driver_self_specs[] = {