mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 18:09:47 +01:00
fuzz: Configure check for main function
This commit is contained in:
parent
54fc96ffa7
commit
fae7a1c188
14
configure.ac
14
configure.ac
@ -1165,6 +1165,20 @@ if test "x$enable_fuzz" = "xyes"; then
|
||||
use_bench=no
|
||||
use_upnp=no
|
||||
use_zmq=no
|
||||
|
||||
AC_MSG_CHECKING([whether main function is needed])
|
||||
AX_CHECK_LINK_FLAG(
|
||||
[[-fsanitize=$use_sanitizers]],
|
||||
[AC_MSG_RESULT([no])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
CPPFLAGS="$CPPFLAGS -DPROVIDE_MAIN_FUNCTION"],
|
||||
[],
|
||||
[AC_LANG_PROGRAM([[
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { return 0; }
|
||||
/* unterminated comment to remove the main function ...
|
||||
]],[[]])])
|
||||
else
|
||||
BITCOIN_QT_INIT
|
||||
|
||||
|
@ -12,15 +12,6 @@
|
||||
|
||||
const std::function<void(const std::string&)> G_TEST_LOG_FUN{};
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user