pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
compiler-rt-netbsd: Add initial glue for lsan and msan
Module Name: pkgsrc-wip
Committed By: Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By: kamil
Date: Thu Jun 29 03:02:34 2017 +0200
Changeset: 448d47caa431abbe31e2468dfbc43fafe0704f6e
Modified Files:
compiler-rt-netbsd/distinfo
Added Files:
compiler-rt-netbsd/patches/patch-lib_lsan_lsan__common.h
compiler-rt-netbsd/patches/patch-lib_lsan_lsan__linux.cc
compiler-rt-netbsd/patches/patch-lib_msan_msan.h
compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
Log Message:
compiler-rt-netbsd: Add initial glue for lsan and msan
msan not tested.
lsan won't work as is, it requires more work to write dedicated code to match our tls/libc.
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=448d47caa431abbe31e2468dfbc43fafe0704f6e
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
compiler-rt-netbsd/distinfo | 5 +
.../patches/patch-lib_lsan_lsan__common.h | 13 ++
.../patches/patch-lib_lsan_lsan__linux.cc | 19 +++
compiler-rt-netbsd/patches/patch-lib_msan_msan.h | 13 ++
.../patches/patch-lib_msan_msan__interceptors.cc | 184 +++++++++++++++++++++
.../patches/patch-lib_msan_msan__linux.cc | 19 +++
6 files changed, 253 insertions(+)
diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index c94f2d7c0f..bbb23be7a3 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -23,6 +23,11 @@ SHA1 (patch-lib_builtins_gcc__personality__v0.c) = 66c36733afc7043f662328303de25
SHA1 (patch-lib_interception_interception.h) = f18c140feec3c88fec57ac7ba1fbedb03db2bac6
SHA1 (patch-lib_interception_interception__linux.cc) = a7c8a898784eb8424ca17dd96cf8faac4b3057bb
SHA1 (patch-lib_interception_interception__linux.h) = 2f37344082e935a99fc04203453d387fe78bd6d3
+SHA1 (patch-lib_lsan_lsan__common.h) = e2eecdcb084abe9c4f4dac4b22d85a5e50095580
+SHA1 (patch-lib_lsan_lsan__linux.cc) = 237e17c0992689d3fe37742861fc158ad5932b64
+SHA1 (patch-lib_msan_msan.h) = 255eb26b3e6c4b728376cd8b12f7efa3caccc7b5
+SHA1 (patch-lib_msan_msan__interceptors.cc) = aa4e4f78a25a51959787aaf54afa3fed35ed52bc
+SHA1 (patch-lib_msan_msan__linux.cc) = 059a26cbff5082a964b90314bccb0b994b323053
SHA1 (patch-lib_safestack_safestack.cc) = 6ccd97d3253eb3e284fc8375e651f2527317d88a
SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = 45b18179c5d1d9f284ccfe4670a989ac30d05e92
SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = b0815e88864b3f8f9c577811fb56bc8f9791a64c
diff --git a/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__common.h b/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__common.h
new file mode 100644
index 0000000000..bbd88649e0
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__common.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- lib/lsan/lsan_common.h.orig 2017-06-03 23:53:56.000000000 +0000
++++ lib/lsan/lsan_common.h
+@@ -30,7 +30,7 @@
+ // To enable LeakSanitizer on new architecture, one need to implement
+ // internal_clone function as well as (probably) adjust TLS machinery for
+ // new architecture inside sanitizer library.
+-#if (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC) && \
++#if (SANITIZER_LINUX && !SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_NETBSD) && \
+ (SANITIZER_WORDSIZE == 64) && \
+ (defined(__x86_64__) || defined(__mips64) || defined(__aarch64__) || \
+ defined(__powerpc64__))
diff --git a/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__linux.cc b/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__linux.cc
new file mode 100644
index 0000000000..f6ce0373d9
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_lsan_lsan__linux.cc
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- lib/lsan/lsan_linux.cc.orig 2017-06-03 23:53:56.000000000 +0000
++++ lib/lsan/lsan_linux.cc
+@@ -13,7 +13,7 @@
+
+ #include "sanitizer_common/sanitizer_platform.h"
+
+-#if SANITIZER_LINUX
++#if SANITIZER_LINUX || SANITIZER_NETBSD
+
+ #include "lsan_allocator.h"
+
+@@ -30,4 +30,4 @@ void ReplaceSystemMalloc() {}
+
+ } // namespace __lsan
+
+-#endif // SANITIZER_LINUX
++#endif // SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan.h b/compiler-rt-netbsd/patches/patch-lib_msan_msan.h
new file mode 100644
index 0000000000..ade60273f3
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- lib/msan/msan.h.orig 2017-06-03 23:53:56.000000000 +0000
++++ lib/msan/msan.h
+@@ -178,7 +178,7 @@ const MappingDesc kMemoryLayout[] = {
+ #define MEM_TO_SHADOW(mem) (LINEARIZE_MEM((mem)) + 0x080000000000ULL)
+ #define SHADOW_TO_ORIGIN(shadow) (((uptr)(shadow)) + 0x140000000000ULL)
+
+-#elif SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64
++#elif (SANITIZER_FREEBSD && SANITIZER_WORDSIZE == 64) || SANITIZER_NETBSD
+
+ // Low memory: main binary, MAP_32BIT mappings and modules
+ // High memory: heap, modules and main thread stack
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..a31f747d83
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
@@ -0,0 +1,184 @@
+$NetBSD$
+
+--- lib/msan/msan_interceptors.cc.orig 2017-06-12 15:01:29.000000000 +0000
++++ lib/msan/msan_interceptors.cc
+@@ -48,7 +48,7 @@ DECLARE_REAL(SIZE_T, strnlen, const char
+ DECLARE_REAL(void *, memcpy, void *dest, const void *src, uptr n)
+ DECLARE_REAL(void *, memset, void *dest, int c, uptr n)
+
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+ #define __errno_location __error
+ #endif
+
+@@ -123,7 +123,7 @@ static void *AllocateFromLocalPool(uptr
+ #define CHECK_UNPOISONED_STRING(x, n) \
+ CHECK_UNPOISONED_STRING_OF_LEN((x), internal_strlen(x), (n))
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(SIZE_T, fread_unlocked, void *ptr, SIZE_T size, SIZE_T nmemb,
+ void *file) {
+ ENSURE_MSAN_INITED();
+@@ -174,7 +174,7 @@ INTERCEPTOR(int, posix_memalign, void **
+ return 0;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(void *, memalign, SIZE_T boundary, SIZE_T size) {
+ GET_MALLOC_STACK_TRACE;
+ CHECK_EQ(boundary & (boundary - 1), 0);
+@@ -207,7 +207,7 @@ INTERCEPTOR(void *, valloc, SIZE_T size)
+ return ptr;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(void *, pvalloc, SIZE_T size) {
+ GET_MALLOC_STACK_TRACE;
+ uptr PageSize = GetPageSizeCached();
+@@ -230,7 +230,7 @@ INTERCEPTOR(void, free, void *ptr) {
+ MsanDeallocate(&stack, ptr);
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(void, cfree, void *ptr) {
+ GET_MALLOC_STACK_TRACE;
+ if (!ptr || UNLIKELY(IsInDlsymAllocPool(ptr))) return;
+@@ -245,7 +245,7 @@ INTERCEPTOR(uptr, malloc_usable_size, vo
+ return __sanitizer_get_allocated_size(ptr);
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ // This function actually returns a struct by value, but we can't unpoison a
+ // temporary! The following is equivalent on all supported platforms but
+ // aarch64 (which uses a different register for sret value). We have a test
+@@ -264,7 +264,7 @@ INTERCEPTOR(void, mallinfo, __sanitizer_
+ #define MSAN_MAYBE_INTERCEPT_MALLINFO
+ #endif
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, mallopt, int cmd, int value) {
+ return -1;
+ }
+@@ -273,7 +273,7 @@ INTERCEPTOR(int, mallopt, int cmd, int v
+ #define MSAN_MAYBE_INTERCEPT_MALLOPT
+ #endif
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(void, malloc_stats, void) {
+ // FIXME: implement, but don't call REAL(malloc_stats)!
+ }
+@@ -326,7 +326,7 @@ INTERCEPTOR(char *, strdup, char *src) {
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(char *, __strdup, char *src) {
+ ENSURE_MSAN_INITED();
+ GET_STORE_STACK_TRACE;
+@@ -491,7 +491,7 @@ INTERCEPTOR(SIZE_T, strftime_l, char *s,
+ INTERCEPTOR_STRFTIME_BODY(char, SIZE_T, strftime_l, s, max, format, tm, loc);
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(SIZE_T, __strftime_l, char *s, SIZE_T max, const char *format,
+ __sanitizer_tm *tm, void *loc) {
+ INTERCEPTOR_STRFTIME_BODY(char, SIZE_T, __strftime_l, s, max, format, tm,
+@@ -513,7 +513,7 @@ INTERCEPTOR(SIZE_T, wcsftime_l, wchar_t
+ loc);
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(SIZE_T, __wcsftime_l, wchar_t *s, SIZE_T max, const wchar_t *format,
+ __sanitizer_tm *tm, void *loc) {
+ INTERCEPTOR_STRFTIME_BODY(wchar_t, SIZE_T, __wcsftime_l, s, max, format, tm,
+@@ -675,7 +675,7 @@ INTERCEPTOR(int, putenv, char *string) {
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, __fxstat, int magic, int fd, void *buf) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(__fxstat)(magic, fd, buf);
+@@ -688,7 +688,7 @@ INTERCEPTOR(int, __fxstat, int magic, in
+ #define MSAN_MAYBE_INTERCEPT___FXSTAT
+ #endif
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, __fxstat64, int magic, int fd, void *buf) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(__fxstat64)(magic, fd, buf);
+@@ -701,7 +701,7 @@ INTERCEPTOR(int, __fxstat64, int magic,
+ #define MSAN_MAYBE_INTERCEPT___FXSTAT64
+ #endif
+
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+ INTERCEPTOR(int, fstatat, int fd, char *pathname, void *buf, int flags) {
+ ENSURE_MSAN_INITED();
+ int res = REAL(fstatat)(fd, pathname, buf, flags);
+@@ -720,7 +720,7 @@ INTERCEPTOR(int, __fxstatat, int magic,
+ # define MSAN_INTERCEPT_FSTATAT INTERCEPT_FUNCTION(__fxstatat)
+ #endif
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, __fxstatat64, int magic, int fd, char *pathname, void *buf,
+ int flags) {
+ ENSURE_MSAN_INITED();
+@@ -767,7 +767,7 @@ INTERCEPTOR(char *, fgets, char *s, int
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(char *, fgets_unlocked, char *s, int size, void *stream) {
+ ENSURE_MSAN_INITED();
+ char *res = REAL(fgets_unlocked)(s, size, stream);
+@@ -790,7 +790,7 @@ INTERCEPTOR(int, getrlimit, int resource
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, getrlimit64, int resource, void *rlim) {
+ if (msan_init_is_running) return REAL(getrlimit64)(resource, rlim);
+ ENSURE_MSAN_INITED();
+@@ -866,7 +866,7 @@ INTERCEPTOR(int, gethostname, char *name
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, epoll_wait, int epfd, void *events, int maxevents,
+ int timeout) {
+ ENSURE_MSAN_INITED();
+@@ -881,7 +881,7 @@ INTERCEPTOR(int, epoll_wait, int epfd, v
+ #define MSAN_MAYBE_INTERCEPT_EPOLL_WAIT
+ #endif
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(int, epoll_pwait, int epfd, void *events, int maxevents,
+ int timeout, void *sigmask) {
+ ENSURE_MSAN_INITED();
+@@ -970,7 +970,7 @@ INTERCEPTOR(void *, mmap, void *addr, SI
+ return res;
+ }
+
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ INTERCEPTOR(void *, mmap64, void *addr, SIZE_T length, int prot, int flags,
+ int fd, OFF64_T offset) {
+ ENSURE_MSAN_INITED();
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
new file mode 100644
index 0000000000..4b426f0bb8
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__linux.cc
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- lib/msan/msan_linux.cc.orig 2017-06-03 23:53:56.000000000 +0000
++++ lib/msan/msan_linux.cc
+@@ -13,7 +13,7 @@
+ //===----------------------------------------------------------------------===//
+
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+
+ #include "msan.h"
+ #include "msan_thread.h"
+@@ -213,4 +213,4 @@ void MsanTSDDtor(void *tsd) {
+
+ } // namespace __msan
+
+-#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
++#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
Home |
Main Index |
Thread Index |
Old Index