diff options
author | Andreas Schneider <asn@samba.org> | 2023-02-03 13:43:16 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2023-02-06 23:49:04 +0000 |
commit | 024571a7a85a7c4a81e0ee6bf9f228477275365e (patch) | |
tree | 1e420d00810e6506cf6609796891ae2eebc2fe8e /buildtools | |
parent | b3d7df58a03e2b5419431cde510ae85c25d909c2 (diff) | |
download | samba-024571a7a85a7c4a81e0ee6bf9f228477275365e.tar.gz |
waf: Add support for MemorySanitizer
This currently only works with binaries. As there is no shared library for
MSAN it only is statically linked against binaries. This means if we have e.g.
a python script trying to load ldb, it will fail with undefined symbols.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Feb 6 23:49:04 UTC 2023 on atb-devel-224
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/wafsamba/samba_autoconf.py | 15 | ||||
-rw-r--r-- | buildtools/wafsamba/wscript | 5 |
2 files changed, 18 insertions, 2 deletions
diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 2e00f52230f..b047fe421b4 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -830,8 +830,10 @@ int main(void) { if (Options.options.address_sanitizer or Options.options.undefined_sanitizer): conf.ADD_CFLAGS('-g -O1', testflags=True) - if Options.options.address_sanitizer: + if (Options.options.address_sanitizer + or Options.options.memory_sanitizer): conf.ADD_CFLAGS('-fno-omit-frame-pointer', testflags=True) + if Options.options.address_sanitizer: conf.ADD_CFLAGS('-fsanitize=address', testflags=True) conf.ADD_LDFLAGS('-fsanitize=address', testflags=True) conf.env['ADDRESS_SANITIZER'] = True @@ -842,6 +844,13 @@ int main(void) { conf.ADD_LDFLAGS('-fsanitize=undefined', testflags=True) conf.env['UNDEFINED_SANITIZER'] = True + # MemorySanitizer is only available if you build with clang + if Options.options.memory_sanitizer: + conf.ADD_CFLAGS('-g -O2', testflags=True) + conf.ADD_CFLAGS('-fsanitize=memory', testflags=True) + conf.ADD_CFLAGS('-fsanitize-memory-track-origins=2', testflags=True) + conf.ADD_LDFLAGS('-fsanitize=memory') + conf.env['MEMORY_SANITIZER'] = True # Let people pass an additional ADDITIONAL_{CFLAGS,LDFLAGS} # environment variables which are only used the for final build. @@ -986,7 +995,9 @@ def SETUP_CONFIGURE_CACHE(conf, enable): @conf def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf): - if Options.options.address_sanitizer or Options.options.enable_libfuzzer: + if (Options.options.address_sanitizer + or Options.options.memory_sanitizer + or Options.options.enable_libfuzzer): # Sanitizers can rely on symbols undefined at library link time and the # symbols used for fuzzers are only defined by compiler wrappers. return diff --git a/buildtools/wafsamba/wscript b/buildtools/wafsamba/wscript index 8729b0829da..a33d26706a5 100644 --- a/buildtools/wafsamba/wscript +++ b/buildtools/wafsamba/wscript @@ -189,6 +189,11 @@ Currently the only tested value is 'smbtorture,smbd/smbd' for Samba'''), action="store_true", dest='undefined_sanitizer', default=False) + gr.add_option('--memory-sanitizer', + help=("Enable memory behaviour sanitizer compile and linker flags"), + action="store_true", + dest='memory_sanitizer', + default=False) gr.add_option('--enable-libfuzzer', help=("Build fuzzing binaries (use ADDITIONAL_CFLAGS to specify compiler options for libFuzzer or use CC=honggfuzz/hfuzz-cc)"), action="store_true", dest='enable_libfuzzer', default=False) |