diff options
| author | Kostya Serebryany <kcc@google.com> | 2019-01-29 23:37:20 +0000 |
|---|---|---|
| committer | Kostya Serebryany <kcc@google.com> | 2019-01-29 23:37:20 +0000 |
| commit | 50a1c697127749eec567d14819d549b63af1242f (patch) | |
| tree | fa03158af3ea18e060beaf3a7347f0b836673476 | |
| parent | 0b5e6b11c358e704384520dc036eddb5da1c68bf (diff) | |
| download | bcm5719-llvm-50a1c697127749eec567d14819d549b63af1242f.tar.gz bcm5719-llvm-50a1c697127749eec567d14819d549b63af1242f.zip | |
[libFuzzer] remove deprecated support for -fsanitize-coverage=trace-pc[-guard]
llvm-svn: 352564
| -rw-r--r-- | compiler-rt/lib/fuzzer/FuzzerTracePC.cpp | 21 | ||||
| -rw-r--r-- | compiler-rt/test/fuzzer/deprecated-instrumentation.test | 4 | ||||
| -rw-r--r-- | compiler-rt/test/fuzzer/dump_coverage.test | 22 | ||||
| -rw-r--r-- | compiler-rt/test/fuzzer/trace-pc.test | 3 |
4 files changed, 16 insertions, 34 deletions
diff --git a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp index b6b11f08579..695eee2fa93 100644 --- a/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerTracePC.cpp @@ -416,16 +416,20 @@ uintptr_t TracePC::GetMaxStackOffset() const { return InitialStack - __sancov_lowest_stack; // Stack grows down } +void WarnAboutDeprecatedInstrumentation(const char *flag) { + Printf("libFuzzer does not support %s any more.\n" + "Please either migrate to a compiler that supports -fsanitize=fuzzer\n" + "or use an older version of libFuzzer\n", flag); + exit(1); +} + } // namespace fuzzer extern "C" { ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_ALL void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) { - uintptr_t PC = reinterpret_cast<uintptr_t>(GET_CALLER_PC()); - uint32_t Idx = *Guard; - __sancov_trace_pc_pcs[Idx] = PC; - __sancov_trace_pc_guard_8bit_counters[Idx]++; + fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc"); } // Best-effort support for -fsanitize-coverage=trace-pc, which is available @@ -433,15 +437,14 @@ void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) { ATTRIBUTE_INTERFACE ATTRIBUTE_NO_SANITIZE_ALL void __sanitizer_cov_trace_pc() { - uintptr_t PC = reinterpret_cast<uintptr_t>(GET_CALLER_PC()); - uintptr_t Idx = PC & (((uintptr_t)1 << fuzzer::TracePC::kTracePcBits) - 1); - __sancov_trace_pc_pcs[Idx] = PC; - __sancov_trace_pc_guard_8bit_counters[Idx]++; + fuzzer::WarnAboutDeprecatedInstrumentation( + "-fsanitize-coverage=trace-pc-guard"); } ATTRIBUTE_INTERFACE void __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) { - fuzzer::TPC.HandleInit(Start, Stop); + fuzzer::WarnAboutDeprecatedInstrumentation( + "-fsanitize-coverage=trace-pc-guard"); } ATTRIBUTE_INTERFACE diff --git a/compiler-rt/test/fuzzer/deprecated-instrumentation.test b/compiler-rt/test/fuzzer/deprecated-instrumentation.test new file mode 100644 index 00000000000..7192aba556a --- /dev/null +++ b/compiler-rt/test/fuzzer/deprecated-instrumentation.test @@ -0,0 +1,4 @@ +CHECK: libFuzzer does not support -fsanitize-coverage=trace-pc +RUN: %cpp_compiler %S/SimpleTest.cpp -c -o %t-SimpleTest.o -fsanitize-coverage=trace-pc +RUN: %cpp_compiler %t-SimpleTest.o -o %t-SimpleTest +RUN: not %run %t-SimpleTest 2>&1 | FileCheck %s diff --git a/compiler-rt/test/fuzzer/dump_coverage.test b/compiler-rt/test/fuzzer/dump_coverage.test deleted file mode 100644 index 803a4fbb8a0..00000000000 --- a/compiler-rt/test/fuzzer/dump_coverage.test +++ /dev/null @@ -1,22 +0,0 @@ -# FIXME: Disabled on Windows because -fPIC cannot be used to compile for Windows. -UNSUPPORTED: freebsd, windows -RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO1.cpp -fPIC -shared -o %dynamiclib1 %ld_flags_rpath_so1 -RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSO2.cpp -fPIC -shared -o %dynamiclib2 %ld_flags_rpath_so2 -RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/DSOTestMain.cpp %S/DSOTestExtra.cpp %ld_flags_rpath_exe1 %ld_flags_rpath_exe2 -o %t-DSOTest - -RUN: %cpp_compiler -fsanitize-coverage=0 -fsanitize-coverage=trace-pc-guard %S/NullDerefTest.cpp -o %t-NullDerefTest - -RUN: rm -rf %t_workdir && mkdir -p %t_workdir -RUN: env ASAN_OPTIONS=coverage_dir='"%t_workdir"' not %run %t-NullDerefTest -dump_coverage=1 2>&1 | FileCheck %s -RUN: sancov -covered-functions %t-NullDerefTest %t_workdir/*.sancov | FileCheck %s --check-prefix=SANCOV -RUN: env ASAN_OPTIONS=coverage_dir='"%t_workdir"' %run %t-DSOTest -dump_coverage=1 -runs=0 2>&1 | FileCheck -allow-deprecated-dag-overlap %s --check-prefix=DSO -RUN: env ASAN_OPTIONS=coverage_dir='"%t_workdir"' not %run %t-NullDerefTest -dump_coverage=0 2>&1 | FileCheck %s --check-prefix=NOCOV - -CHECK: SanitizerCoverage: {{.*}}NullDerefTest.{{.*}}.sancov: {{.*}} PCs written -SANCOV: LLVMFuzzerTestOneInput - -DSO: SanitizerCoverage: {{.*}}DSOTest.{{.*}}.sancov: {{.*}} PCs written -DSO-DAG: SanitizerCoverage: {{.*}}.{{.*}}.sancov: {{.*}} PCs written -DSO-DAG: SanitizerCoverage: {{.*}}2.{{.*}}.sancov: {{.*}} PCs written - -NOCOV-NOT: SanitizerCoverage: {{.*}} PCs written diff --git a/compiler-rt/test/fuzzer/trace-pc.test b/compiler-rt/test/fuzzer/trace-pc.test deleted file mode 100644 index 30049331e36..00000000000 --- a/compiler-rt/test/fuzzer/trace-pc.test +++ /dev/null @@ -1,3 +0,0 @@ -RUN: %cpp_compiler %S/SimpleTest.cpp -fsanitize-coverage=0 -fsanitize-coverage=trace-pc -o %t-SimpleTest-TracePC -CHECK: BINGO -RUN: not %run %t-SimpleTest-TracePC -runs=1000000 -seed=1 2>&1 | FileCheck %s |

