diff options
author | 2022-01-05 17:54:21 +0300 | |
---|---|---|
committer | 2022-01-05 14:54:21 +0000 | |
commit | 8747524f04b1b906d4a21a6ade87f7803b3f9b8c (patch) | |
tree | 7ccb226afc00c1a60159691e49de4379d407e7d1 | |
parent | 99cad8f4a3be21768d2400dbf3158fb0c8c22f86 (diff) |
[elfutils] turn on the alignment check (#7092)
* [elfutils] turn on the alignment check
Unaligned access can crash code on some architectures
like SPARC for example. The latest example (unrelated to elfutils)
would be https://github.com/systemd/systemd/issues/21935 (which UBSan
could have easily prevented and which led to rolling out the check
in the systemd project among other things).
It should probably be merged once https://sourceware.org/bugzilla/show_bug.cgi?id=28720
is closed.
* [elfutils] drop line-tables-only
to make it easier to run the fuzzer with gdb locally.
-rwxr-xr-x | projects/elfutils/build.sh | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/projects/elfutils/build.sh b/projects/elfutils/build.sh index 501351ec..df8f8f67 100755 --- a/projects/elfutils/build.sh +++ b/projects/elfutils/build.sh @@ -38,7 +38,7 @@ set -eux SANITIZER=${SANITIZER:-address} -flags="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER -fsanitize=fuzzer-no-link" +flags="-O1 -fno-omit-frame-pointer -g -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=$SANITIZER -fsanitize=fuzzer-no-link" export CC=${CC:-clang} export CFLAGS=${CFLAGS:-$flags} @@ -61,6 +61,17 @@ find -name Makefile.am | xargs sed -i 's/,--no-undefined//' # https://clang.llvm.org/docs/AddressSanitizer.html#usage sed -i 's/^\(ZDEFS_LDFLAGS=\).*/\1/' configure.ac +if [[ "$SANITIZER" == undefined ]]; then + additional_ubsan_checks=alignment + UBSAN_FLAGS="-fsanitize=$additional_ubsan_checks -fno-sanitize-recover=$additional_ubsan_checks" + CFLAGS="$CFLAGS $UBSAN_FLAGS" + CXXFLAGS="$CXXFLAGS $UBSAN_FLAGS" + + # That's basicaly what --enable-sanitize-undefined does to turn off unaligned access + # elfutils heavily relies on on i386/x86_64 but without changing compiler flags along the way + sed -i 's/\(check_undefined_val\)=[0-9]/\1=1/' configure.ac +fi + autoreconf -i -f if ! ./configure --enable-maintainer-mode --disable-debuginfod --disable-libdebuginfod \ --without-bzlib --without-lzma --without-zstd \ |