pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Add more asan sugar for NetBSD



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Jun 21 21:35:22 2017 +0200
Changeset:	ec56c432d00f6c4cccba041e6f53fa4ae8a9167c

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
	compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc

Log Message:
compiler-rt-netbsd: Add more asan sugar for NetBSD

This fixes missing symbols and breaks the build again.

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

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 +-
 ...zer__common_sanitizer__common__interceptors.inc |   8 +-
 ...r__common_sanitizer__platform__limits__posix.cc | 229 +++++++++++++++++++++
 ...er__common_sanitizer__platform__limits__posix.h |  59 +++---
 ...anitizer__common_sanitizer__procmaps__common.cc |  19 ++
 .../patch-lib_tsan_rtl_tsan__interceptors.cc       |  47 ++---
 6 files changed, 302 insertions(+), 68 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 2e83dfe9d1..400756ac8b 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -21,18 +21,20 @@ SHA1 (patch-lib_interception_interception.h) = f18c140feec3c88fec57ac7ba1fbedb03
 SHA1 (patch-lib_interception_interception__linux.h) = 2f37344082e935a99fc04203453d387fe78bd6d3
 SHA1 (patch-lib_safestack_safestack.cc) = 6ccd97d3253eb3e284fc8375e651f2527317d88a
 SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = 45b18179c5d1d9f284ccfe4670a989ac30d05e92
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = da22dbf5942941b0f8be6e1075ea6d71f14a9069
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = b0815e88864b3f8f9c577811fb56bc8f9791a64c
 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__platform__limits__posix.cc) = d4c0c967b53dbdf86090c7f0fba9b808302cca77
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = 01eba8683f70398c8f4be6bc6de165ffd7bf27fa
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps.h) = ec0b5c576463639a3ee66c33ff7e9d94076f40df
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__common.cc) = 0c30494654cfc0294804434d40468f6f722a6786
 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) = 66052fb67cce09953680717b8840f95a70f2869b
+SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 80dfeebfd74f5470604b8cebfd90aae810a10cc0
 SHA1 (patch-lib_tsan_rtl_tsan__platform__linux.cc) = 3bb2c418b3d4bedad9014309abdd2cbad58b252c
 SHA1 (patch-lib_tsan_rtl_tsan__rtl__amd64.S) = 743e52c14f6aa21d0002b05a1be4f972dff0206f
 SHA1 (patch-lib_ubsan_ubsan__platform.h) = 8b9419ed6d3f40357eb73e71680d070bd64bd5cc
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
index 94c9d3cb9a..86275a4025 100644
--- 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
@@ -2,17 +2,11 @@ $NetBSD$
 
 --- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig	2017-06-12 15:01:29.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_common_interceptors.inc
-@@ -3799,10 +3799,13 @@ INTERCEPTOR(int, pthread_mutex_lock, voi
+@@ -3799,6 +3799,7 @@ INTERCEPTOR(int, pthread_mutex_lock, voi
    COMMON_INTERCEPTOR_ENTER(ctx, pthread_mutex_lock, m);
    COMMON_INTERCEPTOR_MUTEX_PRE_LOCK(ctx, m);
    int res = REAL(pthread_mutex_lock)(m);
 +
-+#if !SANITIZER_NETBSD
    if (res == errno_EOWNERDEAD)
      COMMON_INTERCEPTOR_MUTEX_REPAIR(ctx, m);
    if (res == 0 || res == errno_EOWNERDEAD)
-     COMMON_INTERCEPTOR_MUTEX_POST_LOCK(ctx, m);
-+#endif
-   if (res == errno_EINVAL)
-     COMMON_INTERCEPTOR_MUTEX_INVALID(ctx, m);
-   return res;
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
new file mode 100644
index 0000000000..1f72a65e9b
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc
@@ -0,0 +1,229 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_platform_limits_posix.cc.orig	2017-06-03 23:53:57.000000000 +0000
++++ lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+@@ -14,7 +14,7 @@
+ 
+ #include "sanitizer_platform.h"
+ 
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
+ // Tests in this file assume that off_t-dependent data structures match the
+ // libc ABI. For example, struct dirent here is what readdir() function (as
+ // exported from libc) returns, and not the user-facing "dirent", which
+@@ -79,7 +79,7 @@
+ #include <net/if_arp.h>
+ #endif
+ 
+-#if SANITIZER_FREEBSD
++#if SANITIZER_FREEBSD || SANITIZER_NETBSD
+ # include <sys/mount.h>
+ # include <sys/sockio.h>
+ # include <sys/socket.h>
+@@ -94,16 +94,18 @@
+ # include <sys/statvfs.h>
+ # include <sys/soundcard.h>
+ # include <sys/mtio.h>
+-# include <sys/consio.h>
+-# include <sys/kbio.h>
+-# include <sys/link_elf.h>
+ # include <netinet/ip_mroute.h>
+ # include <netinet/in.h>
+-# include <net/ethernet.h>
+ # include <net/ppp_defs.h>
+ # include <glob.h>
+ # include <term.h>
++#endif
+ 
++#if SANITIZER_FREEBSD
++# include <sys/consio.h>
++# include <sys/kbio.h>
++# include <sys/link_elf.h>
++# include <net/ethernet.h>
+ #define _KERNEL  // to declare 'shminfo' structure
+ # include <sys/shm.h>
+ #undef _KERNEL
+@@ -111,11 +113,18 @@
+ #undef INLINE  // to avoid clashes with sanitizers' definitions
+ #endif
+ 
+-#if SANITIZER_FREEBSD || SANITIZER_IOS
++#if SANITIZER_NETBSD
++# include <sys/shm.h>
++# include <link_elf.h>
++# define statfs statvfs
++# define d_ino d_fileno 
++#endif
++
++#if SANITIZER_FREEBSD || SANITIZER_IOS || SANITIZER_NETBSD
+ #undef IOC_DIRMASK
+ #endif
+ 
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ # include <utime.h>
+ # include <sys/ptrace.h>
+ # if defined(__mips64) || defined(__aarch64__) || defined(__arm__)
+@@ -200,9 +209,9 @@ typedef struct user_fpregs elf_fpregset_
+ namespace __sanitizer {
+   unsigned struct_utsname_sz = sizeof(struct utsname);
+   unsigned struct_stat_sz = sizeof(struct stat);
+-#if !SANITIZER_IOS && !SANITIZER_FREEBSD
++#if !SANITIZER_IOS && !SANITIZER_FREEBSD  && !SANITIZER_NETBSD
+   unsigned struct_stat64_sz = sizeof(struct stat64);
+-#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD
++#endif // !SANITIZER_IOS && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+   unsigned struct_rusage_sz = sizeof(struct rusage);
+   unsigned struct_tm_sz = sizeof(struct tm);
+   unsigned struct_passwd_sz = sizeof(struct passwd);
+@@ -245,12 +254,12 @@ namespace __sanitizer {
+   unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname);
+ #endif // SANITIZER_LINUX
+ 
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+   unsigned struct_rlimit_sz = sizeof(struct rlimit);
+   unsigned struct_timespec_sz = sizeof(struct timespec);
+   unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
+   unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
+-#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
++#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+   unsigned struct_ustat_sz = sizeof(struct ustat);
+@@ -258,12 +267,12 @@ namespace __sanitizer {
+   unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+   unsigned struct_timex_sz = sizeof(struct timex);
+   unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);
+   unsigned struct_mq_attr_sz = sizeof(struct mq_attr);
+   unsigned struct_statvfs_sz = sizeof(struct statvfs);
+-#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#endif // (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+ 
+   uptr sig_ign = (uptr)SIG_IGN;
+   uptr sig_dfl = (uptr)SIG_DFL;
+@@ -310,7 +319,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
+ #endif
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+   int glob_nomatch = GLOB_NOMATCH;
+   int glob_altdirfunc = GLOB_ALTDIRFUNC;
+ #endif
+@@ -452,7 +461,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+   unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
+   unsigned struct_synth_info_sz = sizeof(struct synth_info);
+   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
+-#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
++#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ 
+ #if SANITIZER_LINUX && !SANITIZER_ANDROID
+   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
+@@ -479,7 +488,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+   unsigned struct_unimapinit_sz = sizeof(struct unimapinit);
+ #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+   unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
+   unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
+ #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
+@@ -535,7 +544,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(El
+   unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
+   unsigned IOCTL_TIOCSTI = TIOCSTI;
+   unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
+-#if ((SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID)
++#if ((SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID)
+   unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
+   unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
+ #endif
+@@ -975,7 +984,7 @@ COMPILER_CHECK(IOC_NR(0x12345678) == _IO
+ COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678));
+ #endif // SANITIZER_LINUX
+ 
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ // There are more undocumented fields in dl_phdr_info that we are not interested
+ // in.
+ COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
+@@ -983,9 +992,9 @@ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
+ CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
+-#endif // SANITIZER_LINUX || SANITIZER_FREEBSD
++#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+ CHECK_TYPE_SIZE(glob_t);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
+ CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
+@@ -1037,7 +1046,7 @@ COMPILER_CHECK(sizeof(__sanitizer_dirent
+ CHECK_SIZE_AND_OFFSET(dirent, d_ino);
+ #if SANITIZER_MAC
+ CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
+-#elif SANITIZER_FREEBSD
++#elif SANITIZER_FREEBSD || SANITIZER_NETBSD
+ // There is no 'd_off' field on FreeBSD.
+ #else
+ CHECK_SIZE_AND_OFFSET(dirent, d_off);
+@@ -1134,11 +1143,14 @@ CHECK_SIZE_AND_OFFSET(mntent, mnt_passno
+ 
+ CHECK_TYPE_SIZE(ether_addr);
+ 
+-#if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
++#if (SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD) && !SANITIZER_ANDROID
+ CHECK_TYPE_SIZE(ipc_perm);
+ # if SANITIZER_FREEBSD
+ CHECK_SIZE_AND_OFFSET(ipc_perm, key);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, seq);
++# elif SANITIZER_NETBSD
++CHECK_SIZE_AND_OFFSET(ipc_perm, _key);
++CHECK_SIZE_AND_OFFSET(ipc_perm, _seq);
+ # else
+ CHECK_SIZE_AND_OFFSET(ipc_perm, __key);
+ CHECK_SIZE_AND_OFFSET(ipc_perm, __seq);
+@@ -1175,20 +1187,20 @@ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next)
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr);
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask);
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ // Compare against the union, because we can't reach into the union in a
+ // compliant way.
+ #ifdef ifa_dstaddr
+ #undef ifa_dstaddr
+ #endif
+-# if SANITIZER_FREEBSD
++# if SANITIZER_FREEBSD || SANITIZER_NETBSD
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ # else
+ COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)nullptr)->ifa_dstaddr) ==
+                sizeof(((ifaddrs *)nullptr)->ifa_ifu));
+ COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) ==
+                offsetof(ifaddrs, ifa_ifu));
+-# endif // SANITIZER_FREEBSD
++# endif // SANITIZER_FREEBSD || SANITIZER_NETBSD
+ #else
+ CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
+ #endif // SANITIZER_LINUX
+@@ -1281,7 +1293,7 @@ CHECK_SIZE_AND_OFFSET(cookie_io_function
+ CHECK_SIZE_AND_OFFSET(cookie_io_functions_t, close);
+ #endif
+ 
+-#if SANITIZER_LINUX || SANITIZER_FREEBSD
++#if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_NETBSD
+ CHECK_TYPE_SIZE(sem_t);
+ #endif
+ 
+@@ -1289,4 +1301,4 @@ CHECK_TYPE_SIZE(sem_t);
+ COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN);
+ #endif
+ 
+-#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
++#endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC || SANITIZER_NETBSD
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
index e40d9c1386..faf93510d3 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h
@@ -327,7 +327,15 @@ $NetBSD$
  #endif
  
    // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
-@@ -631,7 +746,7 @@ namespace __sanitizer {
+@@ -624,14 +739,14 @@ namespace __sanitizer {
+   };
+ #else // !SANITIZER_ANDROID
+   struct __sanitizer_sigaction {
+-#if defined(__mips__) && !SANITIZER_FREEBSD
++#if defined(__mips__) && !SANITIZER_FREEBSD && !SANITIZER_NETBSD
+     unsigned int sa_flags;
+ #endif
+     union {
        void (*sigaction)(int sig, void *siginfo, void *uctx);
        void (*handler)(int sig);
      };
@@ -336,7 +344,15 @@ $NetBSD$
      int sa_flags;
      __sanitizer_sigset_t sa_mask;
  #else
-@@ -670,7 +785,7 @@ namespace __sanitizer {
+@@ -640,6 +755,7 @@ namespace __sanitizer {
+ #else
+     __sanitizer_sigset_t sa_mask;
+ #endif
++
+ #ifndef __mips__
+ #if defined(__sparc__)
+ #if __GLIBC_PREREQ (2, 20)
+@@ -670,7 +786,7 @@ namespace __sanitizer {
    };
  #endif // !SANITIZER_ANDROID
  
@@ -345,7 +361,7 @@ $NetBSD$
    typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
  #elif defined(__mips__)
    struct __sanitizer_kernel_sigset_t {
-@@ -717,7 +832,7 @@ namespace __sanitizer {
+@@ -717,7 +833,7 @@ namespace __sanitizer {
    extern int af_inet6;
    uptr __sanitizer_in_addr_sz(int af);
  
@@ -354,7 +370,7 @@ $NetBSD$
    struct __sanitizer_dl_phdr_info {
      uptr dlpi_addr;
      const char *dlpi_name;
-@@ -733,7 +848,7 @@ namespace __sanitizer {
+@@ -733,7 +849,7 @@ namespace __sanitizer {
      int ai_family;
      int ai_socktype;
      int ai_protocol;
@@ -363,7 +379,7 @@ $NetBSD$
      unsigned ai_addrlen;
      char *ai_canonname;
      void *ai_addr;
-@@ -759,7 +874,7 @@ namespace __sanitizer {
+@@ -759,7 +875,7 @@ namespace __sanitizer {
      short revents;
    };
  
@@ -372,7 +388,7 @@ $NetBSD$
    typedef unsigned __sanitizer_nfds_t;
  #else
    typedef unsigned long __sanitizer_nfds_t;
-@@ -779,7 +894,7 @@ namespace __sanitizer {
+@@ -779,7 +895,7 @@ namespace __sanitizer {
      int (*gl_lstat)(const char *, void *);
      int (*gl_stat)(const char *, void *);
    };
@@ -381,7 +397,7 @@ $NetBSD$
    struct __sanitizer_glob_t {
      uptr gl_pathc;
      uptr gl_matchc;
-@@ -793,9 +908,9 @@ namespace __sanitizer {
+@@ -793,9 +909,9 @@ namespace __sanitizer {
      int (*gl_lstat)(const char*, void* /* struct stat* */);
      int (*gl_stat)(const char*, void* /* struct stat* */);
    };
@@ -393,7 +409,7 @@ $NetBSD$
    extern int glob_nomatch;
    extern int glob_altdirfunc;
  # endif
-@@ -807,7 +922,7 @@ namespace __sanitizer {
+@@ -807,7 +923,7 @@ namespace __sanitizer {
      uptr we_wordc;
      char **we_wordv;
      uptr we_offs;
@@ -402,7 +418,7 @@ $NetBSD$
      char *we_strings;
      uptr we_nbytes;
  #endif
-@@ -832,6 +947,37 @@ namespace __sanitizer {
+@@ -832,6 +948,37 @@ namespace __sanitizer {
      int _fileno;
    };
  # define SANITIZER_HAS_STRUCT_FILE 1
@@ -440,7 +456,7 @@ $NetBSD$
  #else
    typedef void __sanitizer_FILE;
  # define SANITIZER_HAS_STRUCT_FILE 0
-@@ -873,6 +1019,10 @@ namespace __sanitizer {
+@@ -873,6 +1020,10 @@ namespace __sanitizer {
    extern int shmctl_shm_stat;
  #endif
  
@@ -451,7 +467,7 @@ $NetBSD$
  #if !SANITIZER_MAC && !SANITIZER_FREEBSD
    extern unsigned struct_utmp_sz;
  #endif
-@@ -923,6 +1073,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -923,6 +1074,7 @@ struct __sanitizer_cookie_io_functions_t
  };
  #endif
  
@@ -459,7 +475,7 @@ $NetBSD$
  #define IOC_NRBITS 8
  #define IOC_TYPEBITS 8
  #if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || \
-@@ -966,13 +1117,17 @@ struct __sanitizer_cookie_io_functions_t
+@@ -966,13 +1118,17 @@ struct __sanitizer_cookie_io_functions_t
  #else
  #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
  #endif
@@ -478,7 +494,7 @@ $NetBSD$
    extern unsigned struct_cdrom_msf_sz;
    extern unsigned struct_cdrom_multisession_sz;
    extern unsigned struct_cdrom_read_audio_sz;
-@@ -1006,6 +1161,9 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1006,6 +1162,9 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_copr_debug_buf_sz;
    extern unsigned struct_copr_msg_sz;
    extern unsigned struct_midi_info_sz;
@@ -488,7 +504,7 @@ $NetBSD$
    extern unsigned struct_mtget_sz;
    extern unsigned struct_mtop_sz;
    extern unsigned struct_rtentry_sz;
-@@ -1013,7 +1171,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1013,7 +1172,7 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_seq_event_rec_sz;
    extern unsigned struct_synth_info_sz;
    extern unsigned struct_vt_mode_sz;
@@ -497,7 +513,7 @@ $NetBSD$
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    extern unsigned struct_ax25_parms_struct_sz;
-@@ -1035,10 +1193,10 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1035,10 +1194,10 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned struct_unimapinit_sz;
  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
  
@@ -510,7 +526,7 @@ $NetBSD$
  
  #if !SANITIZER_ANDROID && !SANITIZER_MAC
    extern unsigned struct_sioc_sg_req_sz;
-@@ -1095,7 +1253,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1095,7 +1254,7 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_TIOCSPGRP;
    extern unsigned IOCTL_TIOCSTI;
    extern unsigned IOCTL_TIOCSWINSZ;
@@ -519,7 +535,7 @@ $NetBSD$
    extern unsigned IOCTL_SIOCGETSGCNT;
    extern unsigned IOCTL_SIOCGETVIFCNT;
  #endif
-@@ -1258,10 +1416,10 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1258,10 +1417,10 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_VT_RESIZEX;
    extern unsigned IOCTL_VT_SENDSIG;
  #endif  // SANITIZER_LINUX
@@ -532,7 +548,7 @@ $NetBSD$
    extern unsigned IOCTL_SIOCDELRT;
    extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
    extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
-@@ -1359,7 +1517,7 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1359,7 +1518,7 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_VT_RELDISP;
    extern unsigned IOCTL_VT_SETMODE;
    extern unsigned IOCTL_VT_WAITACTIVE;
@@ -541,7 +557,7 @@ $NetBSD$
  
  #if SANITIZER_LINUX && !SANITIZER_ANDROID
    extern unsigned IOCTL_CYGETDEFTHRESH;
-@@ -1448,24 +1606,32 @@ struct __sanitizer_cookie_io_functions_t
+@@ -1448,21 +1607,27 @@ struct __sanitizer_cookie_io_functions_t
    extern unsigned IOCTL_TIOCSSERIAL;
  #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
  
@@ -569,9 +585,4 @@ $NetBSD$
 +#endif
  
    extern const int errno_EINVAL;
-+#if !SANITIZER_NETBSD
    extern const int errno_EOWNERDEAD;
-+#endif
- 
-   extern const int si_SEGV_MAPERR;
-   extern const int si_SEGV_ACCERR;
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
new file mode 100644
index 0000000000..5aeb0bc1f4
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__common.cc
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_procmaps_common.cc.orig	2017-06-03 23:53:58.000000000 +0000
++++ lib/sanitizer_common/sanitizer_procmaps_common.cc
+@@ -12,7 +12,7 @@
+ 
+ #include "sanitizer_platform.h"
+ 
+-#if SANITIZER_FREEBSD || SANITIZER_LINUX
++#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
+ 
+ #include "sanitizer_common.h"
+ #include "sanitizer_placement_new.h"
+@@ -173,4 +173,4 @@ void GetMemoryProfile(fill_profile_f cb,
+ 
+ } // namespace __sanitizer
+ 
+-#endif // SANITIZER_FREEBSD || SANITIZER_LINUX
++#endif // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
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
index 0daf6aee26..90f7ca81b1 100644
--- a/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_tsan_rtl_tsan__interceptors.cc
@@ -35,11 +35,13 @@ $NetBSD$
  const int PTHREAD_MUTEX_RECURSIVE = 1;
  const int PTHREAD_MUTEX_RECURSIVE_NP = 1;
  #else
-@@ -100,8 +112,10 @@ const int PTHREAD_MUTEX_RECURSIVE_NP = 2
+@@ -100,8 +112,12 @@ const int PTHREAD_MUTEX_RECURSIVE_NP = 2
  #endif
  const int EINVAL = 22;
  const int EBUSY = 16;
-+#if !SANITIZER_NETBSD
++#if SANITIZER_NETBSD
++const int EOWNERDEAD = -1;
++#else
  const int EOWNERDEAD = 130;
 -#if !SANITIZER_FREEBSD && !SANITIZER_MAC
 +#endif
@@ -47,7 +49,7 @@ $NetBSD$
  const int EPOLL_CTL_ADD = 1;
  #endif
  const int SIGILL = 4;
-@@ -110,7 +124,7 @@ const int SIGFPE = 8;
+@@ -110,7 +126,7 @@ const int SIGFPE = 8;
  const int SIGSEGV = 11;
  const int SIGPIPE = 13;
  const int SIGTERM = 15;
@@ -56,7 +58,7 @@ $NetBSD$
  const int SIGBUS = 10;
  const int SIGSYS = 12;
  #else
-@@ -154,7 +168,7 @@ struct sigaction_t {
+@@ -154,7 +170,7 @@ struct sigaction_t {
      sighandler_t sa_handler;
      sigactionhandler_t sa_sigaction;
    };
@@ -65,7 +67,7 @@ $NetBSD$
    int sa_flags;
    __sanitizer_sigset_t sa_mask;
  #elif SANITIZER_MAC
-@@ -173,7 +187,7 @@ struct sigaction_t {
+@@ -173,7 +189,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;
@@ -74,7 +76,7 @@ $NetBSD$
  const int SA_SIGINFO = 0x40;
  const int SIG_SETMASK = 3;
  #elif defined(__mips__)
-@@ -289,7 +303,7 @@ void ScopedInterceptor::DisableIgnores()
+@@ -289,7 +305,7 @@ void ScopedInterceptor::DisableIgnores()
  }
  
  #define TSAN_INTERCEPT(func) INTERCEPT_FUNCTION(func)
@@ -83,7 +85,7 @@ $NetBSD$
  # define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION(func)
  #else
  # define TSAN_INTERCEPT_VER(func, ver) INTERCEPT_FUNCTION_VER(func, ver)
-@@ -466,7 +480,7 @@ static void SetJmp(ThreadState *thr, upt
+@@ -466,7 +482,7 @@ static void SetJmp(ThreadState *thr, upt
  static void LongJmp(ThreadState *thr, uptr *env) {
  #ifdef __powerpc__
    uptr mangled_sp = env[0];
@@ -92,30 +94,7 @@ $NetBSD$
    uptr mangled_sp = env[2];
  #elif defined(SANITIZER_LINUX)
  # ifdef __aarch64__
-@@ -1045,7 +1059,9 @@ static int cond_wait(ThreadState *thr, u
-     res = call_pthread_cancel_with_cleanup(
-         fn, c, m, t, (void (*)(void *arg))cond_mutex_unlock, &arg);
-   }
-+#if !SANITIZER_NETBSD
-   if (res == errno_EOWNERDEAD) MutexRepair(thr, pc, (uptr)m);
-+#endif
-   MutexPostLock(thr, pc, (uptr)m, MutexFlagDoPreLockOnPostLock);
-   return res;
- }
-@@ -1131,10 +1147,12 @@ TSAN_INTERCEPTOR(int, pthread_mutex_dest
- TSAN_INTERCEPTOR(int, pthread_mutex_trylock, void *m) {
-   SCOPED_TSAN_INTERCEPTOR(pthread_mutex_trylock, m);
-   int res = REAL(pthread_mutex_trylock)(m);
-+#if !SANITIZER_NETBSD
-   if (res == EOWNERDEAD)
-     MutexRepair(thr, pc, (uptr)m);
-   if (res == 0 || res == EOWNERDEAD)
-     MutexPostLock(thr, pc, (uptr)m, MutexFlagTryLock);
-+#endif
-   return res;
- }
- 
-@@ -1348,7 +1366,7 @@ TSAN_INTERCEPTOR(int, __fxstat, int vers
+@@ -1348,7 +1364,7 @@ TSAN_INTERCEPTOR(int, __fxstat, int vers
  #endif
  
  TSAN_INTERCEPTOR(int, fstat, int fd, void *buf) {
@@ -124,7 +103,7 @@ $NetBSD$
    SCOPED_TSAN_INTERCEPTOR(fstat, fd, buf);
    if (fd > 0)
      FdAccess(thr, pc, fd);
-@@ -1929,7 +1947,7 @@ TSAN_INTERCEPTOR(int, sigaction, int sig
+@@ -1929,7 +1945,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));
@@ -133,7 +112,7 @@ $NetBSD$
    sigactions[sig].sa_restorer = act->sa_restorer;
  #endif
    sigaction_t newact;
-@@ -2291,7 +2309,7 @@ struct ScopedSyscall {
+@@ -2291,7 +2307,7 @@ struct ScopedSyscall {
    }
  };
  
@@ -142,7 +121,7 @@ $NetBSD$
  static void syscall_access_range(uptr pc, uptr p, uptr s, bool write) {
    TSAN_SYSCALL();
    MemoryAccessRange(thr, pc, p, s, write);
-@@ -2571,7 +2589,9 @@ void InitializeInterceptors() {
+@@ -2571,7 +2587,9 @@ void InitializeInterceptors() {
  #endif
    TSAN_INTERCEPT(on_exit);
    TSAN_INTERCEPT(__cxa_atexit);


Home | Main Index | Thread Index | Old Index