[asan] use .preinit_array only on linux
authorKostya Serebryany <kcc@google.com>
Mon, 12 Dec 2011 18:01:46 +0000 (18:01 +0000)
committerKostya Serebryany <kcc@google.com>
Mon, 12 Dec 2011 18:01:46 +0000 (18:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146379 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Instrumentation/AddressSanitizer.cpp

index fdea1b59466e925ea76cddf83fdd87907610a9e6..f16bdf530c528d485e9da85600aabab72d239946 100644 (file)
@@ -567,7 +567,6 @@ bool AddressSanitizer::insertGlobalRedzones(Module &M) {
 
 // .preinit_array is something that hapens before all other inits.
 // On systems where .preinit_array is honored, we will call __asan_init early.
-// On other systems this will make no effect.
 void AddressSanitizer::appendToPreinitArray(Module &M, Function *F) {
   IRBuilder<> IRB(M.getContext());
   GlobalVariable *Var =
@@ -647,7 +646,9 @@ bool AddressSanitizer::runOnModule(Module &M) {
   }
 
   appendToGlobalCtors(M, AsanCtorFunction, 1 /*high priority*/);
-  appendToPreinitArray(M, AsanInitFunction);
+
+  if (M.getTargetTriple().find("linux") != std::string::npos)
+    appendToPreinitArray(M, AsanInitFunction);
 
   return Res;
 }