fuzz: Add support for custom fuzzing library
On oss-fuzz, we must use the LIB_FUZZING_ENGINE and CFLAGS environment variables, rather than -fsanitize=fuzzer. With this change, when LIB_FUZZING_ENGINE is set, the --enable-fuzzing configure option will use that environment variable during the linking stage, rather than -fsanitize=fuzzer Signed-off-by: Alexander Bulekov <alxndr@bu.edu> Message-Id: <20200902173652.307222-3-alxndr@bu.edu> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
c46f76d158
commit
54c9e41d47
10
configure
vendored
10
configure
vendored
@ -6048,7 +6048,7 @@ fi
|
|||||||
|
|
||||||
##########################################
|
##########################################
|
||||||
# checks for fuzzer
|
# checks for fuzzer
|
||||||
if test "$fuzzing" = "yes" ; then
|
if test "$fuzzing" = "yes" && test -z "${LIB_FUZZING_ENGINE+xxx}"; then
|
||||||
write_c_fuzzer_skeleton
|
write_c_fuzzer_skeleton
|
||||||
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
|
if compile_prog "$CPU_CFLAGS -Werror -fsanitize=fuzzer" ""; then
|
||||||
have_fuzzer=yes
|
have_fuzzer=yes
|
||||||
@ -7354,7 +7354,14 @@ if test "$have_mlockall" = "yes" ; then
|
|||||||
echo "HAVE_MLOCKALL=y" >> $config_host_mak
|
echo "HAVE_MLOCKALL=y" >> $config_host_mak
|
||||||
fi
|
fi
|
||||||
if test "$fuzzing" = "yes" ; then
|
if test "$fuzzing" = "yes" ; then
|
||||||
|
# If LIB_FUZZING_ENGINE is set, assume we are running on OSS-Fuzz, and the
|
||||||
|
# needed CFLAGS have already been provided
|
||||||
|
if test -z "${LIB_FUZZING_ENGINE+xxx}" ; then
|
||||||
QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
|
QEMU_CFLAGS="$QEMU_CFLAGS -fsanitize=fuzzer-no-link"
|
||||||
|
FUZZ_EXE_LDFLAGS="-fsanitize=fuzzer"
|
||||||
|
else
|
||||||
|
FUZZ_EXE_LDFLAGS="$LIB_FUZZING_ENGINE"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$plugins" = "yes" ; then
|
if test "$plugins" = "yes" ; then
|
||||||
@ -7455,6 +7462,7 @@ fi
|
|||||||
if test "$fuzzing" != "no"; then
|
if test "$fuzzing" != "no"; then
|
||||||
echo "CONFIG_FUZZ=y" >> $config_host_mak
|
echo "CONFIG_FUZZ=y" >> $config_host_mak
|
||||||
fi
|
fi
|
||||||
|
echo "FUZZ_EXE_LDFLAGS=$FUZZ_EXE_LDFLAGS" >> $config_host_mak
|
||||||
|
|
||||||
if test "$edk2_blobs" = "yes" ; then
|
if test "$edk2_blobs" = "yes" ; then
|
||||||
echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
|
echo "DECOMPRESS_EDK2_BLOBS=y" >> $config_host_mak
|
||||||
|
@ -7,8 +7,8 @@ specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_NET', if_true: files('virtio_net_fuzz.
|
|||||||
specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_SCSI', if_true: files('virtio_scsi_fuzz.c'))
|
specific_fuzz_ss.add(when: 'CONFIG_VIRTIO_SCSI', if_true: files('virtio_scsi_fuzz.c'))
|
||||||
|
|
||||||
fork_fuzz = declare_dependency(
|
fork_fuzz = declare_dependency(
|
||||||
link_args: ['-fsanitize=fuzzer',
|
link_args: config_host['FUZZ_EXE_LDFLAGS'].split() +
|
||||||
'-Wl,-wrap,qtest_inb',
|
['-Wl,-wrap,qtest_inb',
|
||||||
'-Wl,-wrap,qtest_inw',
|
'-Wl,-wrap,qtest_inw',
|
||||||
'-Wl,-wrap,qtest_inl',
|
'-Wl,-wrap,qtest_inl',
|
||||||
'-Wl,-wrap,qtest_outb',
|
'-Wl,-wrap,qtest_outb',
|
||||||
|
Loading…
Reference in New Issue
Block a user