[ARM 4/5 big.LITTLE] Add support for -mcpu=cortex-a57
[official-gcc.git] / libsanitizer / asan / asan_internal.h
blobede273a71701b7efe7b8e50a47a484f084a6254c
1 //===-- asan_internal.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 which defines various general utilities.
11 //===----------------------------------------------------------------------===//
12 #ifndef ASAN_INTERNAL_H
13 #define ASAN_INTERNAL_H
15 #include "asan_flags.h"
16 #include "asan_interface_internal.h"
17 #include "sanitizer_common/sanitizer_common.h"
18 #include "sanitizer_common/sanitizer_internal_defs.h"
19 #include "sanitizer_common/sanitizer_stacktrace.h"
20 #include "sanitizer_common/sanitizer_libc.h"
22 #define ASAN_DEFAULT_FAILURE_EXITCODE 1
24 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
25 # error "The AddressSanitizer run-time should not be"
26 " instrumented by AddressSanitizer"
27 #endif
29 // Build-time configuration options.
31 // If set, asan will install its own SEGV signal handler.
32 #ifndef ASAN_NEEDS_SEGV
33 # if SANITIZER_ANDROID == 1
34 # define ASAN_NEEDS_SEGV 0
35 # else
36 # define ASAN_NEEDS_SEGV 1
37 # endif
38 #endif
40 // If set, asan will intercept C++ exception api call(s).
41 #ifndef ASAN_HAS_EXCEPTIONS
42 # define ASAN_HAS_EXCEPTIONS 1
43 #endif
45 // If set, asan uses the values of SHADOW_SCALE and SHADOW_OFFSET
46 // provided by the instrumented objects. Otherwise constants are used.
47 #ifndef ASAN_FLEXIBLE_MAPPING_AND_OFFSET
48 # define ASAN_FLEXIBLE_MAPPING_AND_OFFSET 0
49 #endif
51 // If set, values like allocator chunk size, as well as defaults for some flags
52 // will be changed towards less memory overhead.
53 #ifndef ASAN_LOW_MEMORY
54 #if SANITIZER_WORDSIZE == 32
55 # define ASAN_LOW_MEMORY 1
56 #else
57 # define ASAN_LOW_MEMORY 0
58 # endif
59 #endif
61 #ifndef ASAN_USE_PREINIT_ARRAY
62 # define ASAN_USE_PREINIT_ARRAY (SANITIZER_LINUX && !SANITIZER_ANDROID)
63 #endif
65 // All internal functions in asan reside inside the __asan namespace
66 // to avoid namespace collisions with the user programs.
67 // Seperate namespace also makes it simpler to distinguish the asan run-time
68 // functions from the instrumented user code in a profile.
69 namespace __asan {
71 class AsanThread;
72 using __sanitizer::StackTrace;
74 // asan_rtl.cc
75 void NORETURN ShowStatsAndAbort();
77 void ReplaceOperatorsNewAndDelete();
78 // asan_malloc_linux.cc / asan_malloc_mac.cc
79 void ReplaceSystemMalloc();
81 // asan_linux.cc / asan_mac.cc / asan_win.cc
82 void *AsanDoesNotSupportStaticLinkage();
84 void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
86 void MaybeReexec();
87 bool AsanInterceptsSignal(int signum);
88 void SetAlternateSignalStack();
89 void UnsetAlternateSignalStack();
90 void InstallSignalHandlers();
91 void ReadContextStack(void *context, uptr *stack, uptr *ssize);
92 void AsanPlatformThreadInit();
93 void StopInitOrderChecking();
95 // Wrapper for TLS/TSD.
96 void AsanTSDInit(void (*destructor)(void *tsd));
97 void *AsanTSDGet();
98 void AsanTSDSet(void *tsd);
99 void PlatformTSDDtor(void *tsd);
101 void AppendToErrorMessageBuffer(const char *buffer);
103 // Platfrom-specific options.
104 #if SANITIZER_MAC
105 bool PlatformHasDifferentMemcpyAndMemmove();
106 # define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE \
107 (PlatformHasDifferentMemcpyAndMemmove())
108 #else
109 # define PLATFORM_HAS_DIFFERENT_MEMCPY_AND_MEMMOVE true
110 #endif // SANITIZER_MAC
112 // Add convenient macro for interface functions that may be represented as
113 // weak hooks.
114 #define ASAN_MALLOC_HOOK(ptr, size) \
115 if (&__asan_malloc_hook) __asan_malloc_hook(ptr, size)
116 #define ASAN_FREE_HOOK(ptr) \
117 if (&__asan_free_hook) __asan_free_hook(ptr)
118 #define ASAN_ON_ERROR() \
119 if (&__asan_on_error) __asan_on_error()
121 extern int asan_inited;
122 // Used to avoid infinite recursion in __asan_init().
123 extern bool asan_init_is_running;
124 extern void (*death_callback)(void);
126 // These magic values are written to shadow for better error reporting.
127 const int kAsanHeapLeftRedzoneMagic = 0xfa;
128 const int kAsanHeapRightRedzoneMagic = 0xfb;
129 const int kAsanHeapFreeMagic = 0xfd;
130 const int kAsanStackLeftRedzoneMagic = 0xf1;
131 const int kAsanStackMidRedzoneMagic = 0xf2;
132 const int kAsanStackRightRedzoneMagic = 0xf3;
133 const int kAsanStackPartialRedzoneMagic = 0xf4;
134 const int kAsanStackAfterReturnMagic = 0xf5;
135 const int kAsanInitializationOrderMagic = 0xf6;
136 const int kAsanUserPoisonedMemoryMagic = 0xf7;
137 const int kAsanContiguousContainerOOBMagic = 0xfc;
138 const int kAsanStackUseAfterScopeMagic = 0xf8;
139 const int kAsanGlobalRedzoneMagic = 0xf9;
140 const int kAsanInternalHeapMagic = 0xfe;
142 static const uptr kCurrentStackFrameMagic = 0x41B58AB3;
143 static const uptr kRetiredStackFrameMagic = 0x45E0360E;
145 } // namespace __asan
147 #endif // ASAN_INTERNAL_H