Skip to contentSkip to conversation

valgrind: Force -fno-stack-protector in CFLAGS

PATCH New Matt Weber 2 participants 2 messages Dec 21, 2016 – Jan 28, 2017

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH v2 1/1 valgrind: Force -fno-stack-protector in CFLAGS

From: Brandon Maier <[email protected]>

Valgrind must be compiled with no stack protection. Valgrind defaults CFLAGS to -fno-stack-protector, but Buildroot's CFLAGS may override if SSP is enabled.

---

v1 -> v2
[Thomas P
- Update language to state Buildroot may enable SSP
- Use a local temp VALGRIND_CFLAGS to build out CFLAGS used in VALGRIND_CONF_ENV

---
 package/valgrind/valgrind.mk | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
package/valgrind/valgrind.mk +10 -1
index 087a381..652432f 100644
@@ -17,6 +17,13 @@ VALGRIND_INSTALL_STAGING = YES
 # patch 0004-Fixes-for-musl-libc.patch touching configure.ac
 VALGRIND_AUTORECONF = YES
 
+# Valgrind must be compiled with no stack protection, so forcefully
+# pass -fno-stack-protector to override what Buildroot may have in
+# TARGET_CFLAGS if BR2_SSP_* support is enabled.
+VALGRIND_CFLAGS = \
+	$(TARGET_CFLAGS) \
+	-fno-stack-protector
+
 # When Valgrind detects a 32-bit MIPS architecture, it forcibly adds
 # -march=mips32 to CFLAGS; when it detects a 64-bit MIPS architecture,
 # it forcibly adds -march=mips64. This causes Valgrind to be built
@@ -27,9 +34,11 @@ VALGRIND_AUTORECONF = YES
 # and pass the right -march option, so they take precedence over
 # Valgrind's wrongfully detected value.
 ifeq ($(BR2_mips)$(BR2_mipsel)$(BR2_mips64)$(BR2_mips64el),y)
-VALGRIND_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -march=$(BR2_GCC_TARGET_ARCH)"
+VALGRIND_CFLAGS += -march=$(BR2_GCC_TARGET_ARCH)
 endif
 
+VALGRIND_CONF_ENV = CFLAGS="$(VALGRIND_CFLAGS)"
+
 # On ARM, Valgrind only supports ARMv7, and uses the arch part of the
 # host tuple to determine whether it's being built for ARMv7 or
 # not. Therefore, we adjust the host tuple to specify we're on
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/1 valgrind: Force -fno-stack-protector in CFLAGS

Hello,

Quoted 9 lines · Matt Weber

From: Brandon Maier <[email protected]>

Valgrind must be compiled with no stack protection. Valgrind defaults CFLAGS to -fno-stack-protector, but Buildroot's CFLAGS may override if SSP is enabled.

---

Applied to master, thanks.

Thomas

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