pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk Add RELRO support for clang, based on the gcc logic.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/9fba515f8e06
branches:  trunk
changeset: 389821:9fba515f8e06
user:      wiz <wiz%pkgsrc.org@localhost>
date:      Wed Jan 09 13:19:03 2019 +0000

description:
Add RELRO support for clang, based on the gcc logic.

diffstat:

 mk/compiler/clang.mk  |  16 +++++++++++++++-
 mk/platform/Linux.mk  |   4 ++--
 mk/platform/NetBSD.mk |   4 ++--
 3 files changed, 19 insertions(+), 5 deletions(-)

diffs (73 lines):

diff -r 5c87eb0575e8 -r 9fba515f8e06 mk/compiler/clang.mk
--- a/mk/compiler/clang.mk      Wed Jan 09 11:56:37 2019 +0000
+++ b/mk/compiler/clang.mk      Wed Jan 09 13:19:03 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: clang.mk,v 1.19 2018/11/12 14:22:58 jperkin Exp $
+# $NetBSD: clang.mk,v 1.20 2019/01/09 13:19:03 wiz Exp $
 #
 # This is the compiler definition for the clang compiler.
 #
@@ -55,6 +55,13 @@
 
 _CTF_CFLAGS=           -gdwarf-2
 
+# The user can choose the level of RELRO.
+.if ${PKGSRC_USE_RELRO} == "partial"
+_RELRO_LDFLAGS=                -Wl,-z,relro
+.else
+_RELRO_LDFLAGS=                -Wl,-z,relro -Wl,-z,now
+.endif
+
 # The user can choose the level of stack smashing protection.
 .if ${PKGSRC_USE_SSP} == "all"
 _SSP_CFLAGS=           -fstack-protector-all
@@ -62,6 +69,13 @@
 _SSP_CFLAGS=           -fstack-protector
 .endif
 
+.if ${_PKGSRC_USE_RELRO} == "yes"
+_CLANG_LDFLAGS+=       ${_RELRO_LDFLAGS}
+CWRAPPERS_APPEND.ld+=  ${_RELRO_LDFLAGS}
+.endif
+
+LDFLAGS+=      ${_CLANG_LDFLAGS}
+
 # _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the
 # ones requested by the package in USE_LANGUAGES.
 #
diff -r 5c87eb0575e8 -r 9fba515f8e06 mk/platform/Linux.mk
--- a/mk/platform/Linux.mk      Wed Jan 09 11:56:37 2019 +0000
+++ b/mk/platform/Linux.mk      Wed Jan 09 13:19:03 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Linux.mk,v 1.78 2017/11/21 19:16:47 bsiegert Exp $
+# $NetBSD: Linux.mk,v 1.79 2019/01/09 13:19:03 wiz Exp $
 #
 # Variable definitions for the Linux operating system.
 
@@ -131,7 +131,7 @@
 _OPSYS_SUPPORTS_FORTIFY=yes
 .endif
 
-# Register support for RELRO on supported architectures (with GCC)
+# Register support for RELRO on supported architectures
 .if (${MACHINE_ARCH} == "i386") || \
     (${MACHINE_ARCH} == "x86_64")
 _OPSYS_SUPPORTS_RELRO= yes
diff -r 5c87eb0575e8 -r 9fba515f8e06 mk/platform/NetBSD.mk
--- a/mk/platform/NetBSD.mk     Wed Jan 09 11:56:37 2019 +0000
+++ b/mk/platform/NetBSD.mk     Wed Jan 09 13:19:03 2019 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: NetBSD.mk,v 1.57 2017/11/12 13:34:14 khorben Exp $
+# $NetBSD: NetBSD.mk,v 1.58 2019/01/09 13:19:03 wiz Exp $
 #
 # Variable definitions for the NetBSD operating system.
 
@@ -136,7 +136,7 @@
 _OPSYS_SUPPORTS_MKPIE= yes
 .endif
 
-# Register support for RELRO on supported architectures (with GCC)
+# Register support for RELRO on supported architectures
 .if (${MACHINE_ARCH} == "i386") || \
     (${MACHINE_ARCH} == "x86_64")
 _OPSYS_SUPPORTS_RELRO= yes



Home | Main Index | Thread Index | Old Index