Message ID | 8928_1552286905_5C8604B9_8928_92_1_1b5ea6bb-0d36-4857-888c-c65dd93bff8b@OPEXCLILM6F.corporate.adroot.infra.ftgroup |
---|---|
State | Changes Requested |
Headers | show |
Series | [1/4] toolchain: set the ssp gcc option in kconfig | expand |
On 11/03/2019 07:48, yann.morin@orange.com wrote: [snip] > diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk > index 613f5f6c56..e48e765a8e 100644 > --- a/toolchain/toolchain-wrapper.mk > +++ b/toolchain/toolchain-wrapper.mk > @@ -51,12 +51,8 @@ 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 > +ifneq ($(BR2_SSP_OPTION),) > +TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_OPTION='$(BR2_SSP_OPTION)' > endif I try to mention this every time someone touches the toolchain wrapper: I'd really like to use the BR_ADDITIONAL_CFLAGS instead, by changing the definition in the .mk file to something like: TOOLCHAIN_WRAPPER_OPTS = \ $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) \ $(call qstrip,$(BR2_SSP_OPTION)) TOOLCHAIN_WRAPPER_ARGS += \ -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))' (note that I preferred the qstrip instead of the ifdef here, and adding quotes explicitly in the foreach, but you may want to implement it differently). Regards, Arnout
Arnout, All, On 2019-03-12 01:02 +0100, Arnout Vandecappelle spake thusly: > On 11/03/2019 07:48, yann.morin@orange.com wrote: > [snip] [--SNIP--] > > +ifneq ($(BR2_SSP_OPTION),) > > +TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_OPTION='$(BR2_SSP_OPTION)' > > endif > I'd really like to use the BR_ADDITIONAL_CFLAGS instead, by changing the > definition in the .mk file to something like: > > TOOLCHAIN_WRAPPER_OPTS = \ > $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) \ > $(call qstrip,$(BR2_SSP_OPTION)) > > TOOLCHAIN_WRAPPER_ARGS += \ > -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))' OK, will do. > (note that I preferred the qstrip instead of the ifdef here, and adding quotes > explicitly in the foreach, but you may want to implement it differently). Yeah, I tried to avoid the qstriop-then-strip-anyway dance, but it is indeed nicer the way you wrote it. Thanks! Regards, Yann E. MORIN.
On 12/03/2019 07:06, yann.morin@orange.com wrote: > Arnout, All, > > On 2019-03-12 01:02 +0100, Arnout Vandecappelle spake thusly: >> On 11/03/2019 07:48, yann.morin@orange.com wrote: >> [snip] > [--SNIP--] >>> +ifneq ($(BR2_SSP_OPTION),) >>> +TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_OPTION='$(BR2_SSP_OPTION)' >>> endif >> I'd really like to use the BR_ADDITIONAL_CFLAGS instead, by changing the >> definition in the .mk file to something like: >> >> TOOLCHAIN_WRAPPER_OPTS = \ >> $(call qstrip,$(BR2_TARGET_OPTIMIZATION)) \ >> $(call qstrip,$(BR2_SSP_OPTION)) >> >> TOOLCHAIN_WRAPPER_ARGS += \ >> -DBR_ADDITIONAL_CFLAGS='$(foreach f,$(TOOLCHAIN_WRAPPER_OPTS),"$(f)"$(comma))' > > OK, will do. Note that we don't have a runtime test for BR2_TRGET_OPTIMIZATION so some manual testing will be needed. >> (note that I preferred the qstrip instead of the ifdef here, and adding quotes >> explicitly in the foreach, but you may want to implement it differently). > > Yeah, I tried to avoid the qstriop-then-strip-anyway dance, but it is > indeed nicer the way you wrote it. I like the qstrip-then-quote dance, because it makes things consistent. Note that this is a very special case because we want to quote each space-separated option here; in general we actually want to make sure the spaces are quoted when we do a qstrip-then-quote dance. Regards, Arnout
diff --git a/Config.in b/Config.in index d58d8dc04a..757ad1ca40 100644 --- 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 diff --git a/toolchain/toolchain-wrapper.c b/toolchain/toolchain-wrapper.c index e9c5cd9d32..d605a7d648 100644 --- a/toolchain/toolchain-wrapper.c +++ b/toolchain/toolchain-wrapper.c @@ -98,14 +98,8 @@ 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", +#ifdef BR_SSP_OPTION + BR_SSP_OPTION, #endif #ifdef BR_ADDITIONAL_CFLAGS BR_ADDITIONAL_CFLAGS diff --git a/toolchain/toolchain-wrapper.mk b/toolchain/toolchain-wrapper.mk index 613f5f6c56..e48e765a8e 100644 --- a/toolchain/toolchain-wrapper.mk +++ b/toolchain/toolchain-wrapper.mk @@ -51,12 +51,8 @@ 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 +ifneq ($(BR2_SSP_OPTION),) +TOOLCHAIN_WRAPPER_ARGS += -DBR_SSP_OPTION='$(BR2_SSP_OPTION)' endif define TOOLCHAIN_WRAPPER_BUILD