forked from OSchip/llvm-project
[ASan] Add __asan_init to the list of C dynamic initializers to support /MD on Windows
llvm-svn: 151059
This commit is contained in:
parent
a09e62a042
commit
a1c987ff38
|
@ -508,9 +508,15 @@ void __asan_init() {
|
|||
}
|
||||
|
||||
#if defined(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")))
|
||||
typeof(__asan_init) *__asan_preinit =__asan_init;
|
||||
// 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")))
|
||||
typeof(__asan_init) *__asan_preinit =__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)
|
||||
__declspec(allocate(".CRT$XIB")) void (*__asan_preinit)() = __asan_init;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue