2014-02-14 21:02:58 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Setup config name.
|
2016-02-12 22:48:19 +08:00
|
|
|
config.name = 'MemorySanitizer' + getattr(config, 'name_suffix', 'default')
|
2014-02-14 21:02:58 +08:00
|
|
|
|
|
|
|
# Setup source root.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# Setup default compiler flags used with -fsanitize=memory option.
|
2016-02-10 00:18:15 +08:00
|
|
|
clang_msan_cflags = (["-fsanitize=memory",
|
|
|
|
"-mno-omit-leaf-frame-pointer",
|
|
|
|
"-fno-omit-frame-pointer",
|
|
|
|
"-fno-optimize-sibling-calls"] +
|
|
|
|
[config.target_cflags] +
|
|
|
|
config.debug_info_flags)
|
2015-04-24 15:52:47 +08:00
|
|
|
# Some Msan tests leverage backtrace() which requires libexecinfo on FreeBSD.
|
|
|
|
if config.host_os == 'FreeBSD':
|
2018-09-11 18:35:32 +08:00
|
|
|
clang_msan_cflags += ["-lexecinfo", "-fPIC"]
|
2014-02-19 23:13:14 +08:00
|
|
|
clang_msan_cxxflags = config.cxx_mode_flags + clang_msan_cflags
|
2014-02-17 21:08:10 +08:00
|
|
|
|
2018-09-07 17:17:12 +08:00
|
|
|
# Flags for KMSAN invocation. This is C-only, we're not interested in C++.
|
|
|
|
clang_kmsan_cflags = (["-fsanitize=kernel-memory"] +
|
|
|
|
[config.target_cflags] +
|
|
|
|
config.debug_info_flags)
|
|
|
|
|
2014-02-17 21:08:10 +08:00
|
|
|
def build_invocation(compile_flags):
|
|
|
|
return " " + " ".join([config.clang] + compile_flags) + " "
|
|
|
|
|
|
|
|
config.substitutions.append( ("%clang_msan ", build_invocation(clang_msan_cflags)) )
|
|
|
|
config.substitutions.append( ("%clangxx_msan ", build_invocation(clang_msan_cxxflags)) )
|
2018-09-07 17:17:12 +08:00
|
|
|
config.substitutions.append( ("%clang_kmsan ", build_invocation(clang_kmsan_cflags)) )
|
2014-02-14 21:02:58 +08:00
|
|
|
|
|
|
|
# Default test suffixes.
|
2019-08-06 03:25:35 +08:00
|
|
|
config.suffixes = ['.c', '.cpp']
|
2014-02-14 21:02:58 +08:00
|
|
|
|
Adding Msan support to FreeBSD
Summary:
Enabling the memory sanitizer support for FreeBSD, most of unit tests are compatible.
- Adding fstat and stressor_r interceptors.
- Updating the struct link_map access since most likely the struct Obj_Entry had been updated since.
- Disabling few unit tests until further work is needed (or we can assume it can work in real world code).
Patch by: David CARLIER
Reviewers: vitalybuka, krytarowski
Reviewed By: vitalybuka
Subscribers: eugenis, dim, srhines, emaste, kubamracek, mgorny, fedor.sergeev, hintonda, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D43080
llvm-svn: 326644
2018-03-03 19:43:11 +08:00
|
|
|
if config.host_os not in ['Linux', 'NetBSD', 'FreeBSD']:
|
2014-02-14 21:02:58 +08:00
|
|
|
config.unsupported = True
|
2016-03-11 02:46:23 +08:00
|
|
|
|
2016-12-08 14:30:58 +08:00
|
|
|
# For mips64, mips64el we have forced store_context_size to 1 because these
|
|
|
|
# archs use slow unwinder which is not async signal safe. Therefore we only
|
|
|
|
# check the first frame since store_context size is 1.
|
|
|
|
if config.host_arch in ['mips64', 'mips64el']:
|
|
|
|
config.substitutions.append( ('CHECK-%short-stack', 'CHECK-SHORT-STACK'))
|
|
|
|
else:
|
|
|
|
config.substitutions.append( ('CHECK-%short-stack', 'CHECK-FULL-STACK'))
|
2019-12-03 21:44:33 +08:00
|
|
|
|
|
|
|
if config.host_os == 'NetBSD':
|
|
|
|
config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
|