1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef LIBUNWIND_CET_UNWIND_H
11 #define LIBUNWIND_CET_UNWIND_H
13 #include "libunwind.h"
15 // Currently, CET is implemented on Linux x86 platforms.
16 #if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__)
17 #define _LIBUNWIND_USE_CET 1
20 #if defined(_LIBUNWIND_USE_CET)
22 #include <immintrin.h>
24 #define _LIBUNWIND_POP_CET_SSP(x) \
26 unsigned long ssp = _get_ssp(); \
28 unsigned int tmp = (x); \
38 // On AArch64 we use _LIBUNWIND_USE_GCS to indicate that GCS is supported. We
39 // need to guard any use of GCS instructions with __chkfeat though, as GCS may
41 #if defined(_LIBUNWIND_TARGET_AARCH64) && defined(__ARM_FEATURE_GCS_DEFAULT)
44 // We can only use GCS if arm_acle.h defines the GCS intrinsics.
46 #define _LIBUNWIND_USE_GCS 1
49 #define _LIBUNWIND_POP_CET_SSP(x) \
51 if (__chkfeat(_CHKFEAT_GCS)) { \
60 extern void *__libunwind_cet_get_registers(unw_cursor_t
*);
61 extern void *__libunwind_cet_get_jump_target(void);