mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-12 11:19:08 -05:00
tests: Provide main(...) function in fuzzer
This commit is contained in:
parent
80fd474e40
commit
1087807b2b
1 changed files with 12 additions and 4 deletions
|
@ -12,7 +12,16 @@
|
||||||
|
|
||||||
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
||||||
|
|
||||||
#if defined(__AFL_COMPILER)
|
// Decide if main(...) should be provided:
|
||||||
|
// * AFL needs main(...) regardless of platform.
|
||||||
|
// * macOS handles __attribute__((weak)) main(...) poorly when linking
|
||||||
|
// against libFuzzer. See https://github.com/bitcoin/bitcoin/pull/18008
|
||||||
|
// for details.
|
||||||
|
#if defined(__AFL_COMPILER) || !defined(MAC_OSX)
|
||||||
|
#define PROVIDE_MAIN_FUNCTION
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(PROVIDE_MAIN_FUNCTION)
|
||||||
static bool read_stdin(std::vector<uint8_t>& data)
|
static bool read_stdin(std::vector<uint8_t>& data)
|
||||||
{
|
{
|
||||||
uint8_t buffer[1024];
|
uint8_t buffer[1024];
|
||||||
|
@ -44,9 +53,8 @@ extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generally, the fuzzer will provide main(), except for AFL
|
#if defined(PROVIDE_MAIN_FUNCTION)
|
||||||
#if defined(__AFL_COMPILER)
|
__attribute__((weak)) int main(int argc, char** argv)
|
||||||
int main(int argc, char** argv)
|
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
#ifdef __AFL_INIT
|
#ifdef __AFL_INIT
|
||||||
|
|
Loading…
Add table
Reference in a new issue