From 7f32bdc4fb2888d7d8316018285d6cdf1e14e2fc Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Tue, 24 Apr 2018 15:57:54 +0200 Subject: [PATCH] make.rc,make-config.sh: add OPT_USAN (UndefinedBehaviorSanitizer) --- make-config.sh | 16 ++++++++++++---- make.rc | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/make-config.sh b/make-config.sh index aeb14072..ef0521b3 100644 --- a/make-config.sh +++ b/make-config.sh @@ -561,8 +561,7 @@ _cc_flags_generic() { if feat_yes ASAN_ADDRESS; then _ccfg=${_CFLAGS} - if cc_check -fsanitize=address && - ld_check -fsanitize=address; then + if cc_check -fsanitize=address && ld_check -fsanitize=address; then : else feat_bail_required ASAN_ADDRESS @@ -572,8 +571,7 @@ _cc_flags_generic() { if feat_yes ASAN_MEMORY; then _ccfg=${_CFLAGS} - if cc_check -fsanitize=memory && - ld_check -fsanitize=memory && + if cc_check -fsanitize=memory && ld_check -fsanitize=memory && cc_check -fsanitize-memory-track-origins=2 && ld_check -fsanitize-memory-track-origins=2; then : @@ -583,6 +581,16 @@ _cc_flags_generic() { fi fi + if feat_yes USAN; then + _ccfg=${_CFLAGS} + if cc_check -fsanitize=undefined && ld_check -fsanitize=undefined; then + : + else + feat_bail_required USAN + _CFLAGS=${_ccfg} + fi + fi + ld_check -Wl,-z,relro if [ -z "${ld_no_bind_now}" ]; then ld_check -Wl,-z,now diff --git a/make.rc b/make.rc index c5ae7ebe..0331000a 100644 --- a/make.rc +++ b/make.rc @@ -423,12 +423,14 @@ OPT_NOEXTMD5=no # With $OPT_AUTOCC we can make use of the ASan AddressSanitizer and ASan # MemorySanitizer of Google # (https://github.com/google/sanitizers/wiki/AddressSanitizer). +# Also USAN (https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html). # These are definetely only useful for debugging. # Also, external libraries are often problematic (e.g., ncursesw), and # ASAN_MEMORY of the tried clang 4.0.0 (4.0.0-2 of ArchLinux) was faulty. # Can be "require"d. OPT_ASAN_ADDRESS=no OPT_ASAN_MEMORY=no +OPT_USAN=no # With $OPT_AUTOCC we will use stack protector guards shall the # detected compiler support them; this goes in line with our own (heap) -- 2.11.4.GIT