[llvm-commits] [compiler-rt] r151059 - /compiler-rt/trunk/lib/asan/asan_rtl.cc

Timur Iskhodzhanov timurrrr at google.com
Tue Feb 21 08:24:23 PST 2012


Author: timurrrr
Date: Tue Feb 21 10:24:23 2012
New Revision: 151059

URL: http://llvm.org/viewvc/llvm-project?rev=151059&view=rev
Log:
[ASan] Add __asan_init to the list of C dynamic initializers to support /MD on Windows

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=151059&r1=151058&r2=151059&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Tue Feb 21 10:24:23 2012
@@ -508,9 +508,15 @@
 }
 
 #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