Module Name: src
Committed By: kamil
Date: Mon Jun 25 17:58:36 UTC 2018
Modified Files:
src/share/mk: bsd.lib.mk bsd.prog.mk
Log Message:
Add a framework for renaming symbols in libc&co for MKSANITIZER
A new keyword SANITIZER_RENAME_SYMBOL. It's a variable that has specified
a list of symbols to be renamed in a processor in order to remove naming
conflicts with public symbols in libc/m/pthread/rt.
This renaming will occur for libraries and programs.
A symbol with a conflicting 'name', will be renamed to '__mksanitizer_name'.
Based on an idea by <christos>
To generate a diff of this commit:
cvs rdiff -u -r1.375 -r1.376 src/share/mk/bsd.lib.mk
cvs rdiff -u -r1.314 -r1.315 src/share/mk/bsd.prog.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/share/mk/bsd.lib.mk
diff -u src/share/mk/bsd.lib.mk:1.375 src/share/mk/bsd.lib.mk:1.376
--- src/share/mk/bsd.lib.mk:1.375 Thu Jun 21 11:24:38 2018
+++ src/share/mk/bsd.lib.mk Mon Jun 25 17:58:36 2018
@@ -1,9 +1,17 @@
-# $NetBSD: bsd.lib.mk,v 1.375 2018/06/21 11:24:38 kamil Exp $
+# $NetBSD: bsd.lib.mk,v 1.376 2018/06/25 17:58:36 kamil Exp $
# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
.include <bsd.init.mk>
.include <bsd.shlib.mk>
.include <bsd.gcc.mk>
+
+# Rename the local function definitions to not conflict with libc/rt/pthread/m.
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
+. for _symbol in ${SANITIZER_RENAME_SYMBOL}
+CPPFLAGS+= -D${_symbol}=__mksanitizer_${_symbol}
+. endfor
+.endif
+
# Pull in <bsd.sys.mk> here so we can override its .c.o rule
.include <bsd.sys.mk>
Index: src/share/mk/bsd.prog.mk
diff -u src/share/mk/bsd.prog.mk:1.314 src/share/mk/bsd.prog.mk:1.315
--- src/share/mk/bsd.prog.mk:1.314 Thu Jun 21 11:24:38 2018
+++ src/share/mk/bsd.prog.mk Mon Jun 25 17:58:36 2018
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prog.mk,v 1.314 2018/06/21 11:24:38 kamil Exp $
+# $NetBSD: bsd.prog.mk,v 1.315 2018/06/25 17:58:36 kamil Exp $
# @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94
.ifndef HOSTPROG
@@ -13,6 +13,13 @@ CFLAGS+= ${SANITIZERFLAGS}
CXXFLAGS+= ${SANITIZERFLAGS}
LDFLAGS+= ${SANITIZERFLAGS}
+# Rename the local function definitions to not conflict with libc/rt/pthread/m.
+.if ${MKSANITIZER:Uno} == "yes" && defined(SANITIZER_RENAME_SYMBOL)
+. for _symbol in ${SANITIZER_RENAME_SYMBOL}
+CPPFLAGS+= -D${_symbol}=__mksanitizer_${_symbol}
+. endfor
+.endif
+
#
# Definitions and targets shared among all programs built by a single
# Makefile.