Make tools/target_dec_*_fuzzer buildable with configure and make
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 21 Apr 2017 21:58:32 +0000 (23:58 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 24 Apr 2017 21:17:47 +0000 (23:17 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Makefile
configure
tools/Makefile

index 559c5b8..fcee739 100644 (file)
--- 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))                 \
index 1e3463c..f4bcbe2 100755 (executable)
--- 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(){
index 49f55d2..2b9432b 100644 (file)
@@ -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::