Skip to content

Commit 50a1c69

Browse files
committed
[libFuzzer] remove deprecated support for -fsanitize-coverage=trace-pc[-guard]
llvm-svn: 352564
1 parent 0b5e6b1 commit 50a1c69

4 files changed

Lines changed: 16 additions & 34 deletions

File tree

compiler-rt/lib/fuzzer/FuzzerTracePC.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -416,32 +416,35 @@ uintptr_t TracePC::GetMaxStackOffset() const {
416416
return InitialStack - __sancov_lowest_stack; // Stack grows down
417417
}
418418

419+
void WarnAboutDeprecatedInstrumentation(const char *flag) {
420+
Printf("libFuzzer does not support %s any more.\n"
421+
"Please either migrate to a compiler that supports -fsanitize=fuzzer\n"
422+
"or use an older version of libFuzzer\n", flag);
423+
exit(1);
424+
}
425+
419426
} // namespace fuzzer
420427

421428
extern "C" {
422429
ATTRIBUTE_INTERFACE
423430
ATTRIBUTE_NO_SANITIZE_ALL
424431
void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) {
425-
uintptr_t PC = reinterpret_cast<uintptr_t>(GET_CALLER_PC());
426-
uint32_t Idx = *Guard;
427-
__sancov_trace_pc_pcs[Idx] = PC;
428-
__sancov_trace_pc_guard_8bit_counters[Idx]++;
432+
fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc");
429433
}
430434

431435
// Best-effort support for -fsanitize-coverage=trace-pc, which is available
432436
// in both Clang and GCC.
433437
ATTRIBUTE_INTERFACE
434438
ATTRIBUTE_NO_SANITIZE_ALL
435439
void __sanitizer_cov_trace_pc() {
436-
uintptr_t PC = reinterpret_cast<uintptr_t>(GET_CALLER_PC());
437-
uintptr_t Idx = PC & (((uintptr_t)1 << fuzzer::TracePC::kTracePcBits) - 1);
438-
__sancov_trace_pc_pcs[Idx] = PC;
439-
__sancov_trace_pc_guard_8bit_counters[Idx]++;
440+
fuzzer::WarnAboutDeprecatedInstrumentation(
441+
"-fsanitize-coverage=trace-pc-guard");
440442
}
441443

442444
ATTRIBUTE_INTERFACE
443445
void __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) {
444-
fuzzer::TPC.HandleInit(Start, Stop);
446+
fuzzer::WarnAboutDeprecatedInstrumentation(
447+
"-fsanitize-coverage=trace-pc-guard");
445448
}
446449

447450
ATTRIBUTE_INTERFACE
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CHECK: libFuzzer does not support -fsanitize-coverage=trace-pc
2+
RUN: %cpp_compiler %S/SimpleTest.cpp -c -o %t-SimpleTest.o -fsanitize-coverage=trace-pc
3+
RUN: %cpp_compiler %t-SimpleTest.o -o %t-SimpleTest
4+
RUN: not %run %t-SimpleTest 2>&1 | FileCheck %s

compiler-rt/test/fuzzer/dump_coverage.test

Lines changed: 0 additions & 22 deletions
This file was deleted.

compiler-rt/test/fuzzer/trace-pc.test

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)