From 42a3f876ada566e0f03934795e4033bc736f437c Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 4 Jan 2024 13:51:52 -0800 Subject: [PATCH] trusty: clear fuzzer's extra counters directly The FuzzerDefs.h APIs are internal to the fuzzer and aren't available when the fuzzer is built with a custom private libc++, so remove the ExtraCountersBegin/ExtraCountersEnd assertions and inline the array clearing. Bug: 175635923 Bug: 303175229 Bug: 315079422 Test: m libtrusty_fuzz_utils trusty_gatekeeper_fuzzer Change-Id: I1ca9d9867026ff6f8e494ac6026fb1314caab7d1 --- trusty/fuzz/Android.bp | 3 --- trusty/fuzz/counters.cpp | 10 +++------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/trusty/fuzz/Android.bp b/trusty/fuzz/Android.bp index 5d0ff7920..8a93e5ee7 100644 --- a/trusty/fuzz/Android.bp +++ b/trusty/fuzz/Android.bp @@ -41,9 +41,6 @@ cc_library { "utils.cpp", ], export_include_dirs: ["include"], - static_libs: [ - "libFuzzer", - ], shared_libs: [ "libtrusty_coverage", "libbase", diff --git a/trusty/fuzz/counters.cpp b/trusty/fuzz/counters.cpp index 65a3ba6f4..e730ec320 100644 --- a/trusty/fuzz/counters.cpp +++ b/trusty/fuzz/counters.cpp @@ -16,12 +16,12 @@ #define LOG_TAG "trusty-fuzz-counters" -#include - #include #include +#include #include +#include #include #include @@ -45,9 +45,6 @@ ExtraCounters::ExtraCounters(coverage::CoverageRecord* record) : record_(record) return; } - assert(fuzzer::ExtraCountersBegin()); - assert(fuzzer::ExtraCountersEnd()); - volatile uint8_t* begin = NULL; volatile uint8_t* end = NULL; record_->GetRawCounts(&begin, &end); @@ -66,9 +63,8 @@ void ExtraCounters::Reset() { if (!record_->IsOpen()) { return; } - record_->ResetCounts(); - fuzzer::ClearExtraCounters(); + memset_explicit(const_cast(counters), 0, sizeof(counters)); } void ExtraCounters::Flush() {