[asan] use .preinit_array only on linux

llvm-svn: 146379
This commit is contained in:
Kostya Serebryany 2011-12-12 18:01:46 +00:00
parent 531042840d
commit acb42b5919
1 changed files with 3 additions and 2 deletions

View File

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