]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
build-sys: add support for --enable-fuzzing-engine
authorEvgeny Vereshchagin <evvers@ya.ru>
Tue, 28 Jul 2020 04:17:40 +0000 (04:17 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Thu, 6 Aug 2020 12:33:11 +0000 (12:33 +0000)
Signed-off-by: Evgeny Vereshchagin <evvers@ya.ru>
Makefile.am
configure.ac

index 429b6289a72e62ddfe661924cbc77359856308d0..12cb86cba450942cb844a2eaa8111ce0c89883b0 100644 (file)
@@ -10,14 +10,24 @@ AM_CPPFLAGS += \
        -D_PATH_VENDORDIR=\"${vendordir}\"
 endif
 
+if FUZZING_ENGINE
+if !OSS_FUZZ
+AM_CPPFLAGS += \
+       -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
+endif
+endif
+
 AM_CFLAGS = -fsigned-char $(WARN_CFLAGS)
-AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS)
+AM_CXXFLAGS = $(AM_CFLAGS)
+AM_LDFLAGS = $(ASAN_LDFLAGS) $(UBSAN_LDFLAGS) $(FUZZING_ENGINE_LDFLAGS)
 
 # Add gettext stuff to the global LDADD for systems with separate libintl
 # library. The LTLIBINTL is generated by AM_GNU_GETTEXT macro.
 #
 LDADD = $(LTLIBINTL)
 
+LIB_FUZZING_ENGINE ?= -fsanitize=fuzzer
+
 # Automake (at least up to 1.10) mishandles dist_man_MANS inside conditionals.
 # Unlike with other dist primaries, the files are not distributed if the
 # conditional is false.
index 8815d270b8b06a78705f8aa000f5de10222fccc9..94b6ab0682c44f311714a023a2ad33264f41edcd 100644 (file)
@@ -193,8 +193,16 @@ AC_ARG_ENABLE([fuzzing-engine],
   AS_HELP_STRING([--enable-fuzzing-engine], [compile with fuzzing engine]),
   [], [enable_fuzzing_engine=no]
 )
+AS_IF([test "x$enable_fuzzing_engine" = xyes -a "x$LIB_FUZZING_ENGINE" = x], [
+  UL_WARN_ADD([-fno-omit-frame-pointer])
+  UL_WARN_ADD([-gline-tables-only])
+  UL_WARN_ADD([-fsanitize=fuzzer-no-link])
+  FUZZING_ENGINE_LDFLAGS="-fsanitize=fuzzer-no-link"
+])
+AC_SUBST([FUZZING_ENGINE_LDFLAGS])
 AC_PROG_CXX
-AM_CONDITIONAL([FUZZING_ENGINE], [test x$enable_fuzzing_engine = xyes])
+AM_CONDITIONAL([FUZZING_ENGINE], [test "x$enable_fuzzing_engine" = xyes])
+AM_CONDITIONAL([OSS_FUZZ], [test "x$LIB_FUZZING_ENGINE" != x])
 
 dnl libtool-2
 LT_INIT