pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Push forwards sanitizers/NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Jun 19 21:40:55 2017 +0200
Changeset:	b2163f7fadef8871789fc87dcb67b12e1ab26c2c

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_asan_asan__linux.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.h
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
	compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
	compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__linux.cc

Log Message:
compiler-rt-netbsd: Push forwards sanitizers/NetBSD

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=b2163f7fadef8871789fc87dcb67b12e1ab26c2c

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

diffstat:
 compiler-rt-netbsd/distinfo                        |   9 +-
 .../patches/patch-lib_asan_asan__linux.cc          |  29 ++++-
 ...h-lib_sanitizer__common_sanitizer__libignore.cc |  19 ++++
 ...patch-lib_sanitizer__common_sanitizer__linux.cc |  10 +-
 .../patch-lib_sanitizer__common_sanitizer__linux.h |  20 ++++
 ...nitizer__common_sanitizer__syscall__generic.inc |  44 ++++++++
 .../patch-lib_tsan_rtl_tsan__interceptors.cc       | 118 +++++++++++++++++++++
 .../patch-lib_tsan_rtl_tsan__platform__linux.cc    |  25 +++++
 8 files changed, 266 insertions(+), 8 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 61741c8b50..7936aa4bbd 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -14,20 +14,25 @@ RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
 SHA1 (patch-cmake_config-ix.cmake) = 6b0644c422eaf3e2721398c2575e31e07b535984
 SHA1 (patch-lib_asan_asan__interceptors.h) = cca1e74041e37d366c512d23547063d6a4dee008
-SHA1 (patch-lib_asan_asan__linux.cc) = 5783b032e283f1d4220bf47609f8b0f8c88a758d
+SHA1 (patch-lib_asan_asan__linux.cc) = fcbf780af6bcd3b43c86d9e5e2c8a92e3a8885da
 SHA1 (patch-lib_asan_scripts_asan__symbolize.py) = d6c079e7092b22b5379293dbb8d1e2445e077932
 SHA1 (patch-lib_builtins_gcc__personality__v0.c) = 66c36733afc7043f662328303de2573fd9005bf3
 SHA1 (patch-lib_interception_interception.h) = f18c140feec3c88fec57ac7ba1fbedb03db2bac6
 SHA1 (patch-lib_interception_interception__linux.h) = 2f37344082e935a99fc04203453d387fe78bd6d3
 SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = 45b18179c5d1d9f284ccfe4670a989ac30d05e92
 SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = da22dbf5942941b0f8be6e1075ea6d71f14a9069
-SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = cfaf8ba61516835dfbdd48ccdf52e7dacb9f11b5
+SHA1 (patch-lib_sanitizer__common_sanitizer__libignore.cc) = 4b711c72fb64752eb17cc8e0b810526f33d64023
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = ec71e0189426780d32d83e25b1713040a8407e4f
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.h) = 88b1ebffc90f47b1dfd4e21e1ec3980a4ab9f4c3
 SHA1 (patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc) = 3f2be0e646495cbd7988782d8a57da6c4b022401
 SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd.h) = c1c19a402137e21ddc5bb48f8825400a34f010cc
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform.h) = 47360a8352cc34fddc71c8f71081d7d589a63dad
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = bd02af170d2ead22c646a0eb18f518895a2e71cf
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps.h) = ec0b5c576463639a3ee66c33ff7e9d94076f40df
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = a7e97fdb92e166f9d1def5a169c1fd079d8bb40a
+SHA1 (patch-lib_sanitizer__common_sanitizer__syscall__generic.inc) = 73db63809d0972346e76cc6eaebf0d7d047f0bea
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = f42a6732e8b95ba63fec8819a5be2bbd6518d610
+SHA1 (patch-lib_tsan_rtl_tsan__platform__linux.cc) = 3bb2c418b3d4bedad9014309abdd2cbad58b252c
 SHA1 (patch-lib_ubsan_ubsan__platform.h) = 8b9419ed6d3f40357eb73e71680d070bd64bd5cc
 SHA1 (patch-test_asan_lit.cfg) = 259b0e262b5975b862a51f015ec6b646ce2af10a
 SHA1 (patch-test_sanitizer__common_CMakeLists.txt) = 6af4c5ca42f17bb09823c36bf32d5576fbc0b4c8
diff --git a/compiler-rt-netbsd/patches/patch-lib_asan_asan__linux.cc b/compiler-rt-netbsd/patches/patch-lib_asan_asan__linux.cc
index 1275e3b215..c490ddabfd 100644
--- a/compiler-rt-netbsd/patches/patch-lib_asan_asan__linux.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_asan_asan__linux.cc
@@ -18,7 +18,34 @@ $NetBSD$
  #include "sanitizer_common/sanitizer_libc.h"
  #include "sanitizer_common/sanitizer_procmaps.h"
  
-@@ -174,4 +175,4 @@ void *AsanDlSymNext(const char *sym) {
+@@ -42,6 +43,10 @@
+ #if SANITIZER_ANDROID || SANITIZER_FREEBSD
+ #include <ucontext.h>
+ extern "C" void* _DYNAMIC;
++#elif SANITIZER_NETBSD
++#include <ucontext.h>
++#include <link_elf.h>   
++extern Elf_Dyn  _DYNAMIC;
+ #else
+ #include <sys/ucontext.h>
+ #include <link.h>
+@@ -96,6 +101,15 @@ static int FindFirstDSOCallback(struct d
+   if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
+     return 0;
+ 
++#if SANITIZER_NETBSD
++  // Ignore first entry (the main program)
++  char **p = (char **)data;
++  if (*p == NULL) {
++    *p = (char *)-1;
++    return 0;
++  }
++#endif
++
+   *(const char **)data = info->dlpi_name;
+   return 1;
+ }
+@@ -174,4 +188,4 @@ void *AsanDlSymNext(const char *sym) {
  
  } // namespace __asan
  
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
new file mode 100644
index 0000000000..b961420492
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__libignore.cc
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_libignore.cc.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/sanitizer_common/sanitizer_libignore.cc
+@@ -9,7 +9,7 @@
+ 
+ #include "sanitizer_platform.h"
+ 
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_MAC || SANITIZER_NETBSD
+ 
+ #include "sanitizer_libignore.h"
+ #include "sanitizer_flags.h"
+@@ -125,4 +125,4 @@ void LibIgnore::OnLibraryUnloaded() {
+ 
+ } // namespace __sanitizer
+ 
+-#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX
++#endif // #if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
index 06ad3620aa..c9a486a290 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
@@ -191,7 +191,7 @@ $NetBSD$
  #if SANITIZER_FREEBSD
      _umtx_op(m, UMTX_OP_WAKE, 1, 0, 0);
 +#elif SANITIZER_NETBSD
-+    continue; /* No userspace futex-like synchromization */
++    /* No userspace futex-like synchromization */
  #else
      internal_syscall(SYSCALL(futex), (uptr)m, FUTEX_WAKE, 1, 0, 0, 0);
  #endif
@@ -320,11 +320,11 @@ $NetBSD$
    *pc = ucontext->uc_mcontext.mc_eip;
    *bp = ucontext->uc_mcontext.mc_ebp;
    *sp = ucontext->uc_mcontext.mc_esp;
-+# if SANITIZER_NETBSD
++# elif SANITIZER_NETBSD
 +  ucontext_t *ucontext = (ucontext_t*)context;
-+  *pc = ucontext->uc_mcontext.r_eip;
-+  *bp = ucontext->uc_mcontext.r_ebp;
-+  *sp = ucontext->uc_mcontext.r_esp;
++  *pc = ucontext->uc_mcontext.__gregs[_REG_EIP];
++  *bp = ucontext->uc_mcontext.__gregs[_REG_EBP];
++  *sp = ucontext->uc_mcontext.__gregs[_REG_ESP];
  # else
    ucontext_t *ucontext = (ucontext_t*)context;
    *pc = ucontext->uc_mcontext.gregs[REG_EIP];
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.h
new file mode 100644
index 0000000000..08241ea928
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.h
@@ -0,0 +1,20 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_linux.h.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/sanitizer_common/sanitizer_linux.h
+@@ -14,7 +14,7 @@
+ #define SANITIZER_LINUX_H
+ 
+ #include "sanitizer_platform.h"
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+ #include "sanitizer_common.h"
+ #include "sanitizer_internal_defs.h"
+ #include "sanitizer_posix.h"
+@@ -130,5 +130,5 @@ ALWAYS_INLINE uptr *get_android_tls_ptr(
+ 
+ }  // namespace __sanitizer
+ 
+-#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX
++#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+ #endif  // SANITIZER_LINUX_H
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
new file mode 100644
index 0000000000..b824fd129c
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__syscall__generic.inc
@@ -0,0 +1,44 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_syscall_generic.inc.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/sanitizer_common/sanitizer_syscall_generic.inc
+@@ -11,13 +11,37 @@
+ //
+ //===----------------------------------------------------------------------===//
+ 
+-#if SANITIZER_FREEBSD || SANITIZER_MAC
++#ifdef SANITIZER_NETBSD
++# define SYS_stat SYS___stat50
++# define SYS_lstat SYS___lstat50
++# define SYS_fstat SYS___fstat50
++# define SYS_gettimeofday SYS___gettimeofday50
++# define SYS_wait4 SYS___wait450
++# define SYS_getdents SYS___getdents30
++# define SYS_sigaltstack SYS___sigaltstack14
++# define SYS_sigprocmask SYS___sigprocmask14
++# define SYS_nanosleep SYS___nanosleep50
++#endif
++#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+ # define SYSCALL(name) SYS_ ## name
+ #else
+ # define SYSCALL(name) __NR_ ## name
+ #endif
+ 
+-#if (SANITIZER_FREEBSD || SANITIZER_MAC) && defined(__x86_64__)
++#if SANITIZER_NETBSD
++// We use 3 kinds of internal_syscall's for different types of retval in order
++// to address problems related to the byte order.
++//   - internal_syscall     for 32-bit length (int, pid_t)
++//   - internal_syscall64   for 64-bit length (off_t)
++//   - internal_syscall_ptr for pointer and (s)size_t
++# define  internal_syscall      syscall                                                                                               
++# define  internal_syscall64    __syscall
++# if SANITIZER_WORDSIZE == 64
++#  define internal_syscall_ptr  __syscall
++# else
++#  define internal_syscall_ptr  syscall
++# endif
++#elif (SANITIZER_FREEBSD || SANITIZER_MAC) && defined(__x86_64__)
+ # define internal_syscall __syscall
+ # else
+ # define internal_syscall syscall
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
new file mode 100644
index 0000000000..ba3c53100a
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
@@ -0,0 +1,118 @@
+$NetBSD$
+
+--- lib/tsan/rtl/tsan_interceptors.cc.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/tsan/rtl/tsan_interceptors.cc
+@@ -39,6 +39,14 @@ using namespace __tsan;  // NOLINT
+ #define stderr __stderrp
+ #endif
+ 
++#if SANITIZER_NETBSD
++#define __errno_location __errno
++#define pthread_yield sched_yield
++#define fileno_unlocked fileno
++#define stdout __sF[1]
++#define stderr __sF[2]
++#endif
++
+ #if SANITIZER_ANDROID
+ #define __errno_location __errno
+ #define mallopt(a, b)
+@@ -87,11 +95,15 @@ extern "C" void _exit(int status);
+ extern "C" int *__errno_location();
+ extern "C" int fileno_unlocked(void *stream);
+ extern "C" int dirfd(void *dirp);
+-#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID
++#if !SANITIZER_FREEBSD && !SANITIZER_ANDROID && !SANITIZER_NETBSD
+ extern "C" int mallopt(int param, int value);
+ #endif
++#if SANITIZER_NETBSD
++extern __sanitizer_FILE **__sF;
++#else
+ extern __sanitizer_FILE *stdout, *stderr;
+-#if !SANITIZER_FREEBSD && !SANITIZER_MAC
++#endif
++#if !SANITIZER_FREEBSD && !SANITIZER_MAC && !SANITIZER_NETBSD
+ const int PTHREAD_MUTEX_RECURSIVE = 1;
+ const int PTHREAD_MUTEX_RECURSIVE_NP = 1;
+ #else
+@@ -101,7 +113,7 @@ const int PTHREAD_MUTEX_RECURSIVE_NP = 2
+ const int EINVAL = 22;
+ const int EBUSY = 16;
+ const int EOWNERDEAD = 130;
+-#if !SANITIZER_FREEBSD && !SANITIZER_MAC
++#if !SANITIZER_FREEBSD && !SANITIZER_MAC && !SANITIZER_NETBSD
+ const int EPOLL_CTL_ADD = 1;
+ #endif
+ const int SIGILL = 4;
+@@ -110,7 +122,7 @@ const int SIGFPE = 8;
+ const int SIGSEGV = 11;
+ const int SIGPIPE = 13;
+ const int SIGTERM = 15;
+-#if defined(__mips__) || SANITIZER_FREEBSD || SANITIZER_MAC
++#if defined(__mips__) || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+ const int SIGBUS = 10;
+ const int SIGSYS = 12;
+ #else
+@@ -154,7 +166,7 @@ struct sigaction_t {
+     sighandler_t sa_handler;
+     sigactionhandler_t sa_sigaction;
+   };
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   int sa_flags;
+   __sanitizer_sigset_t sa_mask;
+ #elif SANITIZER_MAC
+@@ -173,7 +185,7 @@ struct sigaction_t {
+ const sighandler_t SIG_DFL = (sighandler_t)0;
+ const sighandler_t SIG_IGN = (sighandler_t)1;
+ const sighandler_t SIG_ERR = (sighandler_t)-1;
+-#if SANITIZER_FREEBSD || SANITIZER_MAC
++#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+ const int SA_SIGINFO = 0x40;
+ const int SIG_SETMASK = 3;
+ #elif defined(__mips__)
+@@ -289,7 +301,7 @@ void ScopedInterceptor::DisableIgnores()
+ }
+ 
+ #define TSAN_INTERCEPT(func) INTERCEPT_FUNCTION(func)
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+ # define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION(func)
+ #else
+ # define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION_VER(func, ver)
+@@ -466,7 +478,7 @@ static void SetJmp(ThreadState *thr, upt
+ static void LongJmp(ThreadState *thr, uptr *env) {
+ #ifdef __powerpc__
+   uptr mangled_sp = env[0];
+-#elif SANITIZER_FREEBSD || SANITIZER_MAC
++#elif SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+   uptr mangled_sp = env[2];
+ #elif defined(SANITIZER_LINUX)
+ # ifdef __aarch64__
+@@ -1348,7 +1360,7 @@ TSAN_INTERCEPTOR(int, __fxstat, int vers
+ #endif
+ 
+ TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
+-#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_ANDROID
++#if SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_ANDROID || SANITIZER_NETBSD
+   SCOPED_TSAN_INTERCEPTOR(fstat, fd, buf);
+   if (fd > 0)
+     FdAccess(thr, pc, fd);
+@@ -1929,7 +1941,7 @@ TSAN_INTERCEPTOR(int, sigaction, int sig
+   sigactions[sig].sa_flags = *(volatile int*)&act->sa_flags;
+   internal_memcpy(&sigactions[sig].sa_mask, &act->sa_mask,
+       sizeof(sigactions[sig].sa_mask));
+-#if !SANITIZER_FREEBSD && !SANITIZER_MAC
++#if !SANITIZER_FREEBSD && !SANITIZER_MAC && !SANITIZER_NETBSD
+   sigactions[sig].sa_restorer = act->sa_restorer;
+ #endif
+   sigaction_t newact;
+@@ -2291,7 +2303,7 @@ struct ScopedSyscall {
+   }
+ };
+ 
+-#if !SANITIZER_FREEBSD && !SANITIZER_MAC
++#if !SANITIZER_FREEBSD && !SANITIZER_MAC && !SANITIZER_NETBSD
+ static void syscall_access_range(uptr pc, uptr p, uptr s, bool write) {
+   TSAN_SYSCALL();
+   MemoryAccessRange(thr, pc, p, s, write);
diff --git a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__linux.cc b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__linux.cc
new file mode 100644
index 0000000000..14c551d631
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__platform__linux.cc
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- lib/tsan/rtl/tsan_platform_linux.cc.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/tsan/rtl/tsan_platform_linux.cc
+@@ -9,12 +9,12 @@
+ //
+ // This file is a part of ThreadSanitizer (TSan), a race detector.
+ //
+-// Linux- and FreeBSD-specific code.
++// Linux-, FreeBSD- and NetBSD-specific code.
+ //===----------------------------------------------------------------------===//
+ 
+ 
+ #include "sanitizer_common/sanitizer_platform.h"
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ 
+ #include "sanitizer_common/sanitizer_common.h"
+ #include "sanitizer_common/sanitizer_libc.h"
+@@ -404,4 +404,4 @@ void cur_thread_finalize() {
+ 
+ }  // namespace __tsan
+ 
+-#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
++#endif  // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD


Home | Main Index | Thread Index | Old Index