diff options
author | Fabian Meumertzheim <fabian@meumertzhe.im> | 2022-03-23 08:38:52 +0100 |
---|---|---|
committer | Fabian Meumertzheim <fabian@meumertzhe.im> | 2022-03-23 17:17:29 +0100 |
commit | 5b8914a1e2d3765b42883589a5da1229b37ab89a (patch) | |
tree | 96770e60c34022ef71c6e1caea8861c9de5dc6a6 | |
parent | 687721eb07f3618af38a4b83149ac125368aa894 (diff) | |
download | jazzer-api-5b8914a1e2d3765b42883589a5da1229b37ab89a.tar.gz |
Write coverage profiles also on a finding
-rw-r--r-- | driver/libfuzzer_fuzz_target.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/driver/libfuzzer_fuzz_target.cpp b/driver/libfuzzer_fuzz_target.cpp index d258e519..77e0ec7d 100644 --- a/driver/libfuzzer_fuzz_target.cpp +++ b/driver/libfuzzer_fuzz_target.cpp @@ -63,6 +63,14 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; } +#ifndef _WIN32 +__attribute__((weak)) +#endif +extern "C" int +__llvm_profile_write_file(void) { + return 0; +} + // Called by the fuzzer for every fuzzing input. extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) { auto result = gLibfuzzerDriver->TestOneInput(data, size); @@ -80,6 +88,9 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, const size_t size) { } // Exit directly without invoking libFuzzer's atexit hook. driver_cleanup(); + // When running with LLVM coverage instrumentation, write out the profile as + // the exit hook that write it won't run. + __llvm_profile_write_file(); _Exit(Driver::kErrorExitCode); } return 0; |