If detected, COND_ENABLE_FUZZERS is set, which can be used in Makefile
templates.
This allows us to build libfuzzer fuzzers for parts of grub.
---
configure.ac | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/configure.ac b/configure.ac
index ca42ff8f7318..f7f305482e59 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1922,6 +1922,31 @@ fi
AC_SUBST([LIBZFS])
AC_SUBST([LIBNVPAIR])
+AC_ARG_ENABLE([fuzzers],
+ [AS_HELP_STRING([--enable-fuzzers],
+ [enable fuzzers (default=guessed)])])
+if test x"$enable_fuzzers" = xno ; then
+ fuzzers_excuse="explicitly disabled"
+fi
+
+if test x"$fuzzers_excuse" = x ; then
+ SAVED_CFLAGS="$CFLAGS"
+ SAVED_CC="$CC"
+ CC="$HOST_CC"
+ CFLAGS="$HOST_CFLAGS -fsanitize=fuzzer"
+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stddef.h>
+#include <stdint.h>
+int LLVMFuzzerTestOneInput(const uint8_t Data, size_t Size) {return 0;}]],
[[]])],
+ [],
+ [fuzzers_excuse="-fsanitize=fuzzer not supported by host compiler"])
+ CFLAGS="$SAVED_CFLAGS"
+ CC="$SAVED_CC"
+fi
+
+if test x"$enable_fuzzers" = xyes && test x"$fuzzers_excuse" != x ; then
+ AC_MSG_ERROR([fuzzers were explicitly requested but requirements are not
satisfied ($fuzzers_excuse)])
+fi
+
LIBS=""
AC_SUBST([FONT_SOURCE])
@@ -2054,6 +2079,8 @@ AM_CONDITIONAL([COND_STARFIELD], [test
"x$starfield_excuse" = x])
AM_CONDITIONAL([COND_HAVE_EXEC], [test "x$have_exec" = xy])
AM_CONDITIONAL([COND_HAVE_PCI], [test "x$have_pci" = xy])
+AM_CONDITIONAL([COND_ENABLE_FUZZERS], [test "x$fuzzers_excuse" = x])
+
test "x$prefix" = xNONE && prefix="$ac_default_prefix"
test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
datarootdir="$(eval echo "$datarootdir")"
@@ -2189,5 +2216,10 @@ echo "With stack smashing protector: Yes"
else
echo "With stack smashing protector: No"
fi
+if [ x"$fuzzers_excuse" = x ]; then
+echo With fuzzers: Yes
+else
+echo With fuzzers: No "($fuzzers_excuse)"
+fi
echo "*******************************************************"
]
--
2.25.1
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel