mk: Add support for conditional compilation of parts of the tree with

partial RELRO when MKRELRO=full is set.

Currently the X server needs to be compiled with only partial RELRO
due to the way certain (but not all - it seems wsfb works with full
RELRO) graphics driver modules are loaded.
This commit is contained in:
nia 2021-11-01 10:05:18 +00:00
parent 4dcd8159ae
commit 8b8c4023f4
9 changed files with 30 additions and 10 deletions

View File

@ -1,8 +1,10 @@
# $NetBSD: Makefile.xf86-driver,v 1.28 2021/05/31 21:45:41 joerg Exp $
# $NetBSD: Makefile.xf86-driver,v 1.29 2021/11/01 10:05:18 nia Exp $
LIBISMODULE= yes
SHLIB_MAJOR= ${PACKAGE_MAJOR}
NOFULLRELRO= yes
.include <bsd.own.mk>
.include <bsd.x11.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.Xserver,v 1.2 2019/03/08 10:00:06 mrg Exp $
# $NetBSD: Makefile.Xserver,v 1.3 2021/11/01 10:05:19 nia Exp $
.for _SL in \
mi \
@ -73,6 +73,9 @@ DPADD.${_SL}= ${LIBDIR.${_SL}}/lib${_SL:T}.a
LDADD.XORG_CORE= ${LDADD.dix} ${LDADD.config}
DPADD.XORG_CORE= ${DPADD.dix} ${DPADD.config}
# X servers cannot load certain modules when built with BIND_NOW
NOFULLRELRO= yes
# X servers need all symbols exported
LDFLAGS+= -Wl,--export-dynamic

View File

@ -1,4 +1,6 @@
# $NetBSD: Makefile.serverlib,v 1.4 2021/05/03 08:44:05 nakayama Exp $
# $NetBSD: Makefile.serverlib,v 1.5 2021/11/01 10:05:19 nia Exp $
NOFULLRELRO= yes
.include <bsd.own.mk> # for NETBSDSRCDIR and mk.conf processing

View File

@ -1,4 +1,6 @@
# $NetBSD: Makefile.servermod,v 1.4 2021/05/03 08:44:05 nakayama Exp $
# $NetBSD: Makefile.servermod,v 1.5 2021/11/01 10:05:19 nia Exp $
NOFULLRELRO= yes
.include <bsd.own.mk> # For /etc/mk.conf processing

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.Xserver,v 1.22 2019/01/18 23:05:30 mrg Exp $
# $NetBSD: Makefile.Xserver,v 1.23 2021/11/01 10:05:19 nia Exp $
.for _SL in \
mi \
@ -63,6 +63,9 @@ DPADD.${_SL}= ${LIBDIR.${_SL}}/lib${_SL:T}.a
LDADD.XORG_CORE= ${LDADD.dix} ${LDADD.config}
DPADD.XORG_CORE= ${DPADD.dix} ${DPADD.config}
# X servers cannot load certain modules when built with BIND_NOW
NOFULLRELRO= yes
# X servers need all symbols exported
LDFLAGS+= -Wl,--export-dynamic

View File

@ -1,4 +1,6 @@
# $NetBSD: Makefile.serverlib,v 1.13 2021/04/12 03:57:06 mrg Exp $
# $NetBSD: Makefile.serverlib,v 1.14 2021/11/01 10:05:19 nia Exp $
NOFULLRELRO= yes
.include <bsd.own.mk> # for NETBSDSRCDIR and mk.conf processing

View File

@ -1,4 +1,6 @@
# $NetBSD: Makefile.servermod,v 1.6 2021/04/12 03:57:06 mrg Exp $
# $NetBSD: Makefile.servermod,v 1.7 2021/11/01 10:05:19 nia Exp $
NOFULLRELRO= yes
.include <bsd.own.mk> # For /etc/mk.conf processing

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.README,v 1.421 2021/10/27 03:06:59 ryo Exp $
# $NetBSD: bsd.README,v 1.422 2021/11/01 10:05:19 nia Exp $
# @(#)bsd.README 8.2 (Berkeley) 4/2/94
This is the README file for the make "include" files for the NetBSD
@ -438,6 +438,9 @@ MKRELRO If "partial", set the non-PLT GOT to read-only. If "full"
also force immediate symbol binding.
Default: no
NOFULLRELRO Don't compile with immediate symbol binding during build.
It is set internally for standalone programs.
MKREPRO If "yes", create reproducible builds. This enables
different switches to make two builds from the same source tree
result in the same build results.

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.sys.mk,v 1.307 2021/09/11 21:30:46 andvar Exp $
# $NetBSD: bsd.sys.mk,v 1.308 2021/11/01 10:05:19 nia Exp $
#
# Build definitions used for NetBSD source tree builds.
@ -140,7 +140,8 @@ CFLAGS+= -Wno-maybe-uninitialized
.if ${MKRELRO:Uno} != "no"
LDFLAGS+= -Wl,-z,relro
.endif
.if ${MKRELRO:Uno} == "full"
.if ${MKRELRO:Uno} == "full" && ${NOFULLRELRO:Uno} == "no"
LDFLAGS+= -Wl,-z,now
.endif