[compiler-rt] [test] Disable ASLR on ASAN/MSAN/TSAN tests on NetBSD
authorMichał Górny <mgorny@gentoo.org>
Tue, 3 Dec 2019 13:44:33 +0000 (14:44 +0100)
committerMichał Górny <mgorny@gentoo.org>
Fri, 6 Dec 2019 07:09:01 +0000 (08:09 +0100)
Use a new %run wrapper for ASAN/MSAN/TSAN tests that calls paxctl
in order to disable ASLR on the test executables.  This makes it
possible to test sanitizers on systems where ASLR is enabled by default.

Differential Revision: https://reviews.llvm.org/D70958

compiler-rt/test/asan/lit.cfg.py
compiler-rt/test/lit.common.cfg.py
compiler-rt/test/msan/lit.cfg.py
compiler-rt/test/sanitizer_common/lit.common.cfg.py
compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh [new file with mode: 0644]
compiler-rt/test/tsan/lit.cfg.py

index 45b8ffc..9045c6e 100644 (file)
@@ -237,3 +237,6 @@ if config.host_os not in ['Linux', 'Darwin', 'FreeBSD', 'SunOS', 'Windows', 'Net
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
index 00f0a1e..1a955ac 100644 (file)
@@ -498,3 +498,9 @@ 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'))
index d45b546..0b43d08 100644 (file)
@@ -45,3 +45,6 @@ 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'))
+
+if config.host_os == 'NetBSD':
+  config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
index 26e08ed..a587daa 100644 (file)
@@ -73,3 +73,6 @@ if config.host_os not in ['Linux', 'Darwin', 'NetBSD', 'FreeBSD']:
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))
diff --git a/compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh b/compiler-rt/test/sanitizer_common/netbsd_commands/run_noaslr.sh
new file mode 100644 (file)
index 0000000..cb89b95
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+/usr/sbin/paxctl +a "${1}"
+exec "${@}"
index a16d8e7..ece8e66 100644 (file)
@@ -88,3 +88,6 @@ if config.android:
 
 if not config.parallelism_group:
   config.parallelism_group = 'shadow-memory'
+
+if config.host_os == 'NetBSD':
+  config.substitutions.insert(0, ('%run', config.netbsd_noaslr_prefix))