[llvm-commits] [ASan] Add __asan_init to the list of C dynamic initializers to support /MD (issue 5688060)
timurrrr at google.com
timurrrr at google.com
Tue Feb 21 08:22:02 PST 2012
Reviewers: glider,
Message:
Hi Alexander,
Can you please review this small patch?
[Remember we were doing experiments on the .CRT sections together an
hour ago?]
Thanks,
Timur
Description:
[ASan] Add __asan_init to the list of C dynamic initializers to support
/MD
Please review this at http://codereview.appspot.com/5688060/
Affected files:
M lib/asan/asan_rtl.cc
Index: lib/asan/asan_rtl.cc
diff --git a/lib/asan/asan_rtl.cc b/lib/asan/asan_rtl.cc
index
e0a920756c85fc0cff42abc80c36efffac44572a..4fb873fced33e419dc245a917c4ae3b558cae3e5
100644
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -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
More information about the llvm-commits
mailing list