forked from OSchip/llvm-project
[sanitizer] Test ubsan and cfi on android.
Summary: Enable check-cfi and check-ubsan on Android. Check-ubsan includes standalone and ubsan+asan, but not tsan or msan. Cross-dso cfi tests are disabled for now. Reviewers: vitalybuka, pcc Subscribers: srhines, kubamracek, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D38608 llvm-svn: 315105
This commit is contained in:
parent
420090af89
commit
f29ee9a050
|
|
@ -208,7 +208,7 @@ set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64})
|
||||||
set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
|
set(ALL_UBSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
|
||||||
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
|
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
|
||||||
set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64})
|
set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64})
|
||||||
set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64})
|
set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64})
|
||||||
set(ALL_ESAN_SUPPORTED_ARCH ${X86_64} ${MIPS64})
|
set(ALL_ESAN_SUPPORTED_ARCH ${X86_64} ${MIPS64})
|
||||||
set(ALL_SCUDO_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64})
|
set(ALL_SCUDO_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64})
|
||||||
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} powerpc64le)
|
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} powerpc64le)
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,5 @@ def getRoot(config):
|
||||||
|
|
||||||
root = getRoot(config)
|
root = getRoot(config)
|
||||||
|
|
||||||
if root.host_os not in ['Linux']:
|
if root.host_os not in ['Linux'] or config.android:
|
||||||
config.unsupported = True
|
config.unsupported = True
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ config.name = 'cfi' + config.name_suffix
|
||||||
config.suffixes = ['.c', '.cpp', '.test']
|
config.suffixes = ['.c', '.cpp', '.test']
|
||||||
config.test_source_root = os.path.dirname(__file__)
|
config.test_source_root = os.path.dirname(__file__)
|
||||||
|
|
||||||
clang = ' '.join([config.clang, config.target_cflags])
|
clang = ' '.join([config.compile_wrapper, config.clang, config.target_cflags])
|
||||||
clangxx = ' '.join([config.clang, config.target_cflags] + config.cxx_mode_flags)
|
clangxx = ' '.join([config.compile_wrapper, config.clang, config.target_cflags] + config.cxx_mode_flags)
|
||||||
|
|
||||||
config.substitutions.append((r"%clang ", clang + ' '))
|
config.substitutions.append((r"%clang ", clang + ' '))
|
||||||
config.substitutions.append((r"%clangxx ", clangxx + ' '))
|
config.substitutions.append((r"%clangxx ", clangxx + ' '))
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
// FIXME: We currently emit the wrong debug info under devirtualization.
|
// FIXME: We currently emit the wrong debug info under devirtualization.
|
||||||
// UNSUPPORTED: devirt
|
// UNSUPPORTED: devirt
|
||||||
|
|
||||||
|
// FIXME: %t.stats must be transferred from device to host for this to work on Android.
|
||||||
|
// XFAIL: android
|
||||||
|
|
||||||
struct ABase {};
|
struct ABase {};
|
||||||
|
|
||||||
struct A : ABase {
|
struct A : ABase {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ config.available_features.add(compiler_id)
|
||||||
# BFD linker in 64-bit android toolchains fails to find libm.so, which is a
|
# BFD linker in 64-bit android toolchains fails to find libm.so, which is a
|
||||||
# transitive shared library dependency (via asan runtime).
|
# transitive shared library dependency (via asan runtime).
|
||||||
if config.android:
|
if config.android:
|
||||||
config.target_cflags += " -fuse-ld=gold -Wl,--enable-new-dtags"
|
config.target_cflags += " -pie -fuse-ld=gold -Wl,--enable-new-dtags"
|
||||||
|
|
||||||
# Clear some environment variables that might affect Clang.
|
# Clear some environment variables that might affect Clang.
|
||||||
possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS',
|
possibly_dangerous_env_vars = ['ASAN_OPTIONS', 'DFSAN_OPTIONS', 'LSAN_OPTIONS',
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ def build_env():
|
||||||
# Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir.
|
# Android linker ignores RPATH. Set LD_LIBRARY_PATH to Output dir.
|
||||||
args.append('LD_LIBRARY_PATH=%s' % (ANDROID_TMPDIR,))
|
args.append('LD_LIBRARY_PATH=%s' % (ANDROID_TMPDIR,))
|
||||||
for (key, value) in os.environ.items():
|
for (key, value) in os.environ.items():
|
||||||
if key in ['ASAN_OPTIONS', 'ASAN_ACTIVATION_OPTIONS', 'SCUDO_OPTIONS']:
|
if key in ['ASAN_OPTIONS', 'ASAN_ACTIVATION_OPTIONS', 'SCUDO_OPTIONS', 'UBSAN_OPTIONS']:
|
||||||
args.append('%s="%s"' % (key, value))
|
args.append('%s="%s"' % (key, value))
|
||||||
return ' '.join(args)
|
return ' '.join(args)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ foreach(arch ${UBSAN_TEST_ARCH})
|
||||||
if(COMPILER_RT_HAS_MSAN AND ";${MSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
if(COMPILER_RT_HAS_MSAN AND ";${MSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
||||||
add_ubsan_testsuite("MemorySanitizer" msan ${arch})
|
add_ubsan_testsuite("MemorySanitizer" msan ${arch})
|
||||||
endif()
|
endif()
|
||||||
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};")
|
if(COMPILER_RT_HAS_TSAN AND ";${TSAN_SUPPORTED_ARCH};" MATCHES ";${arch};" AND NOT ANDROID)
|
||||||
add_ubsan_testsuite("ThreadSanitizer" tsan ${arch})
|
add_ubsan_testsuite("ThreadSanitizer" tsan ${arch})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
// Suppression by symbol name (unsigned-integer-overflow:do_overflow below)
|
// Suppression by symbol name (unsigned-integer-overflow:do_overflow below)
|
||||||
// requires the compiler-rt runtime to be able to symbolize stack addresses.
|
// requires the compiler-rt runtime to be able to symbolize stack addresses.
|
||||||
// REQUIRES: can-symbolize
|
// REQUIRES: can-symbolize
|
||||||
|
// UNSUPPORTED: android
|
||||||
|
|
||||||
// Fails without any suppression.
|
// Fails without any suppression.
|
||||||
// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
|
// RUN: %env_ubsan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
# The function type checker is only supported on x86 and x86_64 for now.
|
# The function type checker is only supported on x86 and x86_64 for now.
|
||||||
if config.root.host_arch not in ['x86', 'x86_64']:
|
if config.target_arch not in ['x86', 'x86_64']:
|
||||||
config.unsupported = True
|
config.unsupported = True
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@ if config.host_os == 'Darwin':
|
||||||
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
|
# much slower. Let's override this and run lit tests with 'abort_on_error=0'.
|
||||||
default_ubsan_opts += ['abort_on_error=0']
|
default_ubsan_opts += ['abort_on_error=0']
|
||||||
default_ubsan_opts += ['log_to_syslog=0']
|
default_ubsan_opts += ['log_to_syslog=0']
|
||||||
|
elif config.android:
|
||||||
|
default_ubsan_opts += ['abort_on_error=0']
|
||||||
|
|
||||||
default_ubsan_opts_str = ':'.join(default_ubsan_opts)
|
default_ubsan_opts_str = ':'.join(default_ubsan_opts)
|
||||||
if default_ubsan_opts_str:
|
if default_ubsan_opts_str:
|
||||||
config.environment['UBSAN_OPTIONS'] = default_ubsan_opts_str
|
config.environment['UBSAN_OPTIONS'] = default_ubsan_opts_str
|
||||||
|
|
@ -55,7 +58,7 @@ config.substitutions.append(('%env_ubsan_opts=',
|
||||||
'env UBSAN_OPTIONS=' + default_ubsan_opts_str))
|
'env UBSAN_OPTIONS=' + default_ubsan_opts_str))
|
||||||
|
|
||||||
def build_invocation(compile_flags):
|
def build_invocation(compile_flags):
|
||||||
return " " + " ".join([config.clang] + compile_flags) + " "
|
return " " + " ".join([config.compile_wrapper, config.clang] + compile_flags) + " "
|
||||||
|
|
||||||
target_cflags = [get_required_attr(config, "target_cflags")]
|
target_cflags = [get_required_attr(config, "target_cflags")]
|
||||||
clang_ubsan_cflags += target_cflags
|
clang_ubsan_cflags += target_cflags
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue