Index: compiler-rt/lib/fuzzer/CMakeLists.txt =================================================================== --- compiler-rt/lib/fuzzer/CMakeLists.txt +++ compiler-rt/lib/fuzzer/CMakeLists.txt @@ -1,6 +1,7 @@ set(LIBFUZZER_SOURCES FuzzerCrossOver.cpp FuzzerDataFlowTrace.cpp + FuzzerDeprecated.cpp FuzzerDriver.cpp FuzzerExtFunctionsDlsym.cpp FuzzerExtFunctionsWeak.cpp Index: compiler-rt/lib/fuzzer/FuzzerDeprecated.cpp =================================================================== --- /dev/null +++ compiler-rt/lib/fuzzer/FuzzerDeprecated.cpp @@ -0,0 +1,48 @@ +//===- FuzzerDeprecated.cpp -----------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// Warns about deprecated instrumentation. +//===----------------------------------------------------------------------===// + +#include "FuzzerUtil.h" + +namespace fuzzer { + +void WarnAboutDeprecatedInstrumentation(const char *flag) { + // Use RawPrint because Printf cannot be used on Windows before OutputFile is + // initialized. + RawPrint(flag); + RawPrint( + " is no longer supported by libFuzzer.\n" + "Please either migrate to a compiler that supports -fsanitize=fuzzer\n" + "or use an older version of libFuzzer\n"); + exit(1); +} + +} // namespace fuzzer + +extern "C" { +ATTRIBUTE_INTERFACE +ATTRIBUTE_NO_SANITIZE_ALL +void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) { + fuzzer::WarnAboutDeprecatedInstrumentation( + "-fsanitize-coverage=trace-pc-guard"); +} + +ATTRIBUTE_INTERFACE +ATTRIBUTE_NO_SANITIZE_ALL +void __sanitizer_cov_trace_pc() { + fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc"); +} + +ATTRIBUTE_INTERFACE +void __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) { + fuzzer::WarnAboutDeprecatedInstrumentation( + "-fsanitize-coverage=trace-pc-guard"); +} + +} // extern "C" Index: compiler-rt/lib/fuzzer/FuzzerTracePC.cpp =================================================================== --- compiler-rt/lib/fuzzer/FuzzerTracePC.cpp +++ compiler-rt/lib/fuzzer/FuzzerTracePC.cpp @@ -499,41 +499,9 @@ return (Log2 + 1) * 8 + ((A >> Log2) & 7); } -void WarnAboutDeprecatedInstrumentation(const char *flag) { - // Use RawPrint because Printf cannot be used on Windows before OutputFile is - // initialized. - RawPrint(flag); - RawPrint( - " is no longer supported by libFuzzer.\n" - "Please either migrate to a compiler that supports -fsanitize=fuzzer\n" - "or use an older version of libFuzzer\n"); - exit(1); -} - } // namespace fuzzer extern "C" { -ATTRIBUTE_INTERFACE -ATTRIBUTE_NO_SANITIZE_ALL -void __sanitizer_cov_trace_pc_guard(uint32_t *Guard) { - fuzzer::WarnAboutDeprecatedInstrumentation( - "-fsanitize-coverage=trace-pc-guard"); -} - -// Best-effort support for -fsanitize-coverage=trace-pc, which is available -// in both Clang and GCC. -ATTRIBUTE_INTERFACE -ATTRIBUTE_NO_SANITIZE_ALL -void __sanitizer_cov_trace_pc() { - fuzzer::WarnAboutDeprecatedInstrumentation("-fsanitize-coverage=trace-pc"); -} - -ATTRIBUTE_INTERFACE -void __sanitizer_cov_trace_pc_guard_init(uint32_t *Start, uint32_t *Stop) { - fuzzer::WarnAboutDeprecatedInstrumentation( - "-fsanitize-coverage=trace-pc-guard"); -} - ATTRIBUTE_INTERFACE void __sanitizer_cov_8bit_counters_init(uint8_t *Start, uint8_t *Stop) { fuzzer::TPC.HandleInline8bitCountersInit(Start, Stop);