Source-Changes-HG archive

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

[src/trunk]: src/external/gpl3/gcc/dist/libsanitizer First steps to port this...



details:   https://anonhg.NetBSD.org/src/rev/f22d40d7ebab
branches:  trunk
changeset: 345538:f22d40d7ebab
user:      christos <christos%NetBSD.org@localhost>
date:      Tue May 31 20:47:25 2016 +0000

description:
First steps to port this to NetBSD (compiles now but missing stuff)

diffstat:

 external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.h                            |    2 +-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc                                  |   13 +
 external/gpl3/gcc/dist/libsanitizer/asan/asan_mapping.h                                 |    4 +-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_stack.h                                   |    2 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common.h                 |    2 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc  |    2 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h          |    6 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_libignore.cc             |    4 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc                 |   34 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h                  |    4 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc         |   22 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform.h               |   10 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h  |   14 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc |   39 ++-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h  |  101 +++++++--
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_procmaps_common.cc       |    4 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc      |   14 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_unwind_posix_libcdep.cc  |    2 +-
 external/gpl3/gcc/dist/libsanitizer/tsan/tsan_interceptors.cc                           |   66 +++---
 external/gpl3/gcc/dist/libsanitizer/ubsan/ubsan_value.h                                 |    2 +-
 20 files changed, 220 insertions(+), 127 deletions(-)

diffs (truncated from 1297 to 300 lines):

diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.h
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.h      Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_interceptors.h      Tue May 31 20:47:25 2016 +0000
@@ -34,7 +34,7 @@
 # define ASAN_INTERCEPT_FORK 0
 #endif
 
-#if SANITIZER_FREEBSD || SANITIZER_LINUX
+#if SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
 #else
 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc    Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc    Tue May 31 20:47:25 2016 +0000
@@ -37,6 +37,10 @@
 #if SANITIZER_FREEBSD
 #include <sys/link_elf.h>
 #endif
+#if SANITIZER_NETBSD
+#include <link_elf.h>
+extern Elf_Dyn  _DYNAMIC;
+#endif
 
 #if SANITIZER_ANDROID || SANITIZER_FREEBSD
 #include <ucontext.h>
@@ -207,6 +211,10 @@
   *pc = ucontext->uc_mcontext.mc_rip;
   *bp = ucontext->uc_mcontext.mc_rbp;
   *sp = ucontext->uc_mcontext.mc_rsp;
+# elif SANITIZER_NETBSD
+  *pc = ucontext->uc_mcontext.__gregs[_REG_RIP];
+  *bp = ucontext->uc_mcontext.__gregs[_REG_RBP];
+  *sp = ucontext->uc_mcontext.__gregs[_REG_RSP];
 # else
   ucontext_t *ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.gregs[REG_RIP];
@@ -219,6 +227,11 @@
   *pc = ucontext->uc_mcontext.mc_eip;
   *bp = ucontext->uc_mcontext.mc_ebp;
   *sp = ucontext->uc_mcontext.mc_esp;
+# elif SANITIZER_FREEBSD
+  ucontext_t *ucontext = (ucontext_t*)context;
+  *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 -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/asan/asan_mapping.h
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_mapping.h   Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_mapping.h   Tue May 31 20:47:25 2016 +0000
@@ -97,7 +97,7 @@
 # if SANITIZER_WORDSIZE == 32
 #  if defined(__mips__)
 #    define SHADOW_OFFSET kMIPS32_ShadowOffset32
-#  elif SANITIZER_FREEBSD
+#  elif SANITIZER_FREEBSD || SANITIZER_NETBSD
 #    define SHADOW_OFFSET kFreeBSD_ShadowOffset32
 #  else
 #    if SANITIZER_IOS
@@ -111,7 +111,7 @@
 #    define SHADOW_OFFSET kAArch64_ShadowOffset64
 #  elif defined(__powerpc64__)
 #    define SHADOW_OFFSET kPPC64_ShadowOffset64
-#  elif SANITIZER_FREEBSD
+#  elif SANITIZER_FREEBSD || SANITIZER_NETBSD
 #    define SHADOW_OFFSET kFreeBSD_ShadowOffset64
 #  elif SANITIZER_MAC
 #   define SHADOW_OFFSET kDefaultShadowOffset64
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/asan/asan_stack.h
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_stack.h     Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_stack.h     Tue May 31 20:47:25 2016 +0000
@@ -36,7 +36,7 @@
       // On FreeBSD the slow unwinding that leverages _Unwind_Backtrace()
       // yields the call stack of the signal's handler and not of the code
       // that raised the signal (as it does on Linux).
-      if (SANITIZER_FREEBSD && t->isInDeadlySignal()) fast = true;
+      if ((SANITIZER_NETBSD || SANITIZER_FREEBSD) && t->isInDeadlySignal()) fast = true;
       uptr stack_top = t->stack_top();
       uptr stack_bottom = t->stack_bottom();
       ScopedUnwinding unwind_scope(t);
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common.h
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common.h   Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common.h   Tue May 31 20:47:25 2016 +0000
@@ -521,7 +521,7 @@
 // Callback type for iterating over a set of memory ranges.
 typedef void (*RangeIteratorCallback)(uptr begin, uptr end, void *arg);
 
-#if (SANITIZER_FREEBSD || SANITIZER_LINUX) && !defined(SANITIZER_GO)
+#if (SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX) && !defined(SANITIZER_GO)
 extern uptr indirect_call_wrapper;
 void SetIndirectCallWrapper(uptr wrapper);
 
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc    Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc    Tue May 31 20:47:25 2016 +0000
@@ -39,7 +39,7 @@
 #define va_copy(dst, src) ((dst) = (src))
 #endif // _WIN32
 
-#if SANITIZER_FREEBSD
+#if SANITIZER_BSD
 #define pthread_setname_np pthread_set_name_np
 #endif
 
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h    Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h    Tue May 31 20:47:25 2016 +0000
@@ -154,11 +154,7 @@
 # define UNLIKELY(x) (x)
 # define PREFETCH(x) /* _mm_prefetch(x, _MM_HINT_NTA) */
 #else  // _MSC_VER
-# ifdef __NetBSD__
-#  define ALWAYS_INLINE // inline __attribute__((always_inline))
-# else
-#  define ALWAYS_INLINE inline __attribute__((always_inline))
-# endif
+# define ALWAYS_INLINE inline __attribute__((always_inline))
 # define ALIAS(x) __attribute__((alias(x)))
 // Please only use the ALIGNED macro before the type.
 // Using ALIGNED after the variable declaration is not portable!
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_libignore.cc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_libignore.cc       Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_libignore.cc       Tue May 31 20:47:25 2016 +0000
@@ -6,7 +6,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "sanitizer_platform.h"
-#if SANITIZER_FREEBSD || SANITIZER_LINUX
+#if SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX
 
 #include "sanitizer_libignore.h"
 #include "sanitizer_flags.h"
@@ -101,4 +101,4 @@
 
 }  // namespace __sanitizer
 
-#endif  // #if SANITIZER_FREEBSD || SANITIZER_LINUX
+#endif  // #if SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc   Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc   Tue May 31 20:47:25 2016 +0000
@@ -11,7 +11,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "sanitizer_platform.h"
-#if SANITIZER_FREEBSD || SANITIZER_LINUX
+#if SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX
 
 #include "sanitizer_common.h"
 #include "sanitizer_flags.h"
@@ -24,7 +24,7 @@
 #include "sanitizer_stacktrace.h"
 #include "sanitizer_symbolizer.h"
 
-#if !SANITIZER_FREEBSD
+#if !SANITIZER_FREEBSD && !SANITIZER_NETBSD
 #include <asm/param.h>
 #endif
 
@@ -55,6 +55,10 @@
 }
 extern char **environ;  // provided by crt1
 #endif  // SANITIZER_FREEBSD
+#if SANITIZER_NETBSD
+#include <sys/sysctl.h>
+extern char **environ;  // provided by crt1
+#endif  // SANITIZER_NETBSD
 
 #if !SANITIZER_ANDROID
 #include <sys/signal.h>
@@ -97,7 +101,7 @@
 // --------------- sanitizer_libc.h
 uptr internal_mmap(void *addr, uptr length, int prot, int flags,
                     int fd, u64 offset) {
-#if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
+#if SANITIZER_NETBSD || SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
   return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
                           offset);
 #else
@@ -156,7 +160,7 @@
   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;
@@ -177,7 +181,7 @@
 #endif
 
 uptr internal_stat(const char *path, void *buf) {
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
   return internal_syscall(SYSCALL(stat), path, buf);
 #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
   return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
@@ -193,7 +197,7 @@
 }
 
 uptr internal_lstat(const char *path, void *buf) {
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
   return internal_syscall(SYSCALL(lstat), path, buf);
 #elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
   return internal_syscall(SYSCALL(newfstatat), AT_FDCWD, (uptr)path,
@@ -209,7 +213,7 @@
 }
 
 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
   return internal_syscall(SYSCALL(fstat), fd, (uptr)buf);
 #else
   struct stat64 buf64;
@@ -265,7 +269,7 @@
 }
 
 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);
@@ -293,7 +297,7 @@
 }
 
 uptr GetTid() {
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
   return (uptr)pthread_self();
 #else
   return internal_syscall(SYSCALL(gettid));
@@ -301,7 +305,7 @@
 }
 
 u64 NanoTime() {
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
   timeval tv;
 #else
   kernel_timeval tv;
@@ -315,7 +319,7 @@
 // '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++) {
@@ -416,6 +420,7 @@
 }
 #endif  // SANITIZER_GO
 
+#if !SANITIZER_NETBSD
 enum MutexState {
   MtxUnlocked = 0,
   MtxLocked = 1,
@@ -460,6 +465,7 @@
   atomic_uint32_t *m = reinterpret_cast<atomic_uint32_t *>(&opaque_storage_);
   CHECK_NE(MtxUnlocked, atomic_load(m, memory_order_relaxed));
 }
+#endif // !SANITIZER_NETBSD
 
 // ----------------- sanitizer_linux.h
 // The actual size of this structure is specified by d_reclen.
@@ -571,7 +577,7 @@
 
 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;
@@ -685,7 +691,7 @@
     CHECK_LT(module_name_len, buf_len);
     return module_name_len;
   }
-#if SANITIZER_FREEBSD
+#if SANITIZER_FREEBSD || SANITIZER_NETBSD
   const int Mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
   size_t Size = buf_len;
   bool IsErr = (sysctl(Mib, 4, buf, &Size, NULL, 0) != 0);
@@ -871,4 +877,4 @@
 
 }  // namespace __sanitizer
 
-#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX
+#endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD
diff -r b4e73a38c661 -r f22d40d7ebab external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h    Tue May 31 20:40:51 2016 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h    Tue May 31 20:47:25 2016 +0000
@@ -12,7 +12,7 @@
 #define SANITIZER_LINUX_H
 
 #include "sanitizer_platform.h"



Home | Main Index | Thread Index | Old Index