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 make this compile, prete...



details:   https://anonhg.NetBSD.org/src/rev/27fbbfbfeb51
branches:  trunk
changeset: 333037:27fbbfbfeb51
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Oct 15 18:44:49 2014 +0000

description:
make this compile, pretending a lot that we are linux.

diffstat:

 external/gpl3/gcc/dist/libsanitizer/asan/asan_intercepted_functions.h                  |   4 +-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_internal.h                               |   4 +-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc                                 |  12 ++++-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_malloc_linux.cc                          |   4 +-
 external/gpl3/gcc/dist/libsanitizer/asan/asan_posix.cc                                 |   4 +-
 external/gpl3/gcc/dist/libsanitizer/interception/interception.h                        |   6 +-
 external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.cc                 |   4 +-
 external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.h                  |   4 +-
 external/gpl3/gcc/dist/libsanitizer/interception/interception_type_test.cc             |   4 +-
 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc |  25 ++++++---
 10 files changed, 44 insertions(+), 27 deletions(-)

diffs (252 lines):

diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/asan/asan_intercepted_functions.h
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_intercepted_functions.h     Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_intercepted_functions.h     Wed Oct 15 18:44:49 2014 +0000
@@ -41,7 +41,7 @@
 # define ASAN_INTERCEPT_MLOCKX 0
 #endif
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
 #else
 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
@@ -53,7 +53,7 @@
 # define ASAN_INTERCEPT_STRNLEN 0
 #endif
 
-#if defined(__linux__) && !defined(ANDROID)
+#if (defined(__linux__) || defined(__NetBSD__)) && !defined(ANDROID) 
 # define ASAN_INTERCEPT_SWAPCONTEXT 1
 #else
 # define ASAN_INTERCEPT_SWAPCONTEXT 0
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/asan/asan_internal.h
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_internal.h  Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_internal.h  Wed Oct 15 18:44:49 2014 +0000
@@ -19,13 +19,13 @@
 #include "sanitizer_common/sanitizer_stacktrace.h"
 #include "sanitizer_common/sanitizer_libc.h"
 
-#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
+#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__NetBSD__)
 # error "This operating system is not supported by AddressSanitizer"
 #endif
 
 #define ASAN_DEFAULT_FAILURE_EXITCODE 1
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
 # define ASAN_LINUX   1
 #else
 # define ASAN_LINUX   0
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc    Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_linux.cc    Wed Oct 15 18:44:49 2014 +0000
@@ -9,7 +9,7 @@
 //
 // Linux-specific details.
 //===----------------------------------------------------------------------===//
-#ifdef __linux__
+#if defined(__linux__) || defined(__NetBSD__)
 
 #include "asan_interceptors.h"
 #include "asan_internal.h"
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <pthread.h>
+#include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <unwind.h>
@@ -47,6 +48,13 @@
   return &_DYNAMIC;  // defined in link.h
 }
 
+#ifdef __NetBSD__
+#define gregs __gregs
+#define REG_RIP _REG_RIP
+#define REG_RBP _REG_RBP
+#define REG_RSP _REG_RSP
+#endif
+
 void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
 #if ASAN_ANDROID
   *pc = *sp = *bp = 0;
@@ -131,4 +139,4 @@
 
 }  // namespace __asan
 
-#endif  // __linux__
+#endif  // __linux__ || __NetBSD__
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/asan/asan_malloc_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_malloc_linux.cc     Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_malloc_linux.cc     Wed Oct 15 18:44:49 2014 +0000
@@ -11,7 +11,7 @@
 // We simply define functions like malloc, free, realloc, etc.
 // They will replace the corresponding libc functions automagically.
 //===----------------------------------------------------------------------===//
-#ifdef __linux__
+#if defined(__linux__) || defined(__NetBSD__)
 
 #include "asan_allocator.h"
 #include "asan_interceptors.h"
@@ -144,4 +144,4 @@
   __asan_print_accumulated_stats();
 }
 
-#endif  // __linux__
+#endif  // __linux__ || __NetBSD__
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/asan/asan_posix.cc
--- a/external/gpl3/gcc/dist/libsanitizer/asan/asan_posix.cc    Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/asan/asan_posix.cc    Wed Oct 15 18:44:49 2014 +0000
@@ -9,7 +9,7 @@
 //
 // Posix-specific details.
 //===----------------------------------------------------------------------===//
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__)
 
 #include "asan_internal.h"
 #include "asan_interceptors.h"
@@ -115,4 +115,4 @@
 
 }  // namespace __asan
 
-#endif  // __linux__ || __APPLE_
+#endif  // __linux__ || __APPLE_ || __NetBSD__
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/interception/interception.h
--- a/external/gpl3/gcc/dist/libsanitizer/interception/interception.h   Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/interception/interception.h   Wed Oct 15 18:44:49 2014 +0000
@@ -13,7 +13,7 @@
 #ifndef INTERCEPTION_H
 #define INTERCEPTION_H
 
-#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32)
+#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__NetBSD__)
 # error "Interception doesn't work on this operating system."
 #endif
 
@@ -29,7 +29,7 @@
 // _FILE_OFFSET_BITS. This definition of OFF_T matches the ABI of system calls
 // like pread and mmap, as opposed to pread64 and mmap64.
 // Mac and Linux/x86-64 are special.
-#if defined(__APPLE__) || (defined(__linux__) && defined(__x86_64__))
+#if defined(__APPLE__) || (defined(__linux__) && defined(__x86_64__)) || defined(__NetBSD__)
 typedef __sanitizer::u64 OFF_T;
 #else
 typedef __sanitizer::uptr OFF_T;
@@ -176,7 +176,7 @@
 
 #define INCLUDED_FROM_INTERCEPTION_LIB
 
-#if defined(__linux__)
+#if defined(__linux__) || defined(__NetBSD__)
 # include "interception_linux.h"
 # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX(func)
 #elif defined(__APPLE__)
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.cc
--- a/external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.cc    Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.cc    Wed Oct 15 18:44:49 2014 +0000
@@ -10,7 +10,7 @@
 // Linux-specific interception methods.
 //===----------------------------------------------------------------------===//
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__NetBSD__)
 #include "interception.h"
 
 #include <stddef.h>  // for NULL
@@ -25,4 +25,4 @@
 }  // namespace __interception
 
 
-#endif  // __linux__
+#endif  // __linux__ || __NetBSD__
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.h
--- a/external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.h     Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/interception/interception_linux.h     Wed Oct 15 18:44:49 2014 +0000
@@ -10,7 +10,7 @@
 // Linux-specific interception methods.
 //===----------------------------------------------------------------------===//
 
-#ifdef __linux__
+#if defined(__linux__) || defined(__NetBSD__)
 
 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
 # error "interception_linux.h should be included from interception library only"
@@ -32,4 +32,4 @@
           (::__interception::uptr)&WRAP(func))
 
 #endif  // INTERCEPTION_LINUX_H
-#endif  // __linux__
+#endif  // __linux__ || __NetBSD__
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/interception/interception_type_test.cc
--- a/external/gpl3/gcc/dist/libsanitizer/interception/interception_type_test.cc        Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/interception/interception_type_test.cc        Wed Oct 15 18:44:49 2014 +0000
@@ -10,7 +10,7 @@
 // Compile-time tests of the internal type definitions.
 //===----------------------------------------------------------------------===//
 
-#if defined(__linux__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__)
 
 #include "interception.h"
 #include <sys/types.h>
@@ -22,7 +22,7 @@
 COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t));
 COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t));
 
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__NetBSD__)
 COMPILER_CHECK(sizeof(OFF64_T) == sizeof(off64_t));
 #endif
 
diff -r 53c9d1f00d98 -r 27fbbfbfeb51 external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
--- a/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc    Wed Oct 15 15:13:45 2014 +0000
+++ b/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc    Wed Oct 15 18:44:49 2014 +0000
@@ -296,6 +296,14 @@
 INTERCEPTOR(int, sscanf, const char *str, const char *format, ...)
 SCANF_INTERCEPTOR_IMPL(sscanf, vsscanf, str, format)
 
+#define INIT_SCANF_NORMAL                                                      \
+  INTERCEPT_FUNCTION(scanf);                                                   \
+  INTERCEPT_FUNCTION(sscanf);                                                  \
+  INTERCEPT_FUNCTION(fscanf);                                                  \
+  INTERCEPT_FUNCTION(vscanf);                                                  \
+  INTERCEPT_FUNCTION(vsscanf);                                                 \
+  INTERCEPT_FUNCTION(vfscanf);                                                 \
+
 #if SANITIZER_INTERCEPT_ISOC99_SCANF
 INTERCEPTOR(int, __isoc99_scanf, const char *format, ...)
 SCANF_INTERCEPTOR_IMPL(__isoc99_scanf, __isoc99_vscanf, format)
@@ -305,21 +313,22 @@
 
 INTERCEPTOR(int, __isoc99_sscanf, const char *str, const char *format, ...)
 SCANF_INTERCEPTOR_IMPL(__isoc99_sscanf, __isoc99_vsscanf, str, format)
-#endif
+
 
-#define INIT_SCANF                                                             \
-  INTERCEPT_FUNCTION(scanf);                                                   \
-  INTERCEPT_FUNCTION(sscanf);                                                  \
-  INTERCEPT_FUNCTION(fscanf);                                                  \
-  INTERCEPT_FUNCTION(vscanf);                                                  \
-  INTERCEPT_FUNCTION(vsscanf);                                                 \
-  INTERCEPT_FUNCTION(vfscanf);                                                 \
+#define INIT_SCANF_ISOC99                                                     \
   INTERCEPT_FUNCTION(__isoc99_scanf);                                          \
   INTERCEPT_FUNCTION(__isoc99_sscanf);                                         \
   INTERCEPT_FUNCTION(__isoc99_fscanf);                                         \
   INTERCEPT_FUNCTION(__isoc99_vscanf);                                         \
   INTERCEPT_FUNCTION(__isoc99_vsscanf);                                        \
   INTERCEPT_FUNCTION(__isoc99_vfscanf);
+#else
+#define INIT_SCANF_ISOC99
+#endif
+
+#define INIT_SCANF                                                            \
+  INIT_SCANF_NORMAL                                                           \
+  INIT_SCANF_ISOC99
 
 #else
 #define INIT_SCANF



Home | Main Index | Thread Index | Old Index