diff --git a/centipede/BUILD b/centipede/BUILD index 7aa5030a..1b58e1e7 100644 --- a/centipede/BUILD +++ b/centipede/BUILD @@ -1022,13 +1022,18 @@ RUNNER_SOURCES_NO_MAIN = [ RUNNER_SOURCES_WITH_MAIN = RUNNER_SOURCES_NO_MAIN + ["runner_main.cc"] +RUNNER_FUZZTEST_COPTS = select({ + "@com_google_fuzztest//fuzztest:use_centipede": ["-DCENTIPEDE_RUNNER_NO_MUTATE_LIB"], + "//conditions:default": [], +}) + # Disable sancov and sanitizer instrumentation -RUNNER_COPTS = [ +RUNNER_COPTS = RUNNER_FUZZTEST_COPTS + [ "-fsanitize-coverage=0", "-fno-sanitize=address,hwaddress,memory,thread,undefined", ] -RUNNER_SANITIZED_COPTS = [ +RUNNER_SANITIZED_COPTS = RUNNER_FUZZTEST_COPTS + [ "-fsanitize-coverage=0", ] diff --git a/centipede/runner.cc b/centipede/runner.cc index 78c00983..8ea58835 100644 --- a/centipede/runner.cc +++ b/centipede/runner.cc @@ -328,6 +328,7 @@ void GlobalRunnerState::ResetTimers() { } } +#ifndef CENTIPEDE_RUNNER_NO_MUTATE_LIB // Byte array mutation fallback for a custom mutator, as defined here: // https://github.com/google/fuzzing/blob/master/docs/structure-aware-fuzzing.md extern "C" size_t LLVMFuzzerMutate(uint8_t *data, size_t size, @@ -352,6 +353,7 @@ extern "C" size_t LLVMFuzzerMutate(uint8_t *data, size_t size, memcpy(data, array.data(), array.size()); return array.size(); } +#endif // CENTIPEDE_RUNNER_NO_MUTATE_LIB // An arbitrary large size for input data. static const size_t kMaxDataSize = 1 << 20; diff --git a/fuzztest/llvm_fuzzer_wrapper.cc b/fuzztest/llvm_fuzzer_wrapper.cc index bbdd7f3a..28048741 100644 --- a/fuzztest/llvm_fuzzer_wrapper.cc +++ b/fuzztest/llvm_fuzzer_wrapper.cc @@ -16,9 +16,7 @@ #include "./fuzztest/internal/domains/container_of_impl.h" #include "./fuzztest/internal/domains/domain_base.h" #include "./fuzztest/internal/io.h" -#ifndef FUZZTEST_USE_CENTIPEDE #include "./fuzztest/internal/coverage.h" -#endif ABSL_DECLARE_FLAG(std::string, llvm_fuzzer_wrapper_dict_file); ABSL_DECLARE_FLAG(std::string, llvm_fuzzer_wrapper_corpus_dir); @@ -127,9 +125,6 @@ class InplaceVector { std::size_t size_; }; -// Centipede runner also provides LLVMFuzzerMutate to support libFuzzer targets -// on its own. So we do not define it when integrating with Centipede. -#ifndef FUZZTEST_USE_CENTIPEDE extern "C" size_t LLVMFuzzerMutate(uint8_t* data, size_t size, size_t max_size) { @@ -147,8 +142,6 @@ extern "C" size_t LLVMFuzzerMutate(uint8_t* data, size_t size, return val.size(); } -#endif - class ArbitraryByteVector : public fuzztest::internal::SequenceContainerOfImpl< std::vector, fuzztest::internal::ArbitraryImpl> {