1 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2 // See https://llvm.org/LICENSE.txt for license information.
3 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 // Link this tiny library to a binary compiled with
6 // -fsanitize-coverage=inline-8bit-counters.
7 // When passed SANCOV_OUT=OUTPUT_PATH, the process will
8 // dump the 8-bit coverage counters to the file, assuming
9 // the regular exit() is called.
11 // See OutOfProcessFuzzTarget.cpp for usage.
15 static char *CovStart
, *CovEnd
;
17 static void DumpCoverage() {
18 if (const char *DumpPath
= getenv("SANCOV_OUT")) {
19 fprintf(stderr
, "SanCovDump: %p %p %s\n", CovStart
, CovEnd
, DumpPath
);
20 if (FILE *f
= fopen(DumpPath
, "w")) {
21 fwrite(CovStart
, 1, CovEnd
- CovStart
, f
);
27 extern "C" void __sanitizer_cov_8bit_counters_init(char *Start
, char *End
) {