From 14414c6ea560e7d64c1610f40aec726861bf9756 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Sun, 10 Apr 2022 23:02:56 +0000 Subject: [PATCH] ci: turn on the alignment check to catch issues like https://github.com/libbpf/libbpf/issues/391 --- scripts/build-fuzzers.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/build-fuzzers.sh b/scripts/build-fuzzers.sh index 9082d6e..ba48ee8 100755 --- a/scripts/build-fuzzers.sh +++ b/scripts/build-fuzzers.sh @@ -17,6 +17,16 @@ mkdir -p "$OUT" export LIB_FUZZING_ENGINE=${LIB_FUZZING_ENGINE:--fsanitize=fuzzer} +# The alignment check is turned off by default on OSS-Fuzz/CFLite so it should be +# turned on explicitly there. It was borrowed from +# https://github.com/google/oss-fuzz/pull/7092 +if [[ "$SANITIZER" == undefined ]]; then + additional_ubsan_checks=alignment + UBSAN_FLAGS="-fsanitize=$additional_ubsan_checks -fno-sanitize-recover=$additional_ubsan_checks" + CFLAGS+=" $UBSAN_FLAGS" + CXXFLAGS+=" $UBSAN_FLAGS" +fi + # Ideally libbelf should be built using release tarballs available # at https://sourceware.org/elfutils/ftp/. Unfortunately sometimes they # fail to compile (for example, elfutils-0.185 fails to compile with LDFLAGS enabled