1*0faf1914Srobert //===----------------------------------------------------------------------===// 2*0faf1914Srobert // 3*0faf1914Srobert // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*0faf1914Srobert // See https://llvm.org/LICENSE.txt for license information. 5*0faf1914Srobert // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*0faf1914Srobert // 7*0faf1914Srobert // 8*0faf1914Srobert //===----------------------------------------------------------------------===// 9*0faf1914Srobert 10*0faf1914Srobert #ifndef LIBUNWIND_CET_UNWIND_H 11*0faf1914Srobert #define LIBUNWIND_CET_UNWIND_H 12*0faf1914Srobert 13*0faf1914Srobert #include "libunwind.h" 14*0faf1914Srobert 15*0faf1914Srobert // Currently, CET is implemented on Linux x86 platforms. 16*0faf1914Srobert #if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__) 17*0faf1914Srobert #define _LIBUNWIND_USE_CET 1 18*0faf1914Srobert #endif 19*0faf1914Srobert 20*0faf1914Srobert #if defined(_LIBUNWIND_USE_CET) 21*0faf1914Srobert #include <cet.h> 22*0faf1914Srobert #include <immintrin.h> 23*0faf1914Srobert 24*0faf1914Srobert #define _LIBUNWIND_POP_CET_SSP(x) \ 25*0faf1914Srobert do { \ 26*0faf1914Srobert unsigned long ssp = _get_ssp(); \ 27*0faf1914Srobert if (ssp != 0) { \ 28*0faf1914Srobert unsigned int tmp = (x); \ 29*0faf1914Srobert while (tmp > 255) { \ 30*0faf1914Srobert _inc_ssp(255); \ 31*0faf1914Srobert tmp -= 255; \ 32*0faf1914Srobert } \ 33*0faf1914Srobert _inc_ssp(tmp); \ 34*0faf1914Srobert } \ 35*0faf1914Srobert } while (0) 36*0faf1914Srobert #endif 37*0faf1914Srobert 38*0faf1914Srobert extern void *__libunwind_cet_get_registers(unw_cursor_t *); 39*0faf1914Srobert extern void *__libunwind_cet_get_jump_target(void); 40*0faf1914Srobert 41*0faf1914Srobert #endif 42