AFLplusplus / LibAFL

Advanced Fuzzing Library - Slot your Fuzzer together in Rust! Scales across cores and machines. For Windows, Android, MacOS, Linux, no_std, ...
Other
2.03k stars 319 forks source link

Dictionary linking error with libjpeg-turbo #1079

Closed andreafioraldi closed 1 year ago

andreafioraldi commented 1 year ago

Problably related to autotkens symbols, see https://github.com/google/fuzzbench/actions/runs/4192738695/jobs/7268711483

tokatoka commented 1 year ago

Yes I can reproduce

tokatoka commented 1 year ago

[ 28%] Linking C shared library libturbojpeg.so [ "/usr/lib/llvm-14/bin/clang", "-fPIC", "-O3", "-DNDEBUG", "-Wl,--version-script,/home/toka/LibAFL/fuzzers/fuzzbench/libjpeg-turbo/turbojpeg-mapfile", "-shared", "-Wl,-soname,libturbojpeg.so.0", "-o", "libturbojpeg.so.0.3.0", "CMakeFiles/turbojpeg.dir/jcapimin.c.o", "CMakeFiles/turbojpeg.dir/jcapistd.c.o", "CMakeFiles/turbojpeg.dir/jccoefct.c.o", "CMakeFiles/turbojpeg.dir/jccolor.c.o", "CMakeFiles/turbojpeg.dir/jcdctmgr.c.o", "CMakeFiles/turbojpeg.dir/jcdiffct.c.o", "CMakeFiles/turbojpeg.dir/jchuff.c.o", "CMakeFiles/turbojpeg.dir/jcicc.c.o", "CMakeFiles/turbojpeg.dir/jcinit.c.o", "CMakeFiles/turbojpeg.dir/jclhuff.c.o", "CMakeFiles/turbojpeg.dir/jclossls.c.o", "CMakeFiles/turbojpeg.dir/jcmainct.c.o", "CMakeFiles/turbojpeg.dir/jcmarker.c.o", "CMakeFiles/turbojpeg.dir/jcmaster.c.o", "CMakeFiles/turbojpeg.dir/jcomapi.c.o", "CMakeFiles/turbojpeg.dir/jcparam.c.o", "CMakeFiles/turbojpeg.dir/jcphuff.c.o", "CMakeFiles/turbojpeg.dir/jcprepct.c.o", "CMakeFiles/turbojpeg.dir/jcsample.c.o", "CMakeFiles/turbojpeg.dir/jctrans.c.o", "CMakeFiles/turbojpeg.dir/jdapimin.c.o", "CMakeFiles/turbojpeg.dir/jdapistd.c.o", "CMakeFiles/turbojpeg.dir/jdatadst.c.o", "CMakeFiles/turbojpeg.dir/jdatasrc.c.o", "CMakeFiles/turbojpeg.dir/jdcoefct.c.o", "CMakeFiles/turbojpeg.dir/jdcolor.c.o", "CMakeFiles/turbojpeg.dir/jddctmgr.c.o", "CMakeFiles/turbojpeg.dir/jddiffct.c.o", "CMakeFiles/turbojpeg.dir/jdhuff.c.o", "CMakeFiles/turbojpeg.dir/jdicc.c.o", "CMakeFiles/turbojpeg.dir/jdinput.c.o", "CMakeFiles/turbojpeg.dir/jdlhuff.c.o", "CMakeFiles/turbojpeg.dir/jdlossls.c.o", "CMakeFiles/turbojpeg.dir/jdmainct.c.o", "CMakeFiles/turbojpeg.dir/jdmarker.c.o", "CMakeFiles/turbojpeg.dir/jdmaster.c.o", "CMakeFiles/turbojpeg.dir/jdmerge.c.o", "CMakeFiles/turbojpeg.dir/jdphuff.c.o", "CMakeFiles/turbojpeg.dir/jdpostct.c.o", "CMakeFiles/turbojpeg.dir/jdsample.c.o", "CMakeFiles/turbojpeg.dir/jdtrans.c.o", "CMakeFiles/turbojpeg.dir/jerror.c.o", "CMakeFiles/turbojpeg.dir/jfdctflt.c.o", "CMakeFiles/turbojpeg.dir/jfdctfst.c.o", "CMakeFiles/turbojpeg.dir/jfdctint.c.o", "CMakeFiles/turbojpeg.dir/jidctflt.c.o", "CMakeFiles/turbojpeg.dir/jidctfst.c.o", "CMakeFiles/turbojpeg.dir/jidctint.c.o", "CMakeFiles/turbojpeg.dir/jidctred.c.o", "CMakeFiles/turbojpeg.dir/jquant1.c.o", "CMakeFiles/turbojpeg.dir/jquant2.c.o", "CMakeFiles/turbojpeg.dir/jutils.c.o", "CMakeFiles/turbojpeg.dir/jmemmgr.c.o", "CMakeFiles/turbojpeg.dir/jmemnobs.c.o", "CMakeFiles/turbojpeg.dir/jaricom.c.o", "CMakeFiles/turbojpeg.dir/jcarith.c.o", "CMakeFiles/turbojpeg.dir/jdarith.c.o", "CMakeFiles/turbojpeg.dir/turbojpeg.c.o", "CMakeFiles/turbojpeg.dir/transupp.c.o", "CMakeFiles/turbojpeg.dir/jdatadst-tj.c.o", "CMakeFiles/turbojpeg.dir/jdatasrc-tj.c.o", "CMakeFiles/turbojpeg.dir/rdbmp.c.o", "CMakeFiles/turbojpeg.dir/rdppm.c.o", "CMakeFiles/turbojpeg.dir/wrbmp.c.o", "CMakeFiles/turbojpeg.dir/wrppm.c.o", "CMakeFiles/jpeg12.dir/jcapistd.c.o", "CMakeFiles/jpeg12.dir/jccoefct.c.o", "CMakeFiles/jpeg12.dir/jccolor.c.o", "CMakeFiles/jpeg12.dir/jcdctmgr.c.o", "CMakeFiles/jpeg12.dir/jcdiffct.c.o", "CMakeFiles/jpeg12.dir/jclossls.c.o", "CMakeFiles/jpeg12.dir/jcmainct.c.o", "CMakeFiles/jpeg12.dir/jcprepct.c.o", "CMakeFiles/jpeg12.dir/jcsample.c.o", "CMakeFiles/jpeg12.dir/jdapistd.c.o", "CMakeFiles/jpeg12.dir/jdcoefct.c.o", "CMakeFiles/jpeg12.dir/jdcolor.c.o", "CMakeFiles/jpeg12.dir/jddctmgr.c.o", "CMakeFiles/jpeg12.dir/jddiffct.c.o", "CMakeFiles/jpeg12.dir/jdlossls.c.o", "CMakeFiles/jpeg12.dir/jdmainct.c.o", "CMakeFiles/jpeg12.dir/jdmerge.c.o", "CMakeFiles/jpeg12.dir/jdpostct.c.o", "CMakeFiles/jpeg12.dir/jdsample.c.o", "CMakeFiles/jpeg12.dir/jfdctfst.c.o", "CMakeFiles/jpeg12.dir/jfdctint.c.o", "CMakeFiles/jpeg12.dir/jidctflt.c.o", "CMakeFiles/jpeg12.dir/jidctfst.c.o", "CMakeFiles/jpeg12.dir/jidctint.c.o", "CMakeFiles/jpeg12.dir/jidctred.c.o", "CMakeFiles/jpeg12.dir/jquant1.c.o", "CMakeFiles/jpeg12.dir/jquant2.c.o", "CMakeFiles/jpeg12.dir/jutils.c.o", "CMakeFiles/jpeg16.dir/jcapistd.c.o", "CMakeFiles/jpeg16.dir/jccolor.c.o", "CMakeFiles/jpeg16.dir/jcdiffct.c.o", "CMakeFiles/jpeg16.dir/jclossls.c.o", "CMakeFiles/jpeg16.dir/jcmainct.c.o", "CMakeFiles/jpeg16.dir/jcprepct.c.o", "CMakeFiles/jpeg16.dir/jcsample.c.o", "CMakeFiles/jpeg16.dir/jdapistd.c.o", "CMakeFiles/jpeg16.dir/jdcolor.c.o", "CMakeFiles/jpeg16.dir/jddiffct.c.o", "CMakeFiles/jpeg16.dir/jdlossls.c.o", "CMakeFiles/jpeg16.dir/jdmainct.c.o", "CMakeFiles/jpeg16.dir/jdpostct.c.o", "CMakeFiles/jpeg16.dir/jdsample.c.o", "CMakeFiles/jpeg16.dir/jquant1.c.o", "CMakeFiles/jpeg16.dir/jquant2.c.o", "CMakeFiles/jpeg16.dir/jutils.c.o", "CMakeFiles/turbojpeg12.dir/rdppm.c.o", "CMakeFiles/turbojpeg12.dir/wrppm.c.o", "CMakeFiles/turbojpeg16.dir/rdppm.c.o", "CMakeFiles/turbojpeg16.dir/wrppm.c.o", "-Wl,-rpath,::::::::::::::::::::::::", "-fsanitize-coverage=trace-pc-guard,trace-cmp", "-g", "-O3", "-funroll-loops", "-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION=1", "-fexperimental-new-pass-manager", "-Xclang", "-load", "-Xclang", "/home/toka/LibAFL/fuzzers/fuzzbench/target/release/build/libafl_cc-aa7845e753cdd138/out/autotokens-pass.so", "-Xclang", "-fpass-plugin=/home/toka/LibAFL/fuzzers/fuzzbench/target/release/build/libafl_cc-aa7845e753cdd138/out/autotokens-pass.so", "-Xclang", "-load", "-Xclang", "/home/toka/LibAFL/fuzzers/fuzzbench/target/release/build/libafl_cc-aa7845e753cdd138/out/cmplog-routines-pass.so", "-Xclang", "-fpass-plugin=/home/toka/LibAFL/fuzzers/fuzzbench/target/release/build/libafl_cc-aa7845e753cdd138/out/cmplog-routines-pass.so", ]

When they compile libturbojpeg.so they take two the same(?) object file but in two different directory

For example CMakeFiles/jpeg12.dir/jcsample.c.o: and CMakeFiles/turbojpeg.dir/jcsample.c.o: but these two are from the same C source file /home/toka/LibAFL/fuzzers/fuzzbench/libjpeg-turbo/jcsample.c so that's why multiple difinition happens

andreafioraldi commented 1 year ago

yes this is common as build systems are shit, but in theory the linker should simply take the first symbols in the command line, unless --whole-archive is used

tokatoka commented 1 year ago

unless --whole-archive is used

yeah but I think that's when using .a file(?). it's compiling multiple .o now.

I just weak linked them in the PR