Skip to contentSkip to conversation

gcc: Add support for --enable-default-pie configure option.

PATCH Superseded Stefan Fröberg 2 participants 2 messages Dec 27, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc: Add support for --enable-default-pie configure option.

With this option GCC will make PIE binaries by default. To override this default behaviour, use -no-pie

https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Link-Options.html

---
 package/gcc/Config.in.host | 10 ++++++++++
 package/gcc/gcc.mk         |  4 ++++
 2 files changed, 14 insertions(+)
package/gcc/Config.in.host +10 -0
index 70cce0a5c5..bf646fa07b 100644
@@ -152,3 +152,13 @@ config BR2_GCC_ENABLE_GRAPHITE
 
 comment "graphite support needs gcc >= 5.x"
 	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_5
+
+config BR2_GCC_ENABLE_DEFAULT_PIE
+	bool "Enable default PIE support"
+	depends on BR2_TOOLCHAIN_GCC_AT_LEAST_6
+	help
+	  This option enables the GCC to make PIE
+	  binaries by default.
+
+comment "default PIE support needs gcc >= 6.x"
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_6
package/gcc/gcc.mk +4 -0
index 27fc1e987c..0910fb3932 100644
@@ -183,6 +183,10 @@ else
 HOST_GCC_COMMON_CONF_OPTS += --without-isl --without-cloog
 endif
 
+ifeq ($(BR2_GCC_ENABLE_DEFAULT_PIE),y)
+HOST_GCC_COMMON_CONF_OPTS += --enable-default-pie
+endif
+
 ifeq ($(BR2_arc)$(BR2_or1k),y)
 HOST_GCC_COMMON_DEPENDENCIES += host-flex host-bison
 endif
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/1 gcc: Add support for --enable-default-pie configure option.

Hello,

Quoted 6 lines · Stefan Fr?berg

With this option GCC will make PIE binaries by default. To override this default behaviour, use -no-pie

https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Link-Options.html

Here as well, I'd like the commit log (and Config.in help text) to include some explanations as to *why* one would want to do this.

Also, wouldn't we instead want a more global option that would also work with external toolchains, where the compiler wrapper passes the right gcc arguments ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com