pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Backport MSan/NetBSD patches from LLVM review



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Dec 4 14:05:15 2017 +0100
Changeset:	70ee40fc8ae64f77249e1a574d77e5315ba6cdcd

Modified Files:
	compiler-rt-netbsd/Makefile
	compiler-rt-netbsd/distinfo
Added Files:
	compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc

Log Message:
compiler-rt-netbsd: Backport MSan/NetBSD patches from LLVM review

D40767 Support pthread_key_create symbol alias in MSan/NetBSD
D40766 Handle NetBSD symbol renaming in msan_interceptors.cc
D40765 Handle NetBSD symbol renaming in sanitizer_common_interceptors.inc
D40764 Disable absent functions in MSan/NetBSD interceptors

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=70ee40fc8ae64f77249e1a574d77e5315ba6cdcd

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-netbsd/Makefile                        |   4 +-
 compiler-rt-netbsd/distinfo                        |   2 +
 .../patches/patch-lib_msan_msan__interceptors.cc   | 180 +++++++++++++++++++++
 ...zer__common_sanitizer__common__interceptors.inc |  51 ++++++
 4 files changed, 235 insertions(+), 2 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/Makefile b/compiler-rt-netbsd/Makefile
index 02b438ceec..c1e1cf1a15 100644
--- a/compiler-rt-netbsd/Makefile
+++ b/compiler-rt-netbsd/Makefile
@@ -33,7 +33,7 @@ post-extract:
 	${RUN} mkdir -p ${WRKDIR}/build
 
 .include "../../wip/mk/svn-package.mk"
-DEPENDS+=	llvm-${PKGVERSION_NOREV}{,nb*}:../../wip/llvm-netbsd
-.include "../../wip/llvm-netbsd/buildlink3.mk"
+#DEPENDS+=	llvm-${PKGVERSION_NOREV}{,nb*}:../../wip/llvm-netbsd
+#.include "../../wip/llvm-netbsd/buildlink3.mk"
 .include "../../lang/python/tool.mk"
 .include "../../mk/bsd.pkg.mk"
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 420b44a219..24a9c16101 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -3,6 +3,8 @@ $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
 SHA1 (patch-cmake_config-ix.cmake) = b22fbae114557b1fb99e0683bd0a8804bdadcda5
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
 SHA1 (patch-lib_msan_msan.h) = 1ee0f86ccb410561d381afba526c85aa5dace912
+SHA1 (patch-lib_msan_msan__interceptors.cc) = 3a33fd9597e959a07dd15e6f13a79a25c109ac68
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = 633e5842df9c02e8c7310a14c23dd56e2d8de2c5
 SHA1 (patch-lib_scudo_scudo__platform.h) = 5dfd8f903c840e9ba81f2a8e502a380d296d4d5a
 SHA1 (patch-test_lsan_lit.common.cfg) = 10dc251f80efb96d015a22c740dc20b1843b9a11
 SHA1 (patch-test_scudo_lit.cfg) = 5821288b2a385d0da45a9af25f16a92b1316f962
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
new file mode 100644
index 0000000000..86cfed4134
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
@@ -0,0 +1,180 @@
+$NetBSD$
+
+--- lib/msan/msan_interceptors.cc.orig	2017-12-04 13:03:32.091928090 +0000
++++ lib/msan/msan_interceptors.cc
+@@ -152,9 +152,14 @@ INTERCEPTOR(SSIZE_T, readlink, const cha
+   return res;
+ }
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(void *, mempcpy, void *dest, const void *src, SIZE_T n) {
+   return (char *)__msan_memcpy(dest, src, n) + n;
+ }
++#define MSAN_MAYBE_INTERCEPT_MEMPCPY INTERCEPT_FUNCTION(mempcpy)
++#else
++#define MSAN_MAYBE_INTERCEPT_MEMPCPY
++#endif
+ 
+ INTERCEPTOR(void *, memccpy, void *dest, const void *src, int c, SIZE_T n) {
+   ENSURE_MSAN_INITED();
+@@ -194,6 +199,7 @@ INTERCEPTOR(void *, aligned_alloc, SIZE_
+   return msan_aligned_alloc(alignment, size, &stack);
+ }
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(void *, __libc_memalign, SIZE_T alignment, SIZE_T size) {
+   GET_MALLOC_STACK_TRACE;
+   void *ptr = msan_memalign(alignment, size, &stack);
+@@ -201,6 +207,10 @@ INTERCEPTOR(void *, __libc_memalign, SIZ
+     DTLS_on_libc_memalign(ptr, size);
+   return ptr;
+ }
++#define MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN INTERCEPT_FUNCTION(__libc_memalign)
++#else
++#define MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN
++#endif
+ 
+ INTERCEPTOR(void *, valloc, SIZE_T size) {
+   GET_MALLOC_STACK_TRACE;
+@@ -234,9 +244,15 @@ INTERCEPTOR(void, cfree, void *ptr) {
+ #define MSAN_MAYBE_INTERCEPT_CFREE
+ #endif
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(uptr, malloc_usable_size, void *ptr) {
+   return __sanitizer_get_allocated_size(ptr);
+ }
++#define MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE \
++  INTERCEPT_FUNCTION(malloc_usable_size)
++#else
++#define MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE
++#endif
+ 
+ #if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ // This function actually returns a struct by value, but we can't unpoison a
+@@ -297,6 +313,7 @@ INTERCEPTOR(char *, strncpy, char *dest,
+   return res;
+ }
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(char *, stpcpy, char *dest, const char *src) {  // NOLINT
+   ENSURE_MSAN_INITED();
+   GET_STORE_STACK_TRACE;
+@@ -306,6 +323,10 @@ INTERCEPTOR(char *, stpcpy, char *dest, 
+   CopyShadowAndOrigin(dest, src, n + 1, &stack);
+   return res;
+ }
++#define MSAN_MAYBE_INTERCEPT_STPCPY INTERCEPT_FUNCTION(stpcpy)
++#else
++#define MSAN_MAYBE_INTERCEPT_STPCPY
++#endif
+ 
+ INTERCEPTOR(char *, strdup, char *src) {
+   ENSURE_MSAN_INITED();
+@@ -334,6 +355,7 @@ INTERCEPTOR(char *, __strdup, char *src)
+ #define MSAN_MAYBE_INTERCEPT___STRDUP
+ #endif
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(char *, gcvt, double number, SIZE_T ndigit, char *buf) {
+   ENSURE_MSAN_INITED();
+   char *res = REAL(gcvt)(number, ndigit, buf);
+@@ -341,6 +363,10 @@ INTERCEPTOR(char *, gcvt, double number,
+   __msan_unpoison(buf, n + 1);
+   return res;
+ }
++#define MSAN_MAYBE_INTERCEPT_GCVT INTERCEPT_FUNCTION(gcvr)
++#else
++#define MSAN_MAYBE_INTERCEPT_GCVT
++#endif
+ 
+ INTERCEPTOR(char *, strcat, char *dest, const char *src) {  // NOLINT
+   ENSURE_MSAN_INITED();
+@@ -554,6 +580,7 @@ INTERCEPTOR(wchar_t *, wmemcpy, wchar_t 
+   return res;
+ }
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(wchar_t *, wmempcpy, wchar_t *dest, const wchar_t *src, SIZE_T n) {
+   ENSURE_MSAN_INITED();
+   GET_STORE_STACK_TRACE;
+@@ -561,6 +588,10 @@ INTERCEPTOR(wchar_t *, wmempcpy, wchar_t
+   CopyShadowAndOrigin(dest, src, n * sizeof(wchar_t), &stack);
+   return res;
+ }
++#define MSAN_MAYBE_INTERCEPT_WMEMPCPY INTERCEPT_FUNCTION(wmempcpy)
++#else
++#define MSAN_MAYBE_INTERCEPT_WMEMPCPY
++#endif
+ 
+ INTERCEPTOR(wchar_t *, wmemset, wchar_t *s, wchar_t c, SIZE_T n) {
+   CHECK(MEM_IS_APP(s));
+@@ -594,6 +625,7 @@ INTERCEPTOR(int, gettimeofday, void *tv,
+   return res;
+ }
+ 
++#if !SANITIZER_NETBSD
+ INTERCEPTOR(char *, fcvt, double x, int a, int *b, int *c) {
+   ENSURE_MSAN_INITED();
+   char *res = REAL(fcvt)(x, a, b, c);
+@@ -602,6 +634,10 @@ INTERCEPTOR(char *, fcvt, double x, int 
+   if (res) __msan_unpoison(res, REAL(strlen)(res) + 1);
+   return res;
+ }
++#define MSAN_MAYBE_INTERCEPT_FCVT INTERCEPT_FUNCTION(fcvr)
++#else
++#define MSAN_MAYBE_INTERCEPT_FCVT
++#endif
+ 
+ INTERCEPTOR(char *, getenv, char *name) {
+   if (msan_init_is_running)
+@@ -1512,7 +1548,7 @@ void InitializeInterceptors() {
+   MSAN_MAYBE_INTERCEPT_MMAP64;
+   INTERCEPT_FUNCTION(posix_memalign);
+   MSAN_MAYBE_INTERCEPT_MEMALIGN;
+-  INTERCEPT_FUNCTION(__libc_memalign);
++  MSAN_MAYBE_INTERCEPT___LIBC_MEMALIGN;
+   INTERCEPT_FUNCTION(valloc);
+   MSAN_MAYBE_INTERCEPT_PVALLOC;
+   INTERCEPT_FUNCTION(malloc);
+@@ -1520,7 +1556,7 @@ void InitializeInterceptors() {
+   INTERCEPT_FUNCTION(realloc);
+   INTERCEPT_FUNCTION(free);
+   MSAN_MAYBE_INTERCEPT_CFREE;
+-  INTERCEPT_FUNCTION(malloc_usable_size);
++  MSAN_MAYBE_INTERCEPT_MALLOC_USABLE_SIZE;
+   MSAN_MAYBE_INTERCEPT_MALLINFO;
+   MSAN_MAYBE_INTERCEPT_MALLOPT;
+   MSAN_MAYBE_INTERCEPT_MALLOC_STATS;
+@@ -1528,18 +1564,18 @@ void InitializeInterceptors() {
+   MSAN_MAYBE_INTERCEPT_FREAD_UNLOCKED;
+   INTERCEPT_FUNCTION(readlink);
+   INTERCEPT_FUNCTION(memccpy);
+-  INTERCEPT_FUNCTION(mempcpy);
++  MSAN_MAYBE_INTERCEPT_MEMPCPY;
+   INTERCEPT_FUNCTION(bcopy);
+   INTERCEPT_FUNCTION(wmemset);
+   INTERCEPT_FUNCTION(wmemcpy);
+-  INTERCEPT_FUNCTION(wmempcpy);
++  MSAN_MAYBE_INTERCEPT_WMEMPCPY;
+   INTERCEPT_FUNCTION(wmemmove);
+   INTERCEPT_FUNCTION(strcpy);  // NOLINT
+-  INTERCEPT_FUNCTION(stpcpy);  // NOLINT
++  MSAN_MAYBE_INTERCEPT_STPCPY;  // NOLINT
+   INTERCEPT_FUNCTION(strdup);
+   MSAN_MAYBE_INTERCEPT___STRDUP;
+   INTERCEPT_FUNCTION(strncpy);  // NOLINT
+-  INTERCEPT_FUNCTION(gcvt);
++  MSAN_MAYBE_INTERCEPT_GCVT;
+   INTERCEPT_FUNCTION(strcat);  // NOLINT
+   INTERCEPT_FUNCTION(strncat);  // NOLINT
+   INTERCEPT_STRTO(strtod);
+@@ -1584,7 +1620,7 @@ void InitializeInterceptors() {
+   INTERCEPT_FUNCTION(setenv);
+   INTERCEPT_FUNCTION(putenv);
+   INTERCEPT_FUNCTION(gettimeofday);
+-  INTERCEPT_FUNCTION(fcvt);
++  MSAN_MAYBE_INTERCEPT_FCVT;
+   MSAN_MAYBE_INTERCEPT___FXSTAT;
+   MSAN_INTERCEPT_FSTATAT;
+   MSAN_MAYBE_INTERCEPT___FXSTAT64;
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
new file mode 100644
index 0000000000..086f8c33ff
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig	2017-11-20 18:08:35.000000000 +0000
++++ lib/sanitizer_common/sanitizer_common_interceptors.inc
+@@ -69,6 +69,46 @@
+ #define iconv __bsd_iconv
+ #endif
+ 
++#if SANITIZER_NETBSD
++#define clock_getres __clock_getres50
++#define clock_gettime __clock_gettime50
++#define clock_settime __clock_settime50
++#define ctime __ctime50
++#define ctime_r __ctime_r50
++#define getitimer __getitimer50
++#define getpwent __getpwent50
++#define getpwnam __getpwnam50
++#define getpwnam_r __getpwnam_r50
++#define getpwuid __getpwuid50
++#define getpwuid_r __getpwuid_r50
++#define getutent __getutent50
++#define getutxent __getutxent50
++#define getutxid __getutxid50
++#define getutxline __getutxline50
++#define glob __glob30
++#define gmtime __gmtime50
++#define gmtime_r __gmtime_r50
++#define localtime_r __localtime_r50
++#define mktime __mktime50
++#define opendir __opendir30
++#define readdir __readdir30
++#define readdir_r __readdir_r30
++#define scandir __scandir30
++#define setitimer __setitimer50
++#define setlocale __setlocale50
++#define shmctl __shmctl50
++#define sigemptyset __sigemptyset14
++#define sigfillset __sigfillset14
++#define sigpending __sigpending14
++#define sigprocmask __sigprocmask14
++#define sigtimedwait __sigtimedwait50
++#define stat __stat50
++#define time __time50
++#define times __times13
++#define wait3 __wait350
++#define wait4 __wait450
++#endif
++
+ // Platform-specific options.
+ #if SANITIZER_MAC
+ namespace __sanitizer {


Home | Main Index | Thread Index | Old Index