toolchain: set the ssp gcc option in kconfig
authorYann E. MORIN <yann.morin@orange.com>
Tue, 12 Mar 2019 12:09:33 +0000 (13:09 +0100)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Tue, 12 Mar 2019 23:01:55 +0000 (00:01 +0100)
Currently, we repeat all the SSP level selection deep down to the
toolchain wrapper itself, where we eventually translate it to the
actual SSP option to use. This is a bit redundant.

Additionally, we will want to check that the toolchain actually
supports that option (for those toolchain where it was backported).

So, move the translation into kconfig, and add the qstrip'ed value
to the additional flags passed to the wrapper. Add it before
user-supplied opitons, to keep the previous behaviour (and allow
anyone crazy-enough to override it with BR2_TARGET_OPTIMIZATION).

Signed-off-by: "Yann E. MORIN" <yann.morin@orange.com>
Cc: Matt Weber <matthew.weber@rockwellcollins.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Reviewed-by: Matthew Weber <matthew.weber@rockwellcollins.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Config.in
toolchain/toolchain-wrapper.c
toolchain/toolchain-wrapper.mk

index d58d8dc04a81edce6139517c7de544097ba8d443..757ad1ca405e4c58bff8744a49a4bb5e02ef6a7e 100644 (file)
--- a/Config.in
+++ b/Config.in
@@ -764,6 +764,12 @@ config BR2_SSP_ALL
 
 endchoice
 
+config BR2_SSP_OPTION
+       string
+       default "-fstack-protector"        if BR2_SSP_REGULAR
+       default "-fstack-protector-strong" if BR2_SSP_STRONG
+       default "-fstack-protector-all"    if BR2_SSP_ALL
+
 comment "Stack Smashing Protection needs a toolchain w/ SSP"
        depends on !BR2_TOOLCHAIN_HAS_SSP
 
index e9c5cd9d322795fea6bd9187c1de596c78590cdf..c73a0cc0792973f5280daa446b0aa7de16ffc767 100644 (file)
@@ -98,15 +98,6 @@ static char *predef_args[] = {
 #if defined(BR_MIPS_TARGET_BIG_ENDIAN) || defined(BR_ARC_TARGET_BIG_ENDIAN)
        "-EB",
 #endif
-#ifdef BR_SSP_REGULAR
-       "-fstack-protector",
-#endif
-#ifdef BR_SSP_STRONG
-       "-fstack-protector-strong",
-#endif
-#ifdef BR_SSP_ALL
-       "-fstack-protector-all",
-#endif
 #ifdef BR_ADDITIONAL_CFLAGS
        BR_ADDITIONAL_CFLAGS
 #endif
index c9e6fd3f3d1099ac7a9eb7dcca0a4014f13a8714..ca66fa7ba40ba871a0a2ccda164074aa0b0cdc2c 100644 (file)
@@ -17,6 +17,7 @@ TOOLCHAIN_WRAPPER_ARGS = $($(PKG)_TOOLCHAIN_WRAPPER_ARGS)
 TOOLCHAIN_WRAPPER_ARGS += -DBR_SYSROOT='"$(STAGING_SUBDIR)"'
 
 TOOLCHAIN_WRAPPER_OPTS = \
+       $(call qstrip,$(BR2_SSP_OPTION)) \
        $(call qstrip,$(BR2_TARGET_OPTIMIZATION))
 
 # We create a list like '"-mfoo", "-mbar", "-mbarfoo"' so that each flag is a
@@ -53,14 +54,6 @@ else ifeq ($(BR2_RELRO_FULL),y)
 TOOLCHAIN_WRAPPER_ARGS += -DBR2_RELRO_FULL
 endif
 
-ifeq ($(BR2_SSP_REGULAR),y)
-TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_REGULAR
-else ifeq ($(BR2_SSP_STRONG),y)
-TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_STRONG
-else ifeq ($(BR2_SSP_ALL),y)
-TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_ALL
-endif
-
 define TOOLCHAIN_WRAPPER_BUILD
        $(HOSTCC) $(HOST_CFLAGS) $(TOOLCHAIN_WRAPPER_ARGS) \
                -s -Wl,--hash-style=$(TOOLCHAIN_WRAPPER_HASH_STYLE) \