[compiler-rt] [test] Disable MPROTECT on two builtin tests

Introduce a new %run_nomprotect substitution to run tests that do not
work with MPROTECT enabled.  This uses paxctl via a wrapper on NetBSD,
and evaluates to plain %run on other systems.

Differential Revision: https://reviews.llvm.org/D71513
This commit is contained in:
Michał Górny 2019-12-14 17:03:48 +01:00
parent e1882af9f6
commit 190b9110c2
4 changed files with 18 additions and 8 deletions

View File

@ -1,6 +1,6 @@
// REQUIRES: native-run
// UNSUPPORTED: arm, aarch64
// RUN: %clang_builtins %s %librt -o %t && %run %t
// RUN: %clang_builtins %s %librt -o %t && %run_nomprotect %t
// REQUIRES: librt_has_clear_cache
//===-- clear_cache_test.c - Test clear_cache -----------------------------===//
//

View File

@ -1,5 +1,5 @@
// REQUIRES: native-run
// RUN: %clang_builtins %s %librt -o %t && %run %t
// RUN: %clang_builtins %s %librt -o %t && %run_nomprotect %t
// REQUIRES: librt_has_enable_execute_stack
//===-- enable_execute_stack_test.c - Test __enable_execute_stack ----------===//
//

View File

@ -112,6 +112,19 @@ config.substitutions.append(
(' clang', """\n\n*** Do not use 'clangXXX' in tests,
instead define '%clangXXX' substitution in lit config. ***\n\n""") )
if config.host_os == 'NetBSD':
nb_commands_dir = os.path.join(config.compiler_rt_src_root,
"test", "sanitizer_common", "netbsd_commands")
config.netbsd_noaslr_prefix = ('sh ' +
os.path.join(nb_commands_dir, 'run_noaslr.sh'))
config.netbsd_nomprotect_prefix = ('sh ' +
os.path.join(nb_commands_dir,
'run_nomprotect.sh'))
config.substitutions.append( ('%run_nomprotect',
config.netbsd_nomprotect_prefix) )
else:
config.substitutions.append( ('%run_nomprotect', '%run') )
# Allow tests to be executed on a simulator or remotely.
if config.emulator:
config.substitutions.append( ('%run', config.emulator) )
@ -498,9 +511,3 @@ elif config.use_lld and (not config.has_lld):
config.clang = " " + " ".join(run_wrapper + [config.compile_wrapper, config.clang]) + " "
config.target_cflags = " " + " ".join(target_cflags + extra_cflags) + " "
if config.host_os == 'NetBSD':
nb_commands_dir = os.path.join(config.compiler_rt_src_root,
"test", "sanitizer_common", "netbsd_commands")
config.netbsd_noaslr_prefix = ('sh ' +
os.path.join(nb_commands_dir, 'run_noaslr.sh'))

View File

@ -0,0 +1,3 @@
#!/bin/sh
/usr/sbin/paxctl +m "${1}"
exec "${@}"