Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgejin <ge.jin@intel.com>2021-08-26 11:20:38 +0300
committergejin <ge.jin@intel.com>2021-08-26 11:20:38 +0300
commit21b25a1fb32ecd2e1f336123c2715f8ef1a49f97 (patch)
tree579b8628fe5a573f1852e82d0e298b694aea3000 /libunwind/test
parent9016b2a1cae244eb8f26826427eeb90eded0da20 (diff)
[libunwind] Support stack unwind in CET environment
Control-flow Enforcement Technology (CET), published by Intel, introduces shadow stack feature aiming to ensure a return from a function is directed to where the function was called. In a CET enabled system, each function call will push return address into normal stack and shadow stack, when the function returns, the address stored in shadow stack will be popped and compared with the return address, program will fail if the 2 addresses don't match. In exception handling, the control flow may skip some stack frames and we must adjust shadow stack to avoid violating CET restriction. In order to achieve this, we count the number of stack frames skipped and adjust shadow stack by this number before jumping to landing pad. Reviewed By: hjl.tools, compnerd, MaskRay Differential Revision: https://reviews.llvm.org/D105968 Signed-off-by: gejin <ge.jin@intel.com>
Diffstat (limited to 'libunwind/test')
-rw-r--r--libunwind/test/CMakeLists.txt1
-rw-r--r--libunwind/test/libunwind/test/config.py2
-rw-r--r--libunwind/test/lit.site.cfg.in1
3 files changed, 4 insertions, 0 deletions
diff --git a/libunwind/test/CMakeLists.txt b/libunwind/test/CMakeLists.txt
index ae83ea90a8ce..932a6e3369d3 100644
--- a/libunwind/test/CMakeLists.txt
+++ b/libunwind/test/CMakeLists.txt
@@ -12,6 +12,7 @@ if (NOT DEFINED LIBCXX_ENABLE_SHARED)
endif()
pythonize_bool(LIBUNWIND_BUILD_32_BITS)
+pythonize_bool(LIBUNWIND_ENABLE_CET)
pythonize_bool(LIBCXX_ENABLE_SHARED)
pythonize_bool(LIBUNWIND_ENABLE_SHARED)
pythonize_bool(LIBUNWIND_ENABLE_THREADS)
diff --git a/libunwind/test/libunwind/test/config.py b/libunwind/test/libunwind/test/config.py
index 18919c247f20..2aa3b8257837 100644
--- a/libunwind/test/libunwind/test/config.py
+++ b/libunwind/test/libunwind/test/config.py
@@ -50,6 +50,8 @@ class Configuration(LibcxxConfiguration):
if not self.get_lit_bool('enable_threads', True):
self.cxx.compile_flags += ['-D_LIBUNWIND_HAS_NO_THREADS']
self.config.available_features.add('libunwind-no-threads')
+ if self.get_lit_bool('x86_cet', False):
+ self.cxx.compile_flags += ['-fcf-protection=full']
super(Configuration, self).configure_compile_flags()
def configure_compile_flags_header_includes(self):
diff --git a/libunwind/test/lit.site.cfg.in b/libunwind/test/lit.site.cfg.in
index ef2ebd919272..be98070563ba 100644
--- a/libunwind/test/lit.site.cfg.in
+++ b/libunwind/test/lit.site.cfg.in
@@ -27,6 +27,7 @@ config.host_triple = "@LLVM_HOST_TRIPLE@"
config.sysroot = "@LIBUNWIND_SYSROOT@"
config.gcc_toolchain = "@LIBUNWIND_GCC_TOOLCHAIN@"
config.cxx_ext_threads = @LIBUNWIND_BUILD_EXTERNAL_THREAD_LIBRARY@
+config.x86_cet = @LIBUNWIND_ENABLE_CET@
site.addsitedir(os.path.join(config.libunwind_src_root, 'test'))
site.addsitedir(os.path.join(config.libcxx_src_root, 'utils'))