[PATCH] D28437: [compiler-rt] Update implementation of sanitizer coverage to work when guards are initialized to 0xffffffff.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 20:38:06 PST 2017


mpividori created this revision.
mpividori added reviewers: kcc, aizatsky, rnk, zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.
Herald added subscribers: dberris, kubabrecka.

Update the default implementation of  sanitizer coverage to work when the guards are initialized to 0xffffffff , as mentioned in: https://reviews.llvm.org/D28436


Repository:
  rL LLVM

https://reviews.llvm.org/D28437

Files:
  lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc


Index: lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
===================================================================
--- lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
+++ lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
@@ -111,11 +111,16 @@
 
   void InitTracePcGuard(u32* start, u32* end) {
     if (!initialized) Initialize();
-    CHECK(!*start);
     CHECK_NE(start, end);
 
     u32 i = pc_vector.size();
-    for (u32* p = start; p < end; p++) *p = ++i;
+    for (u32* p = start; p < end; p++)
+      // Ignore zero padding.
+      if (*p) {
+        if (*p != 0xffffffff) // This module was initialized before.
+          return;
+        *p = ++i;
+      }
     pc_vector.resize(i);
   }
 
@@ -155,7 +160,7 @@
 
 SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
 __sanitizer_cov_trace_pc_guard_init(u32* start, u32* end) {
-  if (start == end || *start) return;
+  if (start == end) return;
   pc_guard_controller.InitTracePcGuard(start, end);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28437.83498.patch
Type: text/x-patch
Size: 997 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170107/624baae8/attachment.bin>


More information about the llvm-commits mailing list