diff options
| author | Kostya Serebryany <kcc@google.com> | 2013-02-22 07:51:26 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2013-02-22 07:51:26 +0000 |
| commit | 1d63d13ce2c24e3ceabc8ca8acec26c4616fbd68 (patch) | |
| tree | efc89d27d46856642884029b770dd1e444615f1b | |
| parent | 1c73911d420db52e6d52cd68bd1020bfddb6d608 (diff) | |
| download | bcm5719-llvm-1d63d13ce2c24e3ceabc8ca8acec26c4616fbd68.tar.gz bcm5719-llvm-1d63d13ce2c24e3ceabc8ca8acec26c4616fbd68.zip | |
[asan] move the .preinit_array hack into a separate file (added used attribute)
llvm-svn: 175871
| -rw-r--r-- | compiler-rt/lib/asan/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_intercepted_functions.h | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_preinit.cc | 29 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/asan_rtl.cc | 14 |
4 files changed, 30 insertions, 15 deletions
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt index cdd462ed684..e451e23110d 100644 --- a/compiler-rt/lib/asan/CMakeLists.txt +++ b/compiler-rt/lib/asan/CMakeLists.txt @@ -14,6 +14,7 @@ set(ASAN_SOURCES asan_new_delete.cc asan_poisoning.cc asan_posix.cc + asan_preinit.cc asan_report.cc asan_rtl.cc asan_stack.cc diff --git a/compiler-rt/lib/asan/asan_intercepted_functions.h b/compiler-rt/lib/asan/asan_intercepted_functions.h index 7cfbede9f60..d5295601056 100644 --- a/compiler-rt/lib/asan/asan_intercepted_functions.h +++ b/compiler-rt/lib/asan/asan_intercepted_functions.h @@ -103,7 +103,6 @@ int atoi(const char *nptr); long atol(const char *nptr); // NOLINT long strtol(const char *nptr, char **endptr, int base); // NOLINT void longjmp(void *env, int value); - } # endif diff --git a/compiler-rt/lib/asan/asan_preinit.cc b/compiler-rt/lib/asan/asan_preinit.cc new file mode 100644 index 00000000000..07e0a53ca66 --- /dev/null +++ b/compiler-rt/lib/asan/asan_preinit.cc @@ -0,0 +1,29 @@ +//===-- asan_preinit.cc ---------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file is a part of AddressSanitizer, an address sanity checker. +// +// Call __asan_init at the very early stage of process startup. +// On Linux we use .preinit_array section (unless PIC macro is defined). +//===----------------------------------------------------------------------===// +#include "asan_internal.h" + +#if ASAN_USE_PREINIT_ARRAY && !defined(PIC) + // On Linux, we force __asan_init to be called before anyone else + // by placing it into .preinit_array section. + // FIXME: do we have anything like this on Mac? + __attribute__((section(".preinit_array"), used)) + void (*__asan_preinit)(void) =__asan_init; +#elif defined(_WIN32) && defined(_DLL) + // On Windows, when using dynamic CRT (/MD), we can put a pointer + // to __asan_init into the global list of C initializers. + // See crt0dat.c in the CRT sources for the details. + #pragma section(".CRT$XIB", long, read) // NOLINT + __declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init; +#endif diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc index 83aa1f46abf..7985903bf56 100644 --- a/compiler-rt/lib/asan/asan_rtl.cc +++ b/compiler-rt/lib/asan/asan_rtl.cc @@ -523,17 +523,3 @@ void __asan_init() { Report("AddressSanitizer Init done\n"); } } - -#if ASAN_USE_PREINIT_ARRAY - // On Linux, we force __asan_init to be called before anyone else - // by placing it into .preinit_array section. - // FIXME: do we have anything like this on Mac? - __attribute__((section(".preinit_array"))) - void (*__asan_preinit)(void) =__asan_init; -#elif defined(_WIN32) && defined(_DLL) - // On Windows, when using dynamic CRT (/MD), we can put a pointer - // to __asan_init into the global list of C initializers. - // See crt0dat.c in the CRT sources for the details. - #pragma section(".CRT$XIB", long, read) // NOLINT - __declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init; -#endif |

