From e40fb373ef4f93fd3c22ad094260512044bab0fe Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Wed, 9 Jul 2014 08:35:33 +0000 Subject: [PATCH] [ASan/Win] Don't instrument COMDAT globals. Properly fixes PR20244. llvm-svn: 212596 --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 8f9355c..5e5ddc1 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -923,11 +923,14 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) { if (!G->hasInitializer()) return false; if (GlobalWasGeneratedByAsan(G)) return false; // Our own global. // Touch only those globals that will not be defined in other modules. - // Don't handle ODR type linkages since other modules may be built w/o asan. + // Don't handle ODR linkage types and COMDATs since other modules may be built + // without ASan. if (G->getLinkage() != GlobalVariable::ExternalLinkage && G->getLinkage() != GlobalVariable::PrivateLinkage && G->getLinkage() != GlobalVariable::InternalLinkage) return false; + if (G->hasComdat()) + return false; // Two problems with thread-locals: // - The address of the main thread's copy can't be computed at link-time. // - Need to poison all copies, not just the main thread's one. @@ -946,13 +949,6 @@ bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) { return false; } - // Don't instrument private COMDAT globals on Windows until PR20244 (linkage - // of vftables with RTTI) is properly fixed. - llvm::Triple TargetTriple(G->getParent()->getTargetTriple()); - if (G->hasComdat() && G->getLinkage() == GlobalVariable::PrivateLinkage && - TargetTriple.isWindowsMSVCEnvironment()) - return false; - if (G->hasSection()) { StringRef Section(G->getSection()); // Ignore the globals from the __OBJC section. The ObjC runtime assumes -- 2.7.4