[llvm] r221480 - Base check on the section name, not the variable name.

Rafael Espindola rafael.espindola at gmail.com
Thu Nov 6 12:01:34 PST 2014


Author: rafael
Date: Thu Nov  6 14:01:34 2014
New Revision: 221480

URL: http://llvm.org/viewvc/llvm-project?rev=221480&view=rev
Log:
Base check on the section name, not the variable name.

The variable is private, so the name should not be relied on. Also, the
linker uses the sections, so asan should too when trying to avoid causing
the linker problems.

Added:
    llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll
Modified:
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=221480&r1=221479&r2=221480&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Thu Nov  6 14:01:34 2014
@@ -971,16 +971,6 @@ bool AddressSanitizerModule::ShouldInstr
   // For now, just ignore this Global if the alignment is large.
   if (G->getAlignment() > MinRedzoneSizeForGlobal()) return false;
 
-  // Ignore all the globals with the names starting with "\01L_OBJC_".
-  // Many of those are put into the .cstring section. The linker compresses
-  // that section by removing the spare \0s after the string terminator, so
-  // our redzones get broken.
-  if ((G->getName().find("\01L_OBJC_") == 0) ||
-      (G->getName().find("\01l_OBJC_") == 0)) {
-    DEBUG(dbgs() << "Ignoring \\01L_OBJC_* global: " << *G << "\n");
-    return false;
-  }
-
   if (G->hasSection()) {
     StringRef Section(G->getSection());
     // Ignore the globals from the __OBJC section. The ObjC runtime assumes
@@ -1009,6 +999,11 @@ bool AddressSanitizerModule::ShouldInstr
       DEBUG(dbgs() << "Ignoring a cstring literal: " << *G << "\n");
       return false;
     }
+    if (Section.startswith("__TEXT,__objc_methname,cstring_literals")) {
+      DEBUG(dbgs() << "Ignoring objc_methname cstring global: " << *G << "\n");
+      return false;
+    }
+
 
     // Callbacks put into the CRT initializer/terminator sections
     // should not be instrumented.

Added: llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll?rev=221480&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll (added)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/do-not-instrument-cstring.ll Thu Nov  6 14:01:34 2014
@@ -0,0 +1,7 @@
+; RUN: opt < %s -asan -asan-module -S | FileCheck %s
+
+target datalayout = "e"
+
+ at foo = private global [19 x i8] c"scannerWithString:\00", section "__TEXT,__objc_methname,cstring_literals"
+
+; CHECK: @foo = private global [19 x i8] c"scannerWithString:\00", section "__TEXT,__objc_methname,cstring_literals"
\ No newline at end of file





More information about the llvm-commits mailing list