[llvm-commits] [llvm] r163199 - in /llvm/trunk/lib/Transforms/Instrumentation: AddressSanitizer.cpp BlackList.cpp BlackList.h

Kostya Serebryany kcc at google.com
Wed Sep 5 00:29:57 PDT 2012


Author: kcc
Date: Wed Sep  5 02:29:56 2012
New Revision: 163199

URL: http://llvm.org/viewvc/llvm-project?rev=163199&view=rev
Log:
[asan] extend the blacklist functionality to handle global-init. Patch by Reid Watson

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
    llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
    llvm/trunk/lib/Transforms/Instrumentation/BlackList.h

Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=163199&r1=163198&r2=163199&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Wed Sep  5 02:29:56 2012
@@ -544,6 +544,7 @@
   Type *Ty = cast<PointerType>(G->getType())->getElementType();
   DEBUG(dbgs() << "GLOBAL: " << *G);
 
+  if (BL->isIn(*G)) return false;
   if (!Ty->isSized()) return false;
   if (!G->hasInitializer()) return false;
   // Touch only those globals that will not be defined in other modules.
@@ -643,6 +644,8 @@
     Type *RightRedZoneTy = ArrayType::get(IRB.getInt8Ty(), RightRedzoneSize);
     // Determine whether this global should be poisoned in initialization.
     bool GlobalHasDynamicInitializer = HasDynamicInitializer(G);
+    // Don't check initialization order if this global is blacklisted.
+    GlobalHasDynamicInitializer &= ! BL->isInInit(*G);
 
     StructType *NewTy = StructType::get(Ty, RightRedZoneTy, NULL);
     Constant *NewInitializer = ConstantStruct::get(

Modified: llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp?rev=163199&r1=163198&r2=163199&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp Wed Sep  5 02:29:56 2012
@@ -89,6 +89,10 @@
   return inSection("src", M.getModuleIdentifier());
 }
 
+bool BlackList::isInInit(const GlobalVariable &G) {
+  return isIn(*G.getParent()) || inSection("global-init", G.getName());
+}
+
 bool BlackList::inSection(const StringRef Section,
                                   const StringRef Query) {
   Regex *FunctionRegex = Entries[Section];

Modified: llvm/trunk/lib/Transforms/Instrumentation/BlackList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.h?rev=163199&r1=163198&r2=163199&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.h (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.h Wed Sep  5 02:29:56 2012
@@ -14,7 +14,8 @@
 // variables.  Each line contains a prefix, followed by a wild card expression.
 // ---
 // fun:*_ZN4base6subtle*
-// global:*global_with_initialization_problems*
+// global:*global_with_bad_access_or_initialization*
+// global-init:*global_with_initialization_issues*
 // src:file_with_tricky_code.cc
 // ---
 // Note that the wild card is in fact an llvm::Regex, but * is automatically
@@ -43,6 +44,8 @@
   bool isIn(const GlobalVariable &G);
   // Returns whether this module is blacklisted by filename.
   bool isIn(const Module &M);
+  // Returns whether a global should be excluded from initialization checking.
+  bool isInInit(const GlobalVariable &G);
  private:
   StringMap<Regex*> Entries;
 





More information about the llvm-commits mailing list