Gcc 如何为AFLGo编译libav

Gcc 如何为AFLGo编译libav,gcc,configure,instrumentation,libav,fuzzer,Gcc,Configure,Instrumentation,Libav,Fuzzer,我需要用AFLGO编译libav库 cd ~ export AFLGO=$PWD/aflgo cd path/to/libav/folder export SUBJECT=$PWD; export TMP_DIR=$PWD/obj-aflgo/temp export CC=$AFLGO/afl-clang-fast export CXX=$AFLGO/afl-clang-fast++ export COPY_CFLAGS=$CFLAGS export COPY_CXXFLAGS=$CXXFLAG

我需要用AFLGO编译libav库

cd ~
export AFLGO=$PWD/aflgo
cd path/to/libav/folder
export SUBJECT=$PWD; export TMP_DIR=$PWD/obj-aflgo/temp
export CC=$AFLGO/afl-clang-fast
export CXX=$AFLGO/afl-clang-fast++
export COPY_CFLAGS=$CFLAGS
export COPY_CXXFLAGS=$CXXFLAGS
export ADDITIONAL="-targets=$TMP_DIR/BBtargets.txt -outdir=$TMP_DIR -flto -fuse-ld=gold -Wl,-plugin-opt=save-temps"
export CFLAGS="$CFLAGS $ADDITIONAL"
export CXXFLAGS="$CXXFLAGS $ADDITIONAL"
export LDFLAGS=-lpthread

./configure
它返回:

gcc is unable to create an executable file.
If gcc is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.

If you think configure made a mistake, make sure you are using the latest
version from Git.  If the latest version fails, report the problem to the
libav-tools@libav.org mailing list or IRC #libav on irc.freenode.net.
Include the log file "avbuild/config.log" produced by configure as this will help
solving the problem.
我已经检查了
config.log
,但它似乎没有用,以下是最后几行:

....
gcc -targets=/home/ubuntu16/Documents/github-repos/libav/obj-aflgo/temp/BBtargets.txt -outdir=/home/ubuntu16/Documents/$
gcc: error: unrecognized command line option '-targets=/home/ubuntu16/Documents/github-repos/libav/obj-aflgo/temp/BBtar$
C compiler test failed.


为什么要再次尝试用gcc编译它?我想使用AFLGo fuzzer对其进行检测。

首先,您应该明确指定编译器和标志,如下所示:

./configure --cc=$CC --enable-lto --extra-ldflags="-flto -fuse-ld=gold -Wl,-plugin-opt=save-temps"
否则,就不能用AFLGo编译libav

如果您想知道其他配置标志,请尝试
/confure--help

但在我尝试之后,无法使用LTO(即-flto)编译libav,因为libav包含一些asm指令,并且LLVM(clang)无法将其转换为IR,这将在链接时导致错误,例如
未定义的引用

CC      libavutil/xtea.o
AR      libavfilter/libavfilter.a
AR      libavcodec/libavcodec.a
AR      libavresample/libavresample.a
AR      libswscale/libswscale.a
AR      libavutil/libavutil.a
LD      avconv
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function put_vc1_mspel_mc01_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc03_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc10_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc12_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc12_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmxext: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmxext: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24C'
clang: error: linker command failed with exit code 1 (use -v to see invocation)


因此,由于LLVM(clang)的缺陷,您无法使用AFLGo构建libav首先,您应该明确指定编译器和标志,如下所示:

./configure --cc=$CC --enable-lto --extra-ldflags="-flto -fuse-ld=gold -Wl,-plugin-opt=save-temps"
否则,就不能用AFLGo编译libav

如果您想知道其他配置标志,请尝试
/confure--help

但在我尝试之后,无法使用LTO(即-flto)编译libav,因为libav包含一些asm指令,并且LLVM(clang)无法将其转换为IR,这将在链接时导致错误,例如
未定义的引用

CC      libavutil/xtea.o
AR      libavfilter/libavfilter.a
AR      libavcodec/libavcodec.a
AR      libavresample/libavresample.a
AR      libswscale/libswscale.a
AR      libavutil/libavutil.a
LD      avconv
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function decode_nal_unit: error: undefined reference to 'ff_h264_cabac_tables'
avconv.o:ld-temp.o:function put_vc1_mspel_mc01_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc03_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc10_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_53'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc11_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc12_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_vc1_mspel_mc12_mmx: error: undefined reference to 'ff_pw_128'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function put_cavs_qpel16_mc01_3dnow: error: undefined reference to 'ff_pw_42'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_w1111'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2VCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmx: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2YOffset'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_3dnow: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function rgb24toyv12_mmxext: error: undefined reference to 'ff_bgr2UCoeff'
avconv.o:ld-temp.o:function rgb24toyv12_mmxext: error: undefined reference to 'ff_bgr2UVOffset'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_ar_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_X_mmxext: error: undefined reference to 'ff_M24B'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24C'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24A'
avconv.o:ld-temp.o:function yuv2bgr24_1_mmxext: error: undefined reference to 'ff_M24C'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

因此您无法使用AFLGo构建libav,因为LLVM(clang)存在缺陷