mk: add stack-clash option to PKGSRC_USE_STACK_CHECK

This commit is contained in:
wiz 2022-08-01 07:58:21 +00:00
parent 9c380b7014
commit 7b149405e7
3 changed files with 14 additions and 7 deletions

View file

@ -1,4 +1,4 @@
# $NetBSD: bsd.prefs.mk,v 1.424 2022/07/22 09:27:01 nia Exp $
# $NetBSD: bsd.prefs.mk,v 1.425 2022/08/01 07:58:21 wiz Exp $
#
# This file includes the mk.conf file, which contains the user settings.
#
@ -855,7 +855,11 @@ _PKGSRC_USE_STACK_CHECK=no
.if ${PKGSRC_USE_STACK_CHECK:tl} != "no" && \
${STACK_CHECK_SUPPORTED:Uyes:tl} == "yes" && \
${_OPSYS_SUPPORTS_STACK_CHECK:Uno} == "yes"
. if ${PKGSRC_USE_STACK_CHECK:tl} == "stack-clash"
_PKGSRC_USE_STACK_CHECK=stack-clash
. else
_PKGSRC_USE_STACK_CHECK=yes
. endif
.endif
# Enable CTF conversion if the user requested it, the OPSYS supports it, there

View file

@ -1,4 +1,4 @@
# $NetBSD: gcc.mk,v 1.245 2022/07/07 16:23:39 jperkin Exp $
# $NetBSD: gcc.mk,v 1.246 2022/08/01 07:58:21 wiz Exp $
#
# This is the compiler definition for the GNU Compiler Collection.
#
@ -443,9 +443,11 @@ _RELRO_LDFLAGS= -Wl,-zrelro
_RELRO_LDFLAGS+= -Wl,-z,common-page-size=0x10000
.endif
_STACK_CHECK_CFLAGS= -fstack-check
.if ${_PKGSRC_USE_STACK_CHECK} == "yes"
_STACK_CHECK_CFLAGS= -fstack-check
_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS}
.elif ${_PKGSRC_USE_STACK_CHECK} == "stack-clash"
_STACK_CHECK_CFLAGS= -fstack-clash-protection
_GCC_CFLAGS+= ${_STACK_CHECK_CFLAGS}
.endif

View file

@ -1,4 +1,4 @@
# $NetBSD: mk.conf,v 1.334 2022/06/07 10:04:25 jperkin Exp $
# $NetBSD: mk.conf,v 1.335 2022/08/01 07:58:21 wiz Exp $
#
# This file provides default values for variables that may be overridden
@ -305,8 +305,9 @@ PKGSRC_USE_SSP?= strong
PKGSRC_USE_STACK_CHECK?= no
# Configure this to enable stack boundary verification (on supported platforms).
# Possible values:
# no: Do not pass any stack protection flags
# yes: Pass -fstack-check
# no: Do not pass any stack protection flags
# yes: Pass -fstack-check
# clash-protection: Pass -fstack-clash-protection
# Default: no
# The default PREFER_PKGSRC should be empty, but due to historical reasons we have the list below.