Add configure option to replace main with a stub for fuzzing

This commit is contained in:
Taylor Hornby 2019-10-22 12:58:40 -06:00
parent 586f54fc39
commit 8a0fb36b21
2 changed files with 12 additions and 1 deletions

View File

@ -107,6 +107,12 @@ AC_ARG_ENABLE(tests,
[use_tests=$enableval],
[use_tests=yes])
AC_ARG_ENABLE([fuzz-main],
[AS_HELP_STRING([--enable-fuzz-main],
[Replace main() with a stub for fuzzing (default is no)])],
[use_fuzz_main=$enableval],
[use_fuzz_main=no])
AC_ARG_ENABLE([asan],
[AS_HELP_STRING([--enable-asan],
[instrument the executables with asan (default is no)])],
@ -447,6 +453,11 @@ if test x$TARGET_OS != xwindows; then
AX_CHECK_COMPILE_FLAG([-fPIC],[PIC_FLAGS="-fPIC"])
fi
if test x$use_fuzz_main == xyes; then
CFLAGS="$CFLAGS -DZCASH_FUZZ=1"
CXXFLAGS="$CXXFLAGS -DZCASH_FUZZ=1"
fi
#asan and tsan cannot be used together
if test x$use_asan$use_tsan == xyesyes; then
AC_MSG_ERROR(asan and tsan cannot be simultaneously enabled)

View File

@ -10,4 +10,4 @@ export AFL_LOG_DIR="$(pwd)"
export ZCUTIL=$(realpath "./zcutil")
shift 1
CONFIGURE_FLAGS=--enable-tests=no "$ZCUTIL/build.sh" "CC=$ZCUTIL/afl/zcash-wrapper-gcc" "CXX=$ZCUTIL/afl/zcash-wrapper-g++" AFL_HARDEN=1 "$@"
CONFIGURE_FLAGS="--enable-tests=no --enable-fuzz-main" "$ZCUTIL/build.sh" "CC=$ZCUTIL/afl/zcash-wrapper-gcc" "CXX=$ZCUTIL/afl/zcash-wrapper-g++" AFL_HARDEN=1 "$@"