diff options
Diffstat (limited to 'compiler-rt')
| -rw-r--r-- | compiler-rt/lib/asan/asan_interface.h | 9 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_internal.h | 5 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_posix.cc | 5 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 7 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_win.cc | 5 |
5 files changed, 23 insertions, 8 deletions
diff --git a/compiler-rt/lib/asan/asan_interface.h b/compiler-rt/lib/asan/asan_interface.h index 553d506620b..4deba08dbc6 100644 --- a/compiler-rt/lib/asan/asan_interface.h +++ b/compiler-rt/lib/asan/asan_interface.h @@ -15,6 +15,10 @@ #ifndef ASAN_INTERFACE_H #define ASAN_INTERFACE_H +// ----------- ATTENTION ------------- +// This header should NOT include any other headers from ASan runtime. +// All functions in this header are extern "C" and start with __asan_. + #if !defined(_WIN32) #include <stdint.h> // for uintptr_t #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE __attribute__((visibility("default"))) @@ -22,10 +26,7 @@ // TODO(timurrrr): find out what we need on Windows. __declspec(dllexport) ? #define ASAN_INTERFACE_FUNCTION_ATTRIBUTE #endif -#include <stdlib.h> // for size_t - -// This header should NOT include any other headers from ASan runtime. -// All functions in this header are extern "C" and start with __asan_. +#include <stddef.h> // for size_t extern "C" { // This function should be called at the very beginning of the process, diff --git a/compiler-rt/lib/asan/asan_internal.h b/compiler-rt/lib/asan/asan_internal.h index a67d034d61a..8891e3af48c 100644 --- a/compiler-rt/lib/asan/asan_internal.h +++ b/compiler-rt/lib/asan/asan_internal.h @@ -18,7 +18,7 @@ # error "This operating system is not supported by AddressSanitizer" #endif -#include <stdlib.h> // for size_t, uintptr_t, etc. +#include <stddef.h> // for size_t, uintptr_t, etc. #if defined(_WIN32) // There's no <stdint.h> in Visual Studio 9, so we have to define [u]int*_t. @@ -75,6 +75,8 @@ extern "C" void* _ReturnAddress(void); # define INT64_MAX (__INT64_C(9223372036854775807)) # define UINT64_MAX (__UINT64_C(18446744073709551615)) +#define ASAN_DEFAULT_FAILURE_EXITCODE 1 + #if defined(__linux__) # define ASAN_LINUX 1 #else @@ -229,6 +231,7 @@ enum LinkerInitialized { LINKER_INITIALIZED = 0 }; void AsanDie(); void SleepForSeconds(int seconds); void Exit(int exitcode); +int Atexit(void (*function)(void)); #define CHECK(cond) do { if (!(cond)) { \ CheckFailed(#cond, __FILE__, __LINE__); \ diff --git a/compiler-rt/lib/asan/asan_posix.cc b/compiler-rt/lib/asan/asan_posix.cc index a1f0ecdf2b6..43a5ffee058 100644 --- a/compiler-rt/lib/asan/asan_posix.cc +++ b/compiler-rt/lib/asan/asan_posix.cc @@ -21,6 +21,7 @@ #include <pthread.h> #include <signal.h> +#include <stdlib.h> #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> @@ -99,6 +100,10 @@ void Exit(int exitcode) { return _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + int AtomicInc(int *a) { #ifdef ANDROID return __atomic_inc(a) + 1; diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index fe7c3d010fb..fff199bf352 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -44,7 +44,7 @@ bool FLAG_replace_intrin; bool FLAG_replace_cfallocator; // Used on Mac only. size_t FLAG_max_malloc_fill_size = 0; bool FLAG_use_fake_stack; -int FLAG_exitcode = EXIT_FAILURE; +int FLAG_exitcode = ASAN_DEFAULT_FAILURE_EXITCODE; bool FLAG_allow_user_poisoning; int FLAG_sleep_before_dying; @@ -433,13 +433,14 @@ void __asan_init() { FLAG_replace_str = IntFlagValue(options, "replace_str=", 1); FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 1); FLAG_use_fake_stack = IntFlagValue(options, "use_fake_stack=", 1); - FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE); + FLAG_exitcode = IntFlagValue(options, "exitcode=", + ASAN_DEFAULT_FAILURE_EXITCODE); FLAG_allow_user_poisoning = IntFlagValue(options, "allow_user_poisoning=", 1); FLAG_sleep_before_dying = IntFlagValue(options, "sleep_before_dying=", 0); if (FLAG_atexit) { - atexit(asan_atexit); + Atexit(asan_atexit); } // interceptors diff --git a/compiler-rt/lib/asan/asan_win.cc b/compiler-rt/lib/asan/asan_win.cc index 86bcc2c26a0..2692b0db5b7 100644 --- a/compiler-rt/lib/asan/asan_win.cc +++ b/compiler-rt/lib/asan/asan_win.cc @@ -16,6 +16,7 @@ #include <dbghelp.h> #include <stdio.h> // FIXME: get rid of this. +#include <stdlib.h> #include <new> // FIXME: temporarily needed for placement new in AsanLock. @@ -262,6 +263,10 @@ void Exit(int exitcode) { _exit(exitcode); } +int Atexit(void (*function)(void)) { + return atexit(function); +} + } // namespace __asan #endif // _WIN32 |

