pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Register support for PKGSRC_USE_STACK_CHECK



details:   https://anonhg.NetBSD.org/pkgsrc/rev/631ce94547b9
branches:  trunk
changeset: 365016:631ce94547b9
user:      khorben <khorben%pkgsrc.org@localhost>
date:      Sun Jul 09 14:30:07 2017 +0000

description:
Register support for PKGSRC_USE_STACK_CHECK

This adds -fstack-check to the CFLAGS (with GCC on NetBSD x86). Only
tested on NetBSD/amd64 so far.

Disabled by default.

diffstat:

 mk/bsd.prefs.mk       |  8 +++++++-
 mk/compiler/gcc.mk    |  8 +++++++-
 mk/defaults/mk.conf   |  9 ++++++++-
 mk/platform/NetBSD.mk |  8 +++++++-
 4 files changed, 29 insertions(+), 4 deletions(-)

diffs (89 lines):

diff -r 21cc576b7bb3 -r 631ce94547b9 mk/bsd.prefs.mk
--- a/mk/bsd.prefs.mk   Sun Jul 09 14:13:53 2017 +0000
+++ b/mk/bsd.prefs.mk   Sun Jul 09 14:30:07 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.392 2017/06/01 02:15:10 jlam Exp $
+# $NetBSD: bsd.prefs.mk,v 1.393 2017/07/09 14:30:07 khorben Exp $
 #
 # This file includes the mk.conf file, which contains the user settings.
 #
@@ -717,6 +717,12 @@
 _PKGSRC_USE_SSP=       yes
 .endif
 
+_PKGSRC_USE_STACK_CHECK=no
+.if (${PKGSRC_USE_STACK_CHECK:tl} != "no") && \
+    (${_OPSYS_SUPPORTS_STACK_CHECK:Uno} == "yes")
+_PKGSRC_USE_STACK_CHECK=yes
+.endif
+
 # Enable cwrappers if not building the wrappers themselves, and if the user has
 # explicitly requested them, or if they haven't but the compiler/platform is
 # known to support them.
diff -r 21cc576b7bb3 -r 631ce94547b9 mk/compiler/gcc.mk
--- a/mk/compiler/gcc.mk        Sun Jul 09 14:13:53 2017 +0000
+++ b/mk/compiler/gcc.mk        Sun Jul 09 14:30:07 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: gcc.mk,v 1.179 2017/06/25 01:41:15 joerg Exp $
+# $NetBSD: gcc.mk,v 1.180 2017/07/09 14:30:07 khorben Exp $
 #
 # This is the compiler definition for the GNU Compiler Collection.
 #
@@ -372,6 +372,12 @@
 _SSP_CFLAGS=           -fstack-protector
 .endif
 
+_STACK_CHECK_CFLAGS=   -fstack-check
+
+.if ${_PKGSRC_USE_STACK_CHECK} == "yes"
+_GCC_CFLAGS+=          ${_STACK_CHECK_CFLAGS}
+.endif
+
 # GCC has this annoying behaviour where it advocates in a multi-line
 # banner the use of "#include" over "#import" when including headers.
 # This generates a huge number of warnings when building practically all
diff -r 21cc576b7bb3 -r 631ce94547b9 mk/defaults/mk.conf
--- a/mk/defaults/mk.conf       Sun Jul 09 14:13:53 2017 +0000
+++ b/mk/defaults/mk.conf       Sun Jul 09 14:30:07 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mk.conf,v 1.277 2017/07/05 15:58:30 khorben Exp $
+# $NetBSD: mk.conf,v 1.278 2017/07/09 14:30:07 khorben Exp $
 #
 
 # This file provides default values for variables that may be overridden
@@ -258,6 +258,13 @@
 #      all:    Pass -fstack-protector-all
 # Default: yes
 
+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
+# Default: no
+
 # The default PREFER_PKGSRC should be empty, but due to historical reasons we have the list below.
 # Please add your platform here once you have confirmed it is correct
 .if ${OPSYS} == "OpenBSD" || ${OPSYS} == "Bitrig"
diff -r 21cc576b7bb3 -r 631ce94547b9 mk/platform/NetBSD.mk
--- a/mk/platform/NetBSD.mk     Sun Jul 09 14:13:53 2017 +0000
+++ b/mk/platform/NetBSD.mk     Sun Jul 09 14:30:07 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.mk,v 1.51 2017/07/04 18:29:24 khorben Exp $
+# $NetBSD: NetBSD.mk,v 1.52 2017/07/09 14:30:07 khorben Exp $
 #
 # Variable definitions for the NetBSD operating system.
 
@@ -154,6 +154,12 @@
 _OPSYS_SUPPORTS_SSP=   yes
 .endif
 
+# Register support for stack check on supported architectures (with GCC)
+.if (${MACHINE_ARCH} == "i386") || \
+    (${MACHINE_ARCH} == "x86_64")
+_OPSYS_SUPPORTS_STACK_CHECK=   yes
+.endif
+
 _OPSYS_SUPPORTS_CWRAPPERS=     yes
 
 # use readelf in check/bsd.check-vars.mk



Home | Main Index | Thread Index | Old Index