diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-20 20:31:18 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-02-20 20:31:18 +0000 |
commit | 39a4a9d2feb820fecaf8a72066b25f335da5d627 (patch) | |
tree | 5c879a8c999aa1c713dd78c3cac3766b1feb0008 /test/cfi/lit.cfg | |
parent | ae387957e63894c2618b9e404949b0a6b5a26843 (diff) |
Add test suite for the Control Flow Integrity feature.
Differential Revision: http://reviews.llvm.org/D7738
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@230056 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/cfi/lit.cfg')
-rw-r--r-- | test/cfi/lit.cfg | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/cfi/lit.cfg b/test/cfi/lit.cfg new file mode 100644 index 000000000..d78820daa --- /dev/null +++ b/test/cfi/lit.cfg @@ -0,0 +1,35 @@ +import lit.formats +import os +import subprocess +import sys + +config.name = 'cfi' +config.suffixes = ['.cpp'] +config.test_source_root = os.path.dirname(__file__) + +def is_darwin_lto_supported(): + return os.path.exists(os.path.join(config.llvm_shlib_dir, 'libLTO.dylib')) + +def is_linux_lto_supported(): + if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')): + return False + + ld_cmd = subprocess.Popen([config.gold_executable, '--help'], stdout = subprocess.PIPE) + ld_out = ld_cmd.stdout.read().decode() + ld_cmd.wait() + + if not '-plugin' in ld_out: + return False + + return True + +clangxx = ' '.join([config.clang] + config.cxx_mode_flags) + +config.substitutions.append((r"%clangxx ", clangxx + ' ')) + +if sys.platform == 'darwin' and is_darwin_lto_supported(): + config.substitutions.append((r"%clangxx_cfi ", 'env DYLD_LIBRARY_PATH=' + config.llvm_shlib_dir + ' ' + clangxx + ' -fsanitize=cfi ')) +elif sys.platform.startswith('linux') and is_linux_lto_supported(): + config.substitutions.append((r"%clangxx_cfi ", clangxx + ' -fuse-ld=gold -fsanitize=cfi ')) +else: + config.unsupported = True |