Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[elfutils] build zlib with MSan #7401

Merged
merged 1 commit into from
Mar 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions projects/elfutils/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,39 @@ fi

ASAN_OPTIONS=detect_leaks=0 make -j$(nproc) V=1

# External dependencies used by the fuzz targets have to be built
# with MSan explicitly to avoid bogus "security" bug reports like
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45630,
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45631 and
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=45633
zlib="-l:libz.a"
if [[ "$SANITIZER" == memory ]]; then
git clone https://github.com/madler/zlib
DavidKorczynski marked this conversation as resolved.
Show resolved Hide resolved
pushd zlib
git checkout v1.2.11
if ! ./configure --static; then
cat configure.log
exit 1
fi
make -j$(nproc) V=1
popd
zlib=zlib/libz.a
fi

# When new fuzz targets are added it usually makes sense to notify the maintainers of
# the elfutils project using the mailing list: [email protected]. There
# fuzz targets can be reviewed properly (to make sure they don't fail to compile
# with -Werror for example), their names can be chosen accordingly (so as not to spam
# the mailing list with bogus bug reports that are opened and closed once they are renamed)
# and so on. Also since a lot of bug reports coming out of the blue aren't exactly helpful
# fuzz targets should probably be added one at a time to make it easier to keep track
# of them.
$CC $CFLAGS \
-D_GNU_SOURCE -DHAVE_CONFIG_H \
-I. -I./lib -I./libelf -I./libebl -I./libdw -I./libdwelf -I./libdwfl -I./libasm \
-c "$SRC/fuzz-dwfl-core.c" -o fuzz-dwfl-core.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz-dwfl-core.o \
./libdw/libdw.a ./libelf/libelf.a -l:libz.a \
./libdw/libdw.a ./libelf/libelf.a "$zlib" \
-o "$OUT/fuzz-dwfl-core"

$CC $CFLAGS \
Expand All @@ -101,7 +128,7 @@ $CC $CFLAGS \
-c "$SRC/fuzz-libelf.c" -o fuzz-libelf.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz-libelf.o \
./libasm/libasm.a ./libebl/libebl.a ./backends/libebl_backends.a ./libcpu/libcpu.a \
./libdw/libdw.a ./libelf/libelf.a ./lib/libeu.a -l:libz.a \
./libdw/libdw.a ./libelf/libelf.a ./lib/libeu.a "$zlib" \
-o "$OUT/fuzz-libelf"

$CC $CFLAGS \
Expand All @@ -110,7 +137,7 @@ $CC $CFLAGS \
-c "$SRC/fuzz-libdwfl.c" -o fuzz-libdwfl.o
$CXX $CXXFLAGS $LIB_FUZZING_ENGINE fuzz-libdwfl.o \
./libasm/libasm.a ./libebl/libebl.a ./backends/libebl_backends.a ./libcpu/libcpu.a \
./libdw/libdw.a ./libelf/libelf.a ./lib/libeu.a -l:libz.a \
./libdw/libdw.a ./libelf/libelf.a ./lib/libeu.a "$zlib" \
-o "$OUT/fuzz-libdwfl"

# Corpus
Expand Down