From 1556fb10d654def7146a23886d0f9a713f388b65 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Fri, 1 Apr 2022 00:05:01 -0400 Subject: [PATCH] [zlib-ng] build fixes and improvements (#7467) * [zlib-ng] fixed dataflow sanitizer build error. #7464 * [zlib-ng] use cmake instead of configure to build fuzzers. --- projects/zlib-ng/build.sh | 29 ++++++++++++++++++----------- projects/zlib-ng/project.yaml | 2 -- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/projects/zlib-ng/build.sh b/projects/zlib-ng/build.sh index f476e9584..ad04626a4 100755 --- a/projects/zlib-ng/build.sh +++ b/projects/zlib-ng/build.sh @@ -15,19 +15,26 @@ # ################################################################################ -export LDSHARED=lld -export LDFLAGS="$CFLAGS -stdlib=libc++" - -./configure - -sed -i 's/$(CC) $(LDFLAGS)/$(CXX) $(LDFLAGS)/g' Makefile - -make -j$(nproc) clean -make -j$(nproc) all -make -j$(nproc) check +: ${LD:="${CXX}"} +: ${LDFLAGS:="${CXXFLAGS}"} # to make sure we link against 32-bit libraries +# Package seed corpus zip $OUT/seed_corpus.zip *.* -for f in $(find . -name '*_fuzzer' -o -name 'fuzzer_*'); do + +# Build project +mkdir build && cd build +cmake .. -DCMAKE_C_FLAGS="${CFLAGS}" \ + -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \ + -DCMAKE_LINKER="${LD}" \ + -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \ + -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \ + -DBUILD_SHARED_LIBS=OFF \ + -DWITH_FUZZERS=ON +make clean +make -j $(nproc) + +# Copy seed corpus for each fuzzer target +for f in $(find . -type f -name 'fuzzer_*'); do cp -v $f $OUT (cd $OUT; ln -s seed_corpus.zip $(basename $f)_seed_corpus.zip) done diff --git a/projects/zlib-ng/project.yaml b/projects/zlib-ng/project.yaml index 688f359a9..e11e9ae70 100644 --- a/projects/zlib-ng/project.yaml +++ b/projects/zlib-ng/project.yaml @@ -8,12 +8,10 @@ fuzzing_engines: - libfuzzer - afl - honggfuzz - - dataflow sanitizers: - address - memory - undefined - - dataflow architectures: - x86_64 - i386