Skip to content
Permalink
Browse files

[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
  • Loading branch information
mgorny committed Dec 14, 2019
1 parent e1882af commit 190b9110c23c0c742602d686e4a5bcff3d94fba1
@@ -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 -----------------------------===//
//
@@ -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 ----------===//
//
@@ -112,6 +112,19 @@
(' 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 @@ def is_windows_lto_supported():

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'))
@@ -0,0 +1,3 @@
#!/bin/sh
/usr/sbin/paxctl +m "${1}"
exec "${@}"

0 comments on commit 190b911

Please sign in to comment.
You can’t perform that action at this time.