[compiler-rt] r312026 - [SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 12:48:12 PDT 2017
Author: morehouse
Date: Tue Aug 29 12:48:12 2017
New Revision: 312026
URL: http://llvm.org/viewvc/llvm-project?rev=312026&view=rev
Log:
[SanitizeCoverage] Enable stack-depth coverage for -fsanitize=fuzzer
Summary:
- Don't sanitize __sancov_lowest_stack.
- Don't instrument leaf functions.
- Add CoverageStackDepth to Fuzzer and FuzzerNoLink.
- Disable stack depth tracking on Mac.
Reviewers: vitalybuka, kcc, george.karpenkov
Reviewed By: kcc
Subscribers: kubamracek, cfe-commits, llvm-commits, hiraditya
Differential Revision: https://reviews.llvm.org/D37156
Modified:
compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
compiler-rt/trunk/test/fuzzer/deep-recursion.test
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc?rev=312026&r1=312025&r2=312026&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage_libcdep_new.cc Tue Aug 29 12:48:12 2017
@@ -211,5 +211,10 @@ SANITIZER_INTERFACE_WEAK_DEF(void, __san
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_8bit_counters_init, void) {}
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_cov_pcs_init, void) {}
} // extern "C"
+// Weak definition for code instrumented with -fsanitize-coverage=stack-depth
+// and later linked with code containing a strong definition.
+// E.g., -fsanitize=fuzzer-no-link
+SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
+SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE uptr __sancov_lowest_stack;
#endif // !SANITIZER_FUCHSIA
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=312026&r1=312025&r2=312026&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Tue Aug 29 12:48:12 2017
@@ -35,6 +35,14 @@
# define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
#endif
+// Mac handles TLS differently
+#if SANITIZER_MAC
+# define SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE
+#else
+# define SANITIZER_TLS_INITIAL_EXEC_ATTRIBUTE \
+ __attribute((tls_model("initial-exec"))) thread_local
+#endif
+
//--------------------------- WEAK FUNCTIONS ---------------------------------//
// When working with weak functions, to simplify the code and make it more
// portable, when possible define a default implementation using this macro:
Modified: compiler-rt/trunk/test/fuzzer/deep-recursion.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/deep-recursion.test?rev=312026&r1=312025&r2=312026&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/deep-recursion.test (original)
+++ compiler-rt/trunk/test/fuzzer/deep-recursion.test Tue Aug 29 12:48:12 2017
@@ -1,5 +1,5 @@
# Test that we can find a stack overflow
REQUIRES: linux
-RUN: %cpp_compiler -fsanitize-coverage=stack-depth %S/DeepRecursionTest.cpp -o %t
+RUN: %cpp_compiler %S/DeepRecursionTest.cpp -o %t
RUN: not %t -seed=1 -runs=100000000 2>&1 | FileCheck %s
CHECK: ERROR: libFuzzer: deadly signal
More information about the llvm-commits
mailing list