Browse Source

update gcc defaultpie patch to be switchable at configure time

the sample config.mak.dist is also updated to show usage.
Rich Felker 9 years ago
parent
commit
eeaae9e133
2 changed files with 27 additions and 2 deletions
  1. 4 0
      config.mak.dist
  2. 23 2
      patches/gcc-5.2.0/0006-defaultpie.diff

+ 4 - 0
config.mak.dist

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

+ 23 - 2
patches/gcc-5.2.0/0006-defaultpie.diff

@@ -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/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}"
  #endif
  
 +/* Default to PIE */
 +#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
 +
  static const char *const driver_self_specs[] = {