From 5b499bf4a05ae7db3390cd7e6f08228488aea10c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 21 Apr 2017 23:58:32 +0200 Subject: [PATCH] Make tools/target_dec_*_fuzzer buildable with configure and make Signed-off-by: Michael Niedermayer --- Makefile | 4 ++++ configure | 12 ++++++++++++ tools/Makefile | 10 ++++++++++ 3 files changed, 26 insertions(+) diff --git a/Makefile b/Makefile index 559c5b8d5f..fcee739405 100644 --- a/Makefile +++ b/Makefile @@ -77,9 +77,13 @@ all: $(AVPROGS) $(TOOLS): %$(EXESUF): %.o $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) +target_dec_%_fuzzer$(EXESUF): target_dec_%_fuzzer.o $(FF_DEP_LIBS) + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $^ $(ELIBS) $(FF_EXTRALIBS) $(LIBFUZZER_PATH) + tools/cws2fws$(EXESUF): ELIBS = $(ZLIB) tools/uncoded_frame$(EXESUF): $(FF_DEP_LIBS) tools/uncoded_frame$(EXESUF): ELIBS = $(FF_EXTRALIBS) +tools/target_dec_%_fuzzer$(EXESUF): $(FF_DEP_LIBS) CONFIGURABLE_COMPONENTS = \ $(wildcard $(FFLIBS:%=$(SRC_PATH)/lib%/all*.c)) \ diff --git a/configure b/configure index 1e3463c2c9..f4bcbe2c9d 100755 --- a/configure +++ b/configure @@ -438,6 +438,8 @@ Developer options (useful when working on FFmpeg itself): --random-seed=VALUE seed value for --enable/disable-random --disable-valgrind-backtrace do not print a backtrace under Valgrind (only applies to --disable-optimizations builds) + --enable-osfuzz Enable building fuzzer tool + --libfuzzer=PATH path to libfuzzer NOTE: Object files are built at the place where configure is launched. EOF @@ -1676,6 +1678,7 @@ CONFIG_LIST=" fontconfig memory_poisoning neon_clobber_test + ossfuzz pic raise_major thumb @@ -3509,6 +3512,9 @@ for opt do ;; --fatal-warnings) enable fatal_warnings ;; + --libfuzzer=*) + libfuzzer_path="$optval" + ;; *) optname="${opt%%=*}" optname="${optname#--}" @@ -3577,6 +3583,11 @@ set >> $logfile test -n "$valgrind" && toolchain="valgrind-memcheck" +enabled ossfuzz && { + add_cflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp -fno-omit-frame-pointer + add_ldflags -fsanitize=address,undefined -fsanitize-coverage=trace-pc-guard,trace-cmp +} + case "$toolchain" in *-asan) cc_default="${toolchain%-asan}" @@ -6737,6 +6748,7 @@ SLIB_INSTALL_EXTRA_SHLIB=${SLIB_INSTALL_EXTRA_SHLIB} VERSION_SCRIPT_POSTPROCESS_CMD=${VERSION_SCRIPT_POSTPROCESS_CMD} SAMPLES:=${samples:-\$(FATE_SAMPLES)} NOREDZONE_FLAGS=$noredzone_flags +LIBFUZZER_PATH=$libfuzzer_path EOF get_version(){ diff --git a/tools/Makefile b/tools/Makefile index 49f55d2a9e..2b9432bcc2 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,6 +1,16 @@ TOOLS = qt-faststart trasher uncoded_frame TOOLS-$(CONFIG_ZLIB) += cws2fws +tools/target_dec_video_%_fuzzer.o: tools/target_dec_fuzzer.c + $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_VIDEO + +tools/target_dec_audio_%_fuzzer.o: tools/target_dec_fuzzer.c + $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_AUDIO + +tools/target_dec_subtitle_%_fuzzer.o: tools/target_dec_fuzzer.c + $(COMPILE_C) -DFFMPEG_CODEC=AV_CODEC_ID_$* -DFUZZ_FFMPEG_SUBTITLE + + OBJDIRS += tools clean::