pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Push forwards sanitizers



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Jun 18 18:42:07 2017 +0200
Changeset:	7811fbc672fd7f1846ad4c4db52ff813baf4c07e

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__posix.h

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

This is work-in-progress.

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=7811fbc672fd7f1846ad4c4db52ff813baf4c07e

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

diffstat:
 compiler-rt-netbsd/distinfo                        |   8 +-
 ...patch-lib_sanitizer__common_sanitizer__linux.cc | 226 +++++++++++++++++++++
 ..._sanitizer__common_sanitizer__linux__libcdep.cc |  12 +-
 ...patch-lib_sanitizer__common_sanitizer__netbsd.h |   2 +-
 .../patch-lib_sanitizer__common_sanitizer__posix.h |   0
 ...anitizer__common_sanitizer__procmaps__netbsd.cc |   2 +-
 6 files changed, 239 insertions(+), 11 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 7b8dac73f8..d54c3a3a54 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -21,12 +21,14 @@ SHA1 (patch-lib_interception_interception.h) = f18c140feec3c88fec57ac7ba1fbedb03
 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__libcdep.cc) = 2ed1876f3895fce658270a566f975b61ac06494e
-SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd.h) = c61cb87170cbe35c9e9ed6d26fb0589b1f7b72a7
+SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 76c1520522fc20866c2b70632310c53698123da0
+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__posix.h) = da39a3ee5e6b4b0d3255bfef95601890afd80709
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps.h) = ec0b5c576463639a3ee66c33ff7e9d94076f40df
-SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = b74e609af6aa87bc1efb395935eea6a41b3b19d5
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc) = a7e97fdb92e166f9d1def5a169c1fd079d8bb40a
 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_sanitizer__common_sanitizer__linux.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
new file mode 100644
index 0000000000..e31a0864f4
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
@@ -0,0 +1,226 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_linux.cc.orig	2017-06-16 23:00:11.000000000 +0000
++++ lib/sanitizer_common/sanitizer_linux.cc
+@@ -14,7 +14,7 @@
+ 
+ #include "sanitizer_platform.h"
+ 
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+ 
+ #include "sanitizer_common.h"
+ #include "sanitizer_flags.h"
+@@ -27,10 +27,14 @@
+ #include "sanitizer_stacktrace.h"
+ #include "sanitizer_symbolizer.h"
+ 
+-#if !SANITIZER_FREEBSD
++#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ #include <asm/param.h>
+ #endif
+ 
++#if SANITIZER_NETBSD
++#include <lwp.h>
++#endif
++
+ // For mips64, syscall(__NR_stat) fills the buffer in the 'struct kernel_stat'
+ // format. Struct kernel_stat is defined as 'struct stat' in asm/stat.h. To
+ // access stat from asm/stat.h, without conflicting with definition in
+@@ -71,6 +75,12 @@ extern "C" {
+ extern char **environ;  // provided by crt1
+ #endif  // SANITIZER_FREEBSD
+ 
++#if SANITIZER_NETBSD
++#include <limits.h>     // For NAME_MAX
++#include <sys/sysctl.h>
++extern char **environ;  // provided by crt1
++#endif  // SANITIZER_NETBSD 
++
+ #if !SANITIZER_ANDROID
+ #include <sys/signal.h>
+ #endif
+@@ -131,7 +141,10 @@ namespace __sanitizer {
+ #if !SANITIZER_S390
+ uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
+                    OFF_T offset) {
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
++#if SANITIZER_NETBSD     
++  return internal_syscall_ptr(SYSCALL(mmap), addr, length, prot, flags, fd,
++                              (long)0, offset);
++#elif SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
+   return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
+                           offset);
+ #else
+@@ -174,26 +187,38 @@ uptr internal_open(const char *filename,
+ 
+ uptr internal_read(fd_t fd, void *buf, uptr count) {
+   sptr res;
++#ifdef SANITIZER_NETBSD  
++  HANDLE_EINTR(res, internal_syscall_ptr(SYSCALL(read), fd, buf, count));
++#else
+   HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(read), fd, (uptr)buf,
+                count));
++#endif
+   return res;
+ }
+ 
+ uptr internal_write(fd_t fd, const void *buf, uptr count) {
+   sptr res;
++#ifdef SANITIZER_NETBSD
++  HANDLE_EINTR(res, internal_syscall_ptr(SYSCALL(write), fd, buf, count));
++#else
+   HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(write), fd, (uptr)buf,
+                count));
++#endif
+   return res;
+ }
+ 
+ uptr internal_ftruncate(fd_t fd, uptr size) {
+   sptr res;
++#ifdef SANITIZER_NETBSD
++  HANDLE_EINTR(res, internal_syscall(SYSCALL(ftruncate), fd, 0, (s64)size));
++#else
+   HANDLE_EINTR(res, (sptr)internal_syscall(SYSCALL(ftruncate), fd,
+                (OFF_T)size));
++#endif
+   return res;
+ }
+ 
+-#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD
++#if !SANITIZER_LINUX_USES_64BIT_SYSCALLS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+ static void stat64_to_stat(struct stat64 *in, struct stat *out) {
+   internal_memset(out, 0, sizeof(*out));
+   out->st_dev = in->st_dev;
+@@ -234,7 +259,7 @@ static void kernel_stat_to_stat(struct k
+ #endif
+ 
+ uptr internal_stat(const char *path, void *buf) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
+                           (uptr)buf, 0);
+ #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+@@ -259,7 +284,9 @@ uptr internal_stat(const char *path, voi
+ }
+ 
+ uptr internal_lstat(const char *path, void *buf) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_NETBSD
++  return internal_syscall(SYSCALL(lstat), path, buf);
++#elif SANITIZER_FREEBSD
+   return internal_syscall(SYSCALL(fstatat), AT_FDCWD, (uptr)path,
+                           (uptr)buf, AT_SYMLINK_NOFOLLOW);
+ #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+@@ -284,7 +311,7 @@ uptr internal_lstat(const char *path, vo
+ }
+ 
+ uptr internal_fstat(fd_t fd, void *buf) {
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
++#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS || SANITIZER_NETBSD
+ # if SANITIZER_MIPS64
+   // For mips64, fstat syscall fills buffer in the format of kernel_stat
+   struct kernel_stat kbuf;
+@@ -318,7 +345,9 @@ uptr internal_dup2(int oldfd, int newfd)
+ }
+ 
+ uptr internal_readlink(const char *path, char *buf, uptr bufsize) {
+-#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
++#if SANITIZER_NETBSD
++  return internal_syscall_ptr(SYSCALL(readlink), path, buf, bufsize);
++#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+   return internal_syscall(SYSCALL(readlinkat), AT_FDCWD,
+                           (uptr)path, (uptr)buf, bufsize);
+ #else
+@@ -348,7 +377,7 @@ uptr internal_sched_yield() {
+ }
+ 
+ void internal__exit(int exitcode) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   internal_syscall(SYSCALL(exit), exitcode);
+ #else
+   internal_syscall(SYSCALL(exit_group), exitcode);
+@@ -387,19 +416,25 @@ bool FileExists(const char *filename) {
+ tid_t GetTid() {
+ #if SANITIZER_FREEBSD
+   return (uptr)pthread_self();
++#elif SANITIZER_NETBSD
++  return _lwp_self();
+ #else
+   return internal_syscall(SYSCALL(gettid));
+ #endif
+ }
+ 
+ u64 NanoTime() {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   timeval tv;
+ #else
+   kernel_timeval tv;
+ #endif
+   internal_memset(&tv, 0, sizeof(tv));
++#if SANITIZER_NETBSD
++  internal_syscall(SYSCALL(gettimeofday), &tv, NULL);
++#else
+   internal_syscall(SYSCALL(gettimeofday), (uptr)&tv, 0);
++#endif
+   return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
+ }
+ 
+@@ -407,7 +442,7 @@ u64 NanoTime() {
+ // 'environ' array (on FreeBSD) and does not use libc. This function should be
+ // called first inside __asan_init.
+ const char *GetEnv(const char *name) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   if (::environ != 0) {
+     uptr NameLen = internal_strlen(name);
+     for (char **Env = ::environ; *Env != 0; Env++) {
+@@ -604,7 +639,9 @@ uptr internal_getppid() {
+ }
+ 
+ uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_NETBSD
++  return internal_syscall(SYSCALL(getdents), fd, dirp, (uptr)count);
++#elif SANITIZER_FREEBSD
+   return internal_syscall(SYSCALL(getdirentries), fd, (uptr)dirp, count, NULL);
+ #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+   return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
+@@ -614,7 +651,11 @@ uptr internal_getdents(fd_t fd, struct l
+ }
+ 
+ uptr internal_lseek(fd_t fd, OFF_T offset, int whence) {
++#if SANITIZER_NETBSD
++  return internal_syscall64(SYSCALL(lseek), fd, 0, offset, whence);
++#else
+   return internal_syscall(SYSCALL(lseek), fd, offset, whence);
++#endif
+ }
+ 
+ #if SANITIZER_LINUX
+@@ -706,7 +747,7 @@ int internal_sigaction_syscall(int signu
+ 
+ uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
+     __sanitizer_sigset_t *oldset) {
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+   return internal_syscall(SYSCALL(sigprocmask), how, set, oldset);
+ #else
+   __sanitizer_kernel_sigset_t *k_set = (__sanitizer_kernel_sigset_t *)set;
+@@ -829,8 +870,12 @@ uptr GetPageSize() {
+ }
+ 
+ uptr ReadBinaryName(/*out*/char *buf, uptr buf_len) {
+-#if SANITIZER_FREEBSD
+-  const int Mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
++# if SANITIZER_FREEBSD
++  const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
++# else
++  const int Mib[4] = { CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME };
++# endif
+   const char *default_module_name = "kern.proc.pathname";
+   size_t Size = buf_len;
+   bool IsErr = (sysctl(Mib, ARRAY_SIZE(Mib), buf, &Size, NULL, 0) != 0);
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
index d71d6cb346..a520666148 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig	2017-06-03 23:53:58.000000000 +0000
+--- lib/sanitizer_common/sanitizer_linux_libcdep.cc.orig	2017-06-16 23:00:11.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
 @@ -14,13 +14,14 @@
  
@@ -18,7 +18,7 @@ $NetBSD$
  #include "sanitizer_linux.h"
  #include "sanitizer_placement_new.h"
  #include "sanitizer_procmaps.h"
-@@ -152,7 +153,7 @@ bool SanitizerGetThreadName(char *name, 
+@@ -151,7 +152,7 @@ bool SanitizerGetThreadName(char *name, 
  #endif
  }
  
@@ -27,7 +27,7 @@ $NetBSD$
  static uptr g_tls_size;
  
  #ifdef __i386__
-@@ -180,7 +181,7 @@ void InitTlsSize() {
+@@ -179,7 +180,7 @@ void InitTlsSize() {
  }
  #else
  void InitTlsSize() { }
@@ -36,7 +36,7 @@ $NetBSD$
  
  #if (defined(__x86_64__) || defined(__i386__) || defined(__mips__) \
      || defined(__aarch64__) || defined(__powerpc64__) || defined(__s390__) \
-@@ -337,6 +338,12 @@ uptr ThreadSelf() {
+@@ -336,6 +337,12 @@ uptr ThreadSelf() {
  }
  #endif  // SANITIZER_FREEBSD
  
@@ -49,7 +49,7 @@ $NetBSD$
  #if !SANITIZER_GO
  static void GetTls(uptr *addr, uptr *size) {
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
-@@ -366,7 +373,7 @@ static void GetTls(uptr *addr, uptr *siz
+@@ -365,7 +372,7 @@ static void GetTls(uptr *addr, uptr *siz
      *addr = (uptr) dtv[2];
      *size = (*addr == 0) ? 0 : ((uptr) segbase[0] - (uptr) dtv[2]);
    }
@@ -58,7 +58,7 @@ $NetBSD$
    *addr = 0;
    *size = 0;
  #else
-@@ -377,7 +384,7 @@ static void GetTls(uptr *addr, uptr *siz
+@@ -376,7 +383,7 @@ static void GetTls(uptr *addr, uptr *siz
  
  #if !SANITIZER_GO
  uptr GetTlsSize() {
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
index a84607a548..f863f508ca 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_netbsd.h.orig	2017-06-14 13:03:28.915352766 +0000
+--- lib/sanitizer_common/sanitizer_netbsd.h.orig	2017-06-18 15:16:00.541244551 +0000
 +++ lib/sanitizer_common/sanitizer_netbsd.h
 @@ -0,0 +1,20 @@
 +//===-- sanitizer_freebsd.h -------------------------------------*- C++ -*-===//
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__posix.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__posix.h
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
index f9923f35f7..1cd0ef534d 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__netbsd.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig	2017-06-14 11:43:17.716788351 +0000
+--- lib/sanitizer_common/sanitizer_procmaps_netbsd.cc.orig	2017-06-18 15:16:00.620497444 +0000
 +++ lib/sanitizer_common/sanitizer_procmaps_netbsd.cc
 @@ -0,0 +1,79 @@
 +//===-- sanitizer_procmaps_freebsd.cc -------------------------------------===//


Home | Main Index | Thread Index | Old Index