[infra] replacing libfuzzer/*.o by -lfuzzer

Fixes issue #32
This commit is contained in:
Mike Aizatsky 2016-10-17 14:32:10 -07:00
parent ab9edb1948
commit 089add6e8b
20 changed files with 26 additions and 25 deletions

View File

@ -36,7 +36,7 @@ for F in $fuzzerFiles; do
fuzzerName=$(basename $F .cc)
echo "Building fuzzer $fuzzerName"
$CXX $CXXFLAGS $FUZZER_LDFLAGS -std=c++11 \
-o /out/openssl_${fuzzerName} /work/libfuzzer/*.o $F \
-o /out/openssl_${fuzzerName} -lfuzzer $F \
-I /src/boringssl/include ./ssl/libssl.a ./crypto/libcrypto.a
done

View File

@ -19,4 +19,4 @@ cd /src/curl
./buildconf
./configure --disable-shared --enable-debug --enable-maintainer-mode --disable-symbol-hiding --disable-threaded-resolver --enable-ipv6 --with-random=/dev/null
make -j4
$CXX $CXXFLAGS /src/fuzzer.cc -Iinclude lib/.libs/libcurl.a -lssl -lcrypto -lz /work/libfuzzer/*.o -o /out/curl_fuzzer $FUZZER_LDFLAGS
$CXX $CXXFLAGS /src/fuzzer.cc -Iinclude lib/.libs/libcurl.a -lssl -lcrypto -lz -lfuzzer -o /out/curl_fuzzer $FUZZER_LDFLAGS

View File

@ -103,7 +103,7 @@ make clean all
# build the fuzzer, linking with libFuzzer and libexpat.a
$CXX $CXXFLAGS -std=c++11 -Ilib/ \
/src/oss-fuzz/expat/parse_fuzzer.cc -o /out/expat_parse_fuzzer \
/work/libfuzzer/*.o .libs/libexpat.a \
-lfuzzer .libs/libexpat.a \
$FUZZER_LDFLAGS
```
@ -113,9 +113,9 @@ When build.sh script is executed, the following locations are available within t
| Path | Description
| ------ | -----
| `/src/$LIB_NAME` | Source code for your library.
| `/src/oss-fuzz` | Checked out oss-fuzz source tree.
| `/work/libfuzzer/*.o` | Prebuilt libFuzzer object files that need to be linked into all fuzzers.
| `/src/$LIB_NAME` | Source code for your library.
| `/src/oss-fuzz` | Checked out oss-fuzz source tree.
| `/usr/lib/libfuzzer.a` | Prebuilt libFuzzer library that need to be linked into all fuzzers (`-lfuzzer`).
You *must* use special compiler flags to build your library and fuzzers.
These flags are provided in following environment variables:

View File

@ -7,6 +7,6 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -Ilib/ \
/src/parse_fuzzer.cc -o /out/expat_parse_fuzzer \
/work/libfuzzer/*.o .libs/libexpat.a $FUZZER_LDFLAGS
-lfuzzer .libs/libexpat.a $FUZZER_LDFLAGS
cp /src/*.dict /src/*.options /out/

View File

@ -24,6 +24,6 @@ make clean all
$CXX $CXXFLAGS $FUZZER_LDFLAGS -std=c++11 \
-I./include -I. \
./src/tools/ftfuzzer/ftfuzzer.cc -o /out/freetype2_fuzzer \
./objs/*.o /work/libfuzzer/*.o \
./objs/*.o -lfuzzer \
/usr/lib/x86_64-linux-gnu/libarchive.a \
./objs/.libs/libfreetype.a

View File

@ -25,4 +25,4 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -Isrc \
/src/harfbuzz_fuzzer.cc -o /out/harfbuzz_fuzzer \
/work/libfuzzer/*.o src/.libs/*.o src/hb-ucdn/.libs/*.o $FUZZER_LDFLAGS
-lfuzzer src/.libs/*.o src/hb-ucdn/.libs/*.o $FUZZER_LDFLAGS

View File

@ -18,7 +18,7 @@ Supported commands:
| -------- | ---------- |
| `/out/` | build artifacts should be copied here |
| `/work/` | used to store intermediate files |
| `/work/libfuzzer/*.o` | libfuzzer object files |
| `/usr/lib/libfuzzer.a` | libfuzzer static library |
# Provided Environment Variables

View File

@ -18,11 +18,12 @@
echo "---------------------------------------------------------------"
export LIBFUZZER_WORK_DIR=/work/libfuzzer
echo -n "Compiling libFuzzer into $LIBFUZZER_WORK_DIR ..."
cd $LIBFUZZER_WORK_DIR
echo -n "Compiling libFuzzer into /usr/lib/libfuzzer.a ..."
cd /work/libfuzzer
$CXX $CXXFLAGS -std=c++11 $SANITIZER_FLAGS -c /src/libfuzzer/*.cpp -I/src/libfuzzer
ar ruv /usr/lib/libfuzzer.a /work/libfuzzer/*.o
# TODO(mike): remove /work/libfuzzer after all fuzzers are migrated to -lfuzzer
echo "Done."
export CFLAGS="$CFLAGS $SANITIZER_FLAGS $COV_FLAGS"

View File

@ -19,6 +19,6 @@ cd /src/json
$CXX $CXXFLAGS -std=c++11 -I/src/json/src/ \
/src/parse_fuzzer.cc -o /out/parse_fuzzer \
/work/libfuzzer/*.o $FUZZER_LDFLAGS
-lfuzzer $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -33,7 +33,7 @@ make
$CXX $CXXFLAGS -std=c++11 -I/src/libass \
/src/libass_fuzzer.cc -o /out/libass_fuzzer \
/work/libfuzzer/*.o libass/.libs/libass.a \
-lfuzzer libass/.libs/libass.a \
-Wl,-Bstatic -lfontconfig -lfribidi -lfreetype -lz -lpng12 -lexpat -Wl,-Bdynamic \
$FUZZER_LDFLAGS

View File

@ -29,7 +29,7 @@ $CC $CFLAGS \
-o /out/chewing_fuzzer \
/src/chewing_fuzzer.c \
test/stress.o test/.libs/libtesthelper.a src/.libs/libchewing.a \
/work/libfuzzer/*.o $FUZZER_LDFLAGS
-lfuzzer $FUZZER_LDFLAGS
# install data files
make -C data pkgdatadir=/out install

View File

@ -30,6 +30,6 @@ make clean all
# build libpng_read_fuzzer
$CXX $CXXFLAGS -std=c++11 -I. -lz \
/src/libpng_read_fuzzer.cc -o /out/libpng_read_fuzzer \
/work/libfuzzer/*.o .libs/libpng16.a $FUZZER_LDFLAGS
-lfuzzer .libs/libpng16.a $FUZZER_LDFLAGS
cp /src/*.dict /src/*.options /out/

View File

@ -24,7 +24,7 @@ make clean 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 \
/work/libfuzzer/*.o .libs/libxml2.a $FUZZER_LDFLAGS
-lfuzzer .libs/libxml2.a $FUZZER_LDFLAGS
done
cp /src/*.dict /src/*.options /out/

View File

@ -59,7 +59,7 @@ FUZZERS="asn1_algorithmid_fuzzer \
for fuzzer in $FUZZERS; do
$CXX $CXXFLAGS -std=c++11 /src/$fuzzer.cc \
-I/work/nss/include \
/work/libfuzzer/*.o \
-lfuzzer \
/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 $FUZZER_LDFLAGS

View File

@ -28,4 +28,4 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -I src \
/src/pcre2_fuzzer.cc -o /out/pcre2_fuzzer \
-Wl,--whole-archive .libs/*.a -Wl,-no-whole-archive $FUZZER_LDFLAGS \
/work/libfuzzer/*.o
-lfuzzer

View File

@ -32,6 +32,6 @@ make obj/libre2.a
# Second, build our fuzzers.
$CXX $CXXFLAGS -std=c++11 -I. \
/src/re2_fuzzer.cc -o /out/re2_fuzzer \
/work/libfuzzer/*.o ./obj/libre2.a $FUZZER_LDFLAGS
-lfuzzer ./obj/libre2.a $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -94,5 +94,5 @@ cd /src/%s
# e.g.
# $CXX $CXXFLAGS -std=c++11 -Iinclude \\
# /path/to/name_of_fuzzer.cc -o /out/name_of_fuzzer \\
# /work/libfuzzer/*.o /path/to/library.a $FUZZER_LDFLAGS
# -lfuzzer /path/to/library.a $FUZZER_LDFLAGS
"""

View File

@ -34,6 +34,6 @@ make sqlite3.c
$CXX $CXXFLAGS -std=c++11 -I. \
/src/sqlite3_fuzzer.cc -o /out/sqlite3_fuzzer \
/work/libfuzzer/*.o ./sqlite3.o $FUZZER_LDFLAGS
-lfuzzer ./sqlite3.o $FUZZER_LDFLAGS
cp /src/*.options /src/*.dict /out/

View File

@ -42,6 +42,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 \
/work/libfuzzer/*.o src/*.o brotli/dec/*.o brotli/enc/*.o $FUZZER_LDFLAGS
-lfuzzer src/*.o brotli/dec/*.o brotli/enc/*.o $FUZZER_LDFLAGS
cp /src/*.options /out/

View File

@ -7,4 +7,4 @@ make clean all
$CXX $CXXFLAGS -std=c++11 -I. \
/src/zlib_uncompress_fuzzer.cc -o /out/zlib_uncompress_fuzzer \
/work/libfuzzer/*.o ./libz.a $FUZZER_LDFLAGS
-lfuzzer ./libz.a $FUZZER_LDFLAGS