PR c++/82357 - bit-field in template
[official-gcc.git] / libsanitizer / asan / asan_interceptors.h
blob7053bb7faf51913a18b590e10278993528ae2b71
1 //===-- asan_interceptors.h -------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // ASan-private header for asan_interceptors.cc
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_INTERCEPTORS_H
13 #define ASAN_INTERCEPTORS_H
15 #include "asan_internal.h"
16 #include "interception/interception.h"
17 #include "sanitizer_common/sanitizer_platform_interceptors.h"
19 // Use macro to describe if specific function should be
20 // intercepted on a given platform.
21 #if !SANITIZER_WINDOWS
22 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 1
23 # define ASAN_INTERCEPT__LONGJMP 1
24 # define ASAN_INTERCEPT_INDEX 1
25 # define ASAN_INTERCEPT_PTHREAD_CREATE 1
26 # define ASAN_INTERCEPT_FORK 1
27 #else
28 # define ASAN_INTERCEPT_ATOLL_AND_STRTOLL 0
29 # define ASAN_INTERCEPT__LONGJMP 0
30 # define ASAN_INTERCEPT_INDEX 0
31 # define ASAN_INTERCEPT_PTHREAD_CREATE 0
32 # define ASAN_INTERCEPT_FORK 0
33 #endif
35 #if SANITIZER_FREEBSD || SANITIZER_LINUX
36 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1
37 #else
38 # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0
39 #endif
41 #if SANITIZER_LINUX && !SANITIZER_ANDROID
42 # define ASAN_INTERCEPT_SWAPCONTEXT 1
43 #else
44 # define ASAN_INTERCEPT_SWAPCONTEXT 0
45 #endif
47 #if !SANITIZER_WINDOWS
48 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 1
49 #else
50 # define ASAN_INTERCEPT_SIGNAL_AND_SIGACTION 0
51 #endif
53 #if !SANITIZER_WINDOWS
54 # define ASAN_INTERCEPT_SIGLONGJMP 1
55 #else
56 # define ASAN_INTERCEPT_SIGLONGJMP 0
57 #endif
59 // Android bug: https://code.google.com/p/android/issues/detail?id=61799
60 #if ASAN_HAS_EXCEPTIONS && !SANITIZER_WINDOWS && \
61 !(SANITIZER_ANDROID && defined(__i386))
62 # define ASAN_INTERCEPT___CXA_THROW 1
63 #else
64 # define ASAN_INTERCEPT___CXA_THROW 0
65 #endif
67 #if !SANITIZER_WINDOWS
68 # define ASAN_INTERCEPT___CXA_ATEXIT 1
69 #else
70 # define ASAN_INTERCEPT___CXA_ATEXIT 0
71 #endif
73 #if SANITIZER_LINUX && !SANITIZER_ANDROID
74 # define ASAN_INTERCEPT___STRDUP 1
75 #else
76 # define ASAN_INTERCEPT___STRDUP 0
77 #endif
79 DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size)
80 DECLARE_REAL(void*, memcpy, void *to, const void *from, uptr size)
81 DECLARE_REAL(void*, memset, void *block, int c, uptr size)
82 DECLARE_REAL(char*, strchr, const char *str, int c)
83 DECLARE_REAL(SIZE_T, strlen, const char *s)
84 DECLARE_REAL(char*, strncpy, char *to, const char *from, uptr size)
85 DECLARE_REAL(uptr, strnlen, const char *s, uptr maxlen)
86 DECLARE_REAL(char*, strstr, const char *s1, const char *s2)
87 struct sigaction;
88 DECLARE_REAL(int, sigaction, int signum, const struct sigaction *act,
89 struct sigaction *oldact)
91 #if !SANITIZER_MAC
92 #define ASAN_INTERCEPT_FUNC(name) \
93 do { \
94 if ((!INTERCEPT_FUNCTION(name) || !REAL(name))) \
95 VReport(1, "AddressSanitizer: failed to intercept '" #name "'\n"); \
96 } while (0)
97 #define ASAN_INTERCEPT_FUNC_VER(name, ver) \
98 do { \
99 if ((!INTERCEPT_FUNCTION_VER(name, ver) || !REAL(name))) \
100 VReport( \
101 1, "AddressSanitizer: failed to intercept '" #name "@@" #ver "'\n"); \
102 } while (0)
103 #else
104 // OS X interceptors don't need to be initialized with INTERCEPT_FUNCTION.
105 #define ASAN_INTERCEPT_FUNC(name)
106 #endif // SANITIZER_MAC
108 namespace __asan {
110 void InitializeAsanInterceptors();
111 void InitializePlatformInterceptors();
113 #define ENSURE_ASAN_INITED() do { \
114 CHECK(!asan_init_is_running); \
115 if (UNLIKELY(!asan_inited)) { \
116 AsanInitFromRtl(); \
118 } while (0)
120 } // namespace __asan
122 #endif // ASAN_INTERCEPTORS_H