|
|
|||
File indexing completed on 2026-05-10 08:43:56
0001 //===-- FuzzerCLI.h - Common logic for CLIs of fuzzers ----------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // Common logic needed to implement LLVM's fuzz targets' CLIs - including LLVM 0010 // concepts like cl::opt and libFuzzer concepts like -ignore_remaining_args=1. 0011 // 0012 //===----------------------------------------------------------------------===// 0013 0014 #ifndef LLVM_FUZZMUTATE_FUZZERCLI_H 0015 #define LLVM_FUZZMUTATE_FUZZERCLI_H 0016 0017 #include "llvm/Support/DataTypes.h" 0018 #include <stddef.h> 0019 0020 namespace llvm { 0021 0022 class StringRef; 0023 0024 /// Parse cl::opts from a fuzz target commandline. 0025 /// 0026 /// This handles all arguments after -ignore_remaining_args=1 as cl::opts. 0027 void parseFuzzerCLOpts(int ArgC, char *ArgV[]); 0028 0029 /// Handle backend options that are encoded in the executable name. 0030 /// 0031 /// Parses some common backend options out of a specially crafted executable 0032 /// name (argv[0]). For example, a name like llvm-foo-fuzzer--aarch64-gisel 0033 /// might set up an AArch64 triple and the Global ISel selector. This should be 0034 /// called *before* parseFuzzerCLOpts if calling both. 0035 /// 0036 /// This is meant to be used for environments like OSS-Fuzz that aren't capable 0037 /// of passing in command line arguments in the normal way. 0038 void handleExecNameEncodedBEOpts(StringRef ExecName); 0039 0040 /// Handle optimizer options which are encoded in the executable name. 0041 /// Same semantics as in 'handleExecNameEncodedBEOpts'. 0042 void handleExecNameEncodedOptimizerOpts(StringRef ExecName); 0043 0044 using FuzzerTestFun = int (*)(const uint8_t *Data, size_t Size); 0045 using FuzzerInitFun = int (*)(int *argc, char ***argv); 0046 0047 /// Runs a fuzz target on the inputs specified on the command line. 0048 /// 0049 /// Useful for testing fuzz targets without linking to libFuzzer. Finds inputs 0050 /// in the argument list in a libFuzzer compatible way. 0051 int runFuzzerOnInputs( 0052 int ArgC, char *ArgV[], FuzzerTestFun TestOne, 0053 FuzzerInitFun Init = [](int *, char ***) { return 0; }); 0054 0055 } // namespace llvm 0056 0057 #endif // LLVM_FUZZMUTATE_FUZZERCLI_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|