[llvm-commits] [compiler-rt] r147319 - in /compiler-rt/trunk/lib/asan: asan_rtl.cc asan_stack.cc tests/asan_test.cc

Kostya Serebryany kcc at google.com
Wed Dec 28 11:55:30 PST 2011


Author: kcc
Date: Wed Dec 28 13:55:30 2011
New Revision: 147319

URL: http://llvm.org/viewvc/llvm-project?rev=147319&view=rev
Log:
[asan] enable memset/memcpy/memmove interceptors in asan-rt (in addition to those in the compiler module)

Modified:
    compiler-rt/trunk/lib/asan/asan_rtl.cc
    compiler-rt/trunk/lib/asan/asan_stack.cc
    compiler-rt/trunk/lib/asan/tests/asan_test.cc

Modified: compiler-rt/trunk/lib/asan/asan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_rtl.cc?rev=147319&r1=147318&r2=147319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_rtl.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_rtl.cc Wed Dec 28 13:55:30 2011
@@ -676,7 +676,7 @@
   FLAG_replace_cfallocator = IntFlagValue(options, "replace_cfallocator=", 1);
   FLAG_fast_unwind = IntFlagValue(options, "fast_unwind=", 1);
   FLAG_replace_str = IntFlagValue(options, "replace_str=", 1);
-  FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 0);
+  FLAG_replace_intrin = IntFlagValue(options, "replace_intrin=", 1);
   FLAG_use_fake_stack = IntFlagValue(options, "use_fake_stack=", 1);
   FLAG_exitcode = IntFlagValue(options, "exitcode=", EXIT_FAILURE);
   FLAG_allow_user_poisoning = IntFlagValue(options,

Modified: compiler-rt/trunk/lib/asan/asan_stack.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_stack.cc?rev=147319&r1=147318&r2=147319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_stack.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_stack.cc Wed Dec 28 13:55:30 2011
@@ -183,9 +183,8 @@
     compressed[i] = stack->trace[i];
     res++;
   }
-  for (size_t i = stack->size; i < size; i++) {
-    compressed[i] = 0;
-  }
+  if (stack->size < size)
+    compressed[stack->size] = 0;
 #else  // 64 bits, compress.
   uintptr_t prev_pc = 0;
   const uintptr_t kMaxOffset = (1ULL << 30) - 1;
@@ -214,9 +213,10 @@
     res++;
     prev_pc = pc;
   }
-  for (size_t i = c_index; i < size; i++) {
-    compressed[i] = 0;
-  }
+  if (c_index < size)
+    compressed[c_index] = 0;
+  if (c_index + 1 < size)
+    compressed[c_index + 1] = 0;
 #endif  // __WORDSIZE
 
   // debug-only code

Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=147319&r1=147318&r2=147319&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Wed Dec 28 13:55:30 2011
@@ -1365,7 +1365,6 @@
   size_t size = Ident(100);
   char *str = Ident((char*)malloc(size));
 
-#if 0
   // Check "memcpy". Use Ident() to avoid inlining.
   memset(str, 'z', size);
   Ident(memcpy)(str + 1, str + 11, 10);
@@ -1374,7 +1373,6 @@
   EXPECT_DEATH(Ident(memcpy)(str + 14, str, 15), OverlapErrorMessage("memcpy"));
   EXPECT_DEATH(Ident(memcpy)(str + 20, str + 20, 1),
                OverlapErrorMessage("memcpy"));
-#endif
 
   // Check "strcpy".
   memset(str, 'z', size);





More information about the llvm-commits mailing list