From 3dd707ed58bc527b5d501b5656b210e89fdd745d Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Wed, 7 Dec 2016 11:41:08 -0800 Subject: [PATCH] [infra] using -lFuzzingEngine instead of -lfuzzer --- docs/new_project_guide.md | 17 ++++++++++------- infra/base-images/base-libfuzzer/README.md | 4 ++-- infra/templates.py | 2 +- projects/boringssl/build.sh | 2 +- projects/c-ares/build.sh | 2 +- projects/curl/build.sh | 2 +- projects/expat/build.sh | 2 +- projects/ffmpeg/build.sh | 2 +- projects/file/build.sh | 2 +- projects/freetype2/build.sh | 2 +- projects/harfbuzz/build.sh | 2 +- projects/icu/build.sh | 2 +- projects/json/build.sh | 2 +- projects/lcms/build.sh | 2 +- projects/libarchive/build.sh | 2 +- projects/libass/build.sh | 2 +- projects/libchewing/build.sh | 2 +- projects/libjpeg-turbo/build.sh | 2 +- projects/libpng/build.sh | 2 +- projects/libteken/build.sh | 2 +- projects/libtsm/build.sh | 2 +- projects/libxml2/build.sh | 2 +- projects/libyaml/build.sh | 2 +- projects/nss/build.sh | 2 +- projects/ots/build.sh | 2 +- projects/pcre2/build.sh | 2 +- projects/re2/build.sh | 2 +- projects/sqlite3/build.sh | 2 +- projects/woff2/build.sh | 2 +- projects/zlib/build.sh | 2 +- 30 files changed, 40 insertions(+), 37 deletions(-) diff --git a/docs/new_project_guide.md b/docs/new_project_guide.md index 788fecec1..38376dcc2 100644 --- a/docs/new_project_guide.md +++ b/docs/new_project_guide.md @@ -92,7 +92,7 @@ make -j$(nproc) all $CXX $CXXFLAGS -std=c++11 -Ilib/ \ $SRC/parse_fuzzer.cc -o $OUT/parse_fuzzer \ - -lfuzzer .libs/libexpat.a + -lFuzzingEngine .libs/libexpat.a cp $SRC/*.dict $SRC/*.options $OUT/ ``` @@ -101,12 +101,15 @@ cp $SRC/*.dict $SRC/*.options $OUT/ When build.sh script is executed, the following locations are available within the image: -| Path | Description -| ------ | ----- -| `/out/` (`$OUT`) | Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). -| `/src/` (`$SRC`) | Directory to checkout source files. -| `/work/`(`$WORK`) | Directory for storing intermediate files | -| `/usr/lib/libfuzzer.a` | Location of prebuilt libFuzzer library that needs to be linked into all fuzz targets (`-lfuzzer`). +| Location|Env| Description | +|---------| -------- | ---------- | +| `/out/` | `$OUT` | Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). | +| `/src/` | `$SRC` | Directory to checkout source files | +| `/work/`| `$WORK` | Directory for storing intermediate files | +| `/usr/lib/libFuzzingEngine.a` | `$LIB_FUZZING_ENGINE` | Location of prebuilt fuzzing engine library (e.g. libFuzzer ) that needs to be linked with all fuzz targets (`-lFuzzingEngine`). + +While files layout is fixed within a container, the environment variables are +provided to be able to write retargetable scripts. You *must* use the special compiler flags needed to build your project and fuzz targets. These flags are provided in the following environment variables: diff --git a/infra/base-images/base-libfuzzer/README.md b/infra/base-images/base-libfuzzer/README.md index d69f94f7e..91c008853 100644 --- a/infra/base-images/base-libfuzzer/README.md +++ b/infra/base-images/base-libfuzzer/README.md @@ -58,9 +58,9 @@ docker run --rm -ti -e SANITIZER=undefined ossfuzz/sqlite3 | `/out/` | `$OUT` | Directory to store build artifacts (fuzz targets, dictionaries, options files, seed corpus archives). | | `/src/` | `$SRC` | Directory to checkout source files | | `/work/`| `$WORK` | Directory for storing intermediate files | -| `/usr/lib/libfuzzer.a` | | Location of prebuilt libFuzzer library that needs to be linked into all fuzz targets (`-lfuzzer`). | +| `/usr/lib/libFuzzingEngine.a` | `$LIB_FUZZING_ENGINE` | Location of prebuilt fuzzing engine library (e.g. libFuzzer ) that needs to be linked with all fuzz targets (`-lFuzzingEngine`). -While files layout is fixed within a container, `$SRC`, `$OUT`, `$WORK` are +While files layout is fixed within a container, the environment variables are provided to be able to write retargetable scripts. diff --git a/infra/templates.py b/infra/templates.py index be6cdb4c9..daef4533f 100755 --- a/infra/templates.py +++ b/infra/templates.py @@ -72,5 +72,5 @@ BUILD_TEMPLATE = """\ # e.g. # $CXX $CXXFLAGS -std=c++11 -Iinclude \\ # /path/to/name_of_fuzzer.cc -o /out/name_of_fuzzer \\ -# -lfuzzer /path/to/library.a +# -lFuzzingEngine /path/to/library.a """ diff --git a/projects/boringssl/build.sh b/projects/boringssl/build.sh index 832b96654..4c0a1aba6 100755 --- a/projects/boringssl/build.sh +++ b/projects/boringssl/build.sh @@ -34,7 +34,7 @@ for F in $fuzzerFiles; do fuzzerName=$(basename $F .cc) echo "Building fuzzer $fuzzerName" $CXX $CXXFLAGS -std=c++11 \ - -o $OUT/${fuzzerName} -lfuzzer $F \ + -o $OUT/${fuzzerName} -lFuzzingEngine $F \ -I $SRC/boringssl/include ./ssl/libssl.a ./crypto/libcrypto.a if [ -d "$SRC/boringssl/fuzz/${fuzzerName}_corpus" ]; then diff --git a/projects/c-ares/build.sh b/projects/c-ares/build.sh index 965a5971a..8b3f1f69e 100755 --- a/projects/c-ares/build.sh +++ b/projects/c-ares/build.sh @@ -25,4 +25,4 @@ make -j$(nproc) V=1 all $CXX $CXXFLAGS -std=c++11 -I. \ $SRC/c_ares_ares_create_query_fuzzer.cc \ -o $OUT/c_ares_ares_create_query_fuzzer \ - -lfuzzer $SRC/c-ares/.libs/libcares.a + -lFuzzingEngine $SRC/c-ares/.libs/libcares.a diff --git a/projects/curl/build.sh b/projects/curl/build.sh index 35deec899..b6f3faa11 100755 --- a/projects/curl/build.sh +++ b/projects/curl/build.sh @@ -20,7 +20,7 @@ make -j$(nproc) $CXX $CXXFLAGS $SRC/curl_fuzzer.cc -Iinclude lib/.libs/libcurl.a \ -o $OUT/curl_fuzzer \ - -Wl,-Bstatic -lssl -lcrypto -lz -lfuzzer -Wl,-Bdynamic + -Wl,-Bstatic -lssl -lcrypto -lz -lFuzzingEngine -Wl,-Bdynamic # /usr/lib/x86_64-linux-gnu/libssl.a \ # /usr/lib/x86_64-linux-gnu/libcrypto.a \ diff --git a/projects/expat/build.sh b/projects/expat/build.sh index 06e03612d..7b6b024f0 100755 --- a/projects/expat/build.sh +++ b/projects/expat/build.sh @@ -22,6 +22,6 @@ make -j$(nproc) all $CXX $CXXFLAGS -std=c++11 -Ilib/ \ $SRC/parse_fuzzer.cc -o $OUT/parse_fuzzer \ - -lfuzzer .libs/libexpat.a + -lFuzzingEngine .libs/libexpat.a cp $SRC/*.dict $SRC/*.options $OUT/ diff --git a/projects/ffmpeg/build.sh b/projects/ffmpeg/build.sh index 4c90217ad..f8379b324 100755 --- a/projects/ffmpeg/build.sh +++ b/projects/ffmpeg/build.sh @@ -172,7 +172,7 @@ cd $SRC/ffmpeg export TEMP_VAR_CODEC="AV_CODEC_ID_H264" export TEMP_VAR_CODEC_TYPE="VIDEO" -FFMPEG_FUZZERS_COMMON_FLAGS="-lfuzzer /usr/local/lib/libc++.a \ +FFMPEG_FUZZERS_COMMON_FLAGS="-lFuzzingEngine /usr/local/lib/libc++.a \ -L$FFMPEG_DEPS_PATH/lib \ -Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample \ -Llibavutil -Llibpostproc -Llibswscale -Llibswresample \ diff --git a/projects/file/build.sh b/projects/file/build.sh index 6a5867a5b..28b7cc274 100755 --- a/projects/file/build.sh +++ b/projects/file/build.sh @@ -21,7 +21,7 @@ make V=1 all $CXX $CXXFLAGS -std=c++11 -Isrc/ \ $SRC/magic_fuzzer.cc -o $OUT/magic_fuzzer \ - -lfuzzer ./src/.libs/libmagic.a + -lFuzzingEngine ./src/.libs/libmagic.a cp ./magic/magic.mgc $OUT/ diff --git a/projects/freetype2/build.sh b/projects/freetype2/build.sh index cb025552e..891e0f773 100755 --- a/projects/freetype2/build.sh +++ b/projects/freetype2/build.sh @@ -24,6 +24,6 @@ make -j$(nproc) all $CXX $CXXFLAGS -std=c++11 \ -I./include -I. \ ./src/tools/ftfuzzer/ftfuzzer.cc -o $OUT/ftfuzzer \ - ./objs/*.o -lfuzzer \ + ./objs/*.o -lFuzzingEngine \ /usr/lib/x86_64-linux-gnu/libarchive.a \ ./objs/.libs/libfreetype.a diff --git a/projects/harfbuzz/build.sh b/projects/harfbuzz/build.sh index f1b455616..854bd3af0 100755 --- a/projects/harfbuzz/build.sh +++ b/projects/harfbuzz/build.sh @@ -24,5 +24,5 @@ make -C src V=1 fuzzing $CXX $CXXFLAGS -std=c++11 -Isrc \ ./test/fuzzing/hb-fuzzer.cc -o $OUT/hb-fuzzer \ - -lfuzzer ./src/.libs/libharfbuzz-fuzzing.a + -lFuzzingEngine ./src/.libs/libharfbuzz-fuzzing.a diff --git a/projects/icu/build.sh b/projects/icu/build.sh index 9cca54847..18aeedc80 100755 --- a/projects/icu/build.sh +++ b/projects/icu/build.sh @@ -42,7 +42,7 @@ for fuzzer in $FUZZERS; do $CXX $CXXFLAGS -std=c++11 \ $SRC/$fuzzer.cc -o $OUT/$fuzzer \ -I$SRC/icu/source/common -I$SRC/icu/source/i18n -L$WORK/icu/lib \ - -lfuzzer -licui18n -licuuc -licutu -licudata + -lFuzzingEngine -licui18n -licuuc -licutu -licudata done cp $SRC/*.dict $SRC/*.options $OUT/ diff --git a/projects/json/build.sh b/projects/json/build.sh index 304b7320d..c8e563e67 100755 --- a/projects/json/build.sh +++ b/projects/json/build.sh @@ -17,6 +17,6 @@ $CXX $CXXFLAGS -std=c++11 -Isrc/ \ $SRC/parse_fuzzer.cc -o $OUT/parse_fuzzer \ - -lfuzzer + -lFuzzingEngine cp $SRC/*.options $OUT/ diff --git a/projects/lcms/build.sh b/projects/lcms/build.sh index 6591267b7..6e07e163f 100755 --- a/projects/lcms/build.sh +++ b/projects/lcms/build.sh @@ -26,7 +26,7 @@ for F in $FUZZERS; do $SRC/$F.c -o $SRC/$F.o $CXX $CXXFLAGS \ $SRC/$F.o -o $OUT/$F \ - -lfuzzer src/.libs/liblcms2.a + -lFuzzingEngine src/.libs/liblcms2.a done cp $SRC/icc.dict $SRC/*.options $OUT/ diff --git a/projects/libarchive/build.sh b/projects/libarchive/build.sh index 261a045a4..1fa8d1b7e 100755 --- a/projects/libarchive/build.sh +++ b/projects/libarchive/build.sh @@ -23,6 +23,6 @@ make -j$(nproc) all # build fuzzer(s) $CXX $CXXFLAGS -Ilibarchive \ $SRC/libarchive_fuzzer.cc -o $OUT/libarchive_fuzzer \ - -lfuzzer .libs/libarchive.a \ + -lFuzzingEngine .libs/libarchive.a \ -Wl,-Bstatic -lbz2 -llzo2 -lxml2 -llzma -lz -lcrypto -llz4 -licuuc \ -licudata -Wl,-Bdynamic diff --git a/projects/libass/build.sh b/projects/libass/build.sh index 07db7d05e..b77854430 100755 --- a/projects/libass/build.sh +++ b/projects/libass/build.sh @@ -29,7 +29,7 @@ make -j$(nproc) $CXX $CXXFLAGS -std=c++11 -I$SRC/libass \ $SRC/libass_fuzzer.cc -o $OUT/libass_fuzzer \ - -lfuzzer libass/.libs/libass.a \ + -lFuzzingEngine libass/.libs/libass.a \ -Wl,-Bstatic -lfontconfig -lfribidi -lfreetype -lz -lpng12 \ -lexpat -Wl,-Bdynamic diff --git a/projects/libchewing/build.sh b/projects/libchewing/build.sh index 96f295ffa..3dbc4da1b 100755 --- a/projects/libchewing/build.sh +++ b/projects/libchewing/build.sh @@ -32,7 +32,7 @@ for variant in default random_init dynamic_config; do -o $OUT/chewing_${variant}_fuzzer \ $WORK/chewing_${variant}_fuzzer.o $WORK/chewing_fuzzer_common.o \ test/stress.o test/.libs/libtesthelper.a src/.libs/libchewing.a \ - -lfuzzer + -lFuzzingEngine done # install data files diff --git a/projects/libjpeg-turbo/build.sh b/projects/libjpeg-turbo/build.sh index 992134295..4a3eb3535 100755 --- a/projects/libjpeg-turbo/build.sh +++ b/projects/libjpeg-turbo/build.sh @@ -21,6 +21,6 @@ make "-j$(nproc)" $CXX $CXXFLAGS -std=c++11 -I. \ $SRC/libjpeg_turbo_fuzzer.cc -o $OUT/libjpeg_turbo_fuzzer \ - -lfuzzer ./.libs/libturbojpeg.a + -lFuzzingEngine ./.libs/libturbojpeg.a cp $SRC/libjpeg_turbo_fuzzer_seed_corpus.zip $OUT/ diff --git a/projects/libpng/build.sh b/projects/libpng/build.sh index b9a0444de..0b208fc41 100755 --- a/projects/libpng/build.sh +++ b/projects/libpng/build.sh @@ -29,6 +29,6 @@ make -j$(nproc) all # build libpng_read_fuzzer $CXX $CXXFLAGS -std=c++11 -I. -lz \ $SRC/libpng_read_fuzzer.cc -o $OUT/libpng_read_fuzzer \ - -lfuzzer .libs/libpng16.a + -lFuzzingEngine .libs/libpng16.a cp $SRC/*.dict $SRC/*.options $OUT/ diff --git a/projects/libteken/build.sh b/projects/libteken/build.sh index c5f4a00c8..4e5ef8e31 100755 --- a/projects/libteken/build.sh +++ b/projects/libteken/build.sh @@ -22,4 +22,4 @@ CFLAGS="$CFLAGS -D__unused=" pmake -C libteken libteken.a $CC $CFLAGS -c $SRC/libteken_fuzzer.c -o $SRC/libteken_fuzzer.o -I. $CXX $CXXFLAGS $SRC/libteken_fuzzer.o \ -o $OUT/libteken_fuzzer \ - -lfuzzer libteken/libteken.a + -lFuzzingEngine libteken/libteken.a diff --git a/projects/libtsm/build.sh b/projects/libtsm/build.sh index 710d4cd21..b9c5e4ed1 100755 --- a/projects/libtsm/build.sh +++ b/projects/libtsm/build.sh @@ -26,4 +26,4 @@ $CXX $CXXFLAGS \ -o $OUT/libtsm_fuzzer \ $SRC/libtsm_fuzzer.o \ .libs/libtsm.a \ - -lfuzzer + -lFuzzingEngine diff --git a/projects/libxml2/build.sh b/projects/libxml2/build.sh index 93f3195de..bbfcf4181 100755 --- a/projects/libxml2/build.sh +++ b/projects/libxml2/build.sh @@ -24,7 +24,7 @@ make -j$(nproc) all for fuzzer in libxml2_xml_read_memory_fuzzer libxml2_xml_regexp_compile_fuzzer; do $CXX $CXXFLAGS -std=c++11 -Iinclude/ \ $SRC/$fuzzer.cc -o $OUT/$fuzzer \ - -lfuzzer .libs/libxml2.a + -lFuzzingEngine .libs/libxml2.a done cp $SRC/*.dict $SRC/*.options $OUT/ diff --git a/projects/libyaml/build.sh b/projects/libyaml/build.sh index 4dfe70377..618b5f75f 100755 --- a/projects/libyaml/build.sh +++ b/projects/libyaml/build.sh @@ -23,7 +23,7 @@ make "-j$(nproc)" $CXX $CXXFLAGS -std=c++11 -Iinclude \ $SRC/libyaml_fuzzer.cc -o $OUT/libyaml_fuzzer \ - -lfuzzer src/.libs/libyaml.a + -lFuzzingEngine src/.libs/libyaml.a cp $SRC/libyaml_fuzzer_seed_corpus.zip $OUT/ cp $SRC/*.dict $SRC/*.options $OUT/ diff --git a/projects/nss/build.sh b/projects/nss/build.sh index d2a126ed2..6a35c4789 100755 --- a/projects/nss/build.sh +++ b/projects/nss/build.sh @@ -54,7 +54,7 @@ FUZZERS="asn1_algorithmid_fuzzer \ for fuzzer in $FUZZERS; do $CXX $CXXFLAGS -std=c++11 $SRC/$fuzzer.cc \ -I$WORK/nss/include \ - -lfuzzer \ + -lFuzzingEngine \ $WORK/nss/lib/libnss.a $WORK/nss/lib/libnssutil.a \ $WORK/nss/lib/libnspr4.a $WORK/nss/lib/libplc4.a $WORK/nss/lib/libplds4.a \ $WORK/nss/lib/prlog2.o -o $OUT/$fuzzer diff --git a/projects/ots/build.sh b/projects/ots/build.sh index 7b2287abc..238520d59 100755 --- a/projects/ots/build.sh +++ b/projects/ots/build.sh @@ -24,7 +24,7 @@ make libots.a libwoff2.a libbrotli.a # Build the fuzzer. $CXX $CXXFLAGS -std=c++11 -Iinclude \ $SRC/ots_fuzzer.cc -o $OUT/ots_fuzzer \ - -lfuzzer -lz $SRC/ots/libots.a $SRC/ots/libwoff2.a $SRC/ots/libbrotli.a + -lFuzzingEngine -lz $SRC/ots/libots.a $SRC/ots/libwoff2.a $SRC/ots/libbrotli.a cp $SRC/ots_fuzzer.options $OUT/ zip $OUT/ots_fuzzer_seed_corpus.zip $SRC/seed_corpus/* diff --git a/projects/pcre2/build.sh b/projects/pcre2/build.sh index 1ceccd946..cbff93e91 100755 --- a/projects/pcre2/build.sh +++ b/projects/pcre2/build.sh @@ -25,4 +25,4 @@ make -j$(nproc) all # build fuzzer $CXX $CXXFLAGS -o $OUT/pcre2_fuzzer \ - -lfuzzer .libs/libpcre2-fuzzsupport.a .libs/libpcre2-8.a + -lFuzzingEngine .libs/libpcre2-fuzzsupport.a .libs/libpcre2-8.a diff --git a/projects/re2/build.sh b/projects/re2/build.sh index db1435b65..a97ad3cb1 100755 --- a/projects/re2/build.sh +++ b/projects/re2/build.sh @@ -29,6 +29,6 @@ make -j$(nproc) obj/libre2.a # Second, build the fuzzer (distributed with RE2). $CXX $CXXFLAGS -std=c++11 -I. \ re2/fuzzing/re2_fuzzer.cc -o $OUT/re2_fuzzer \ - -lfuzzer obj/libre2.a + -lFuzzingEngine obj/libre2.a cp $SRC/*.options $OUT/ diff --git a/projects/sqlite3/build.sh b/projects/sqlite3/build.sh index f5f0af8e5..0454019b0 100755 --- a/projects/sqlite3/build.sh +++ b/projects/sqlite3/build.sh @@ -32,7 +32,7 @@ $CC $CFLAGS -I. -c \ $CXX $CXXFLAGS \ $SRC/sqlite3/test/ossfuzz.o -o $OUT/ossfuzz \ - -lfuzzer ./sqlite3.o + -lFuzzingEngine ./sqlite3.o cp $SRC/*.options $SRC/*.dict $SRC/*.zip $OUT/ diff --git a/projects/woff2/build.sh b/projects/woff2/build.sh index 87f34101c..77e70c4b1 100755 --- a/projects/woff2/build.sh +++ b/projects/woff2/build.sh @@ -36,6 +36,6 @@ rm src/woff2_compress.o src/woff2_decompress.o fuzzer=convert_woff2ttf_fuzzer $CXX $CXXFLAGS -std=c++11 -Isrc \ $SRC/$fuzzer.cc -o $OUT/$fuzzer \ - -lfuzzer src/*.o brotli/dec/*.o brotli/enc/*.o + -lFuzzingEngine src/*.o brotli/dec/*.o brotli/enc/*.o cp $SRC/*.options $OUT/ diff --git a/projects/zlib/build.sh b/projects/zlib/build.sh index f8aebe24b..f7f2a24ff 100755 --- a/projects/zlib/build.sh +++ b/projects/zlib/build.sh @@ -6,4 +6,4 @@ make -j$(nproc) all $CXX $CXXFLAGS -std=c++11 -I. \ $SRC/zlib_uncompress_fuzzer.cc -o $OUT/zlib_uncompress_fuzzer \ - -lfuzzer ./libz.a + -lFuzzingEngine ./libz.a