forked from OSchip/llvm-project
[libFuzzer] remove deprecated support for -fsanitize-coverage=trace-pc[-guard]
llvm-svn: 352564
This commit is contained in:
parent
0b5e6b11c3
commit
50a1c69712
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue