Skip to contentSkip to conversation

security_flags: Remove stack protector flags from LDFLAGS

PATCH RESEND In review Junling Zheng 2 participants 4 messages Mar 2, 2020 – Mar 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/2 security_flags: Remove stack protector flags from LDFLAGS

The stack protector flag is a compile option, not a link option, so remove it from LDFLAGS.

---
 meta/conf/distro/include/security_flags.inc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/conf/distro/include/security_flags.inc +2 -2
index aaf04e9e59..5b79340be9 100644
@@ -26,8 +26,8 @@ SECURITY_STACK_PROTECTOR ?= "-fstack-protector-strong"
 SECURITY_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
 SECURITY_NO_PIE_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
 
-SECURITY_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro,-z,now"
-SECURITY_X_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro"
+SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now"
+SECURITY_X_LDFLAGS ?= "-Wl,-z,relro"
 
 # powerpc does not get on with pie for reasons not looked into as yet
 GCCPIE_powerpc = ""
Signature · 1 line
2.17.1
#1 lore raw

PATCH RESEND 2/2 arch-arm64.inc: Do not append aarch64 in MACHINEOVERRIDES

Currently, for arch-arm64, poky will append the MACHINEOVERRIDES with "aarch64:", which has the higher priority than TRANSLATED_TARGET_ARCH. So, for aarch64 big endian, the variable '<foo>_aarch64' will override not only '<foo>', but also '<foo>_aarch64-be', thus we will get an incorrect variable.

---
 meta/conf/machine/include/arm/arch-arm64.inc | 2 --
 1 file changed, 2 deletions(-)
meta/conf/machine/include/arm/arch-arm64.inc +0 -2
index 53f4566815..32294bd218 100644
@@ -4,8 +4,6 @@ require conf/machine/include/arm/arch-armv7ve.inc
 
 TUNEVALID[aarch64] = "Enable instructions for aarch64"
 
-MACHINEOVERRIDES =. "${@bb.utils.contains('TUNE_FEATURES', 'aarch64', 'aarch64:', '' ,d)}"
-
 # Little Endian base configs
 AVAILTUNES += "aarch64 aarch64_be"
 ARMPKGARCH_tune-aarch64 ?= "aarch64"
Signature · 1 line
2.17.1
#2 lore raw
In reply to Junling Zheng
Quoted 2 lines · Junling Zheng

The stack protector flag is a compile option, not a link option, so remove it from LDFLAGS.

we use compiler driver to do linking as well, what does this change fix for you.

Quoted 22 lines
---
  meta/conf/distro/include/security_flags.inc | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
meta/conf/distro/include/security_flags.inc +2 -2
index aaf04e9e59..5b79340be9 100644
@@ -26,8 +26,8 @@ SECURITY_STACK_PROTECTOR ?= "-fstack-protector-strong"
  SECURITY_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
  SECURITY_NO_PIE_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
 
-SECURITY_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro,-z,now"
-SECURITY_X_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro"
+SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now"
+SECURITY_X_LDFLAGS ?= "-Wl,-z,relro"
 
  # powerpc does not get on with pie for reasons not looked into as yet
  GCCPIE_powerpc = ""
#3 lore raw
Quoted 8 lines · Khem Raj
Quoted 2 lines · Junling Zheng

The stack protector flag is a compile option, not a link option, so remove it from LDFLAGS.

we use compiler driver to do linking as well, what does this change fix for you.

I know that we use gcc to do linking, and this is just a code cleaning, not a bugfix :)

Quoted 22 lines
Quoted 20 lines
---
  meta/conf/distro/include/security_flags.inc | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
meta/conf/distro/include/security_flags.inc +2 -1
index aaf04e9e59..5b79340be9 100644
@@ -26,8 +26,8 @@ SECURITY_STACK_PROTECTOR ?= "-fstack-protector-strong"
  SECURITY_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${SECURITY_PIE_CFLAGS} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
  SECURITY_NO_PIE_CFLAGS ?= "${SECURITY_STACK_PROTECTOR} ${lcl_maybe_fortify} ${SECURITY_STRINGFORMAT}"
  -SECURITY_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro,-z,now"
-SECURITY_X_LDFLAGS ?= "${SECURITY_STACK_PROTECTOR} -Wl,-z,relro"
+SECURITY_LDFLAGS ?= "-Wl,-z,relro,-z,now"
+SECURITY_X_LDFLAGS ?= "-Wl,-z,relro"
    # powerpc does not get on with pie for reasons not looked into as yet
  GCCPIE_powerpc = ""