xref: /netbsd-src/external/apache2/llvm/dist/clang/lib/Headers/cet.h (revision e038c9c4676b0f19b1b7dd08a940c6ed64a6d5ae)
1*e038c9c4Sjoerg /*===------ cet.h -Control-flow Enforcement Technology  feature ------------===
2*e038c9c4Sjoerg  * Add x86 feature with IBT and/or SHSTK bits to ELF program property if they
3*e038c9c4Sjoerg  * are enabled. Otherwise, contents in this header file are unused. This file
4*e038c9c4Sjoerg  * is mainly design for assembly source code which want to enable CET.
5*e038c9c4Sjoerg  *
6*e038c9c4Sjoerg  * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
7*e038c9c4Sjoerg  * See https://llvm.org/LICENSE.txt for license information.
8*e038c9c4Sjoerg  * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
9*e038c9c4Sjoerg  *
10*e038c9c4Sjoerg  *===-----------------------------------------------------------------------===
11*e038c9c4Sjoerg  */
12*e038c9c4Sjoerg #ifndef __CET_H
13*e038c9c4Sjoerg #define __CET_H
14*e038c9c4Sjoerg 
15*e038c9c4Sjoerg #ifdef __ASSEMBLER__
16*e038c9c4Sjoerg 
17*e038c9c4Sjoerg #ifndef __CET__
18*e038c9c4Sjoerg # define _CET_ENDBR
19*e038c9c4Sjoerg #endif
20*e038c9c4Sjoerg 
21*e038c9c4Sjoerg #ifdef __CET__
22*e038c9c4Sjoerg 
23*e038c9c4Sjoerg # ifdef __LP64__
24*e038c9c4Sjoerg #  if __CET__ & 0x1
25*e038c9c4Sjoerg #    define _CET_ENDBR endbr64
26*e038c9c4Sjoerg #  else
27*e038c9c4Sjoerg #    define _CET_ENDBR
28*e038c9c4Sjoerg #  endif
29*e038c9c4Sjoerg # else
30*e038c9c4Sjoerg #  if __CET__ & 0x1
31*e038c9c4Sjoerg #    define _CET_ENDBR endbr32
32*e038c9c4Sjoerg #  else
33*e038c9c4Sjoerg #    define _CET_ENDBR
34*e038c9c4Sjoerg #  endif
35*e038c9c4Sjoerg # endif
36*e038c9c4Sjoerg 
37*e038c9c4Sjoerg 
38*e038c9c4Sjoerg #  ifdef __LP64__
39*e038c9c4Sjoerg #   define __PROPERTY_ALIGN 3
40*e038c9c4Sjoerg #  else
41*e038c9c4Sjoerg #   define __PROPERTY_ALIGN 2
42*e038c9c4Sjoerg #  endif
43*e038c9c4Sjoerg 
44*e038c9c4Sjoerg 	.pushsection ".note.gnu.property", "a"
45*e038c9c4Sjoerg 	.p2align __PROPERTY_ALIGN
46*e038c9c4Sjoerg 	.long 1f - 0f		/* name length.  */
47*e038c9c4Sjoerg 	.long 4f - 1f		/* data length.  */
48*e038c9c4Sjoerg 	/* NT_GNU_PROPERTY_TYPE_0.   */
49*e038c9c4Sjoerg 	.long 5			/* note type.  */
50*e038c9c4Sjoerg 0:
51*e038c9c4Sjoerg 	.asciz "GNU"		/* vendor name.  */
52*e038c9c4Sjoerg 1:
53*e038c9c4Sjoerg 	.p2align __PROPERTY_ALIGN
54*e038c9c4Sjoerg 	/* GNU_PROPERTY_X86_FEATURE_1_AND.  */
55*e038c9c4Sjoerg 	.long 0xc0000002	/* pr_type.  */
56*e038c9c4Sjoerg 	.long 3f - 2f		/* pr_datasz.  */
57*e038c9c4Sjoerg 2:
58*e038c9c4Sjoerg 	/* GNU_PROPERTY_X86_FEATURE_1_XXX.  */
59*e038c9c4Sjoerg 	.long __CET__
60*e038c9c4Sjoerg 3:
61*e038c9c4Sjoerg 	.p2align __PROPERTY_ALIGN
62*e038c9c4Sjoerg 4:
63*e038c9c4Sjoerg 	.popsection
64*e038c9c4Sjoerg #endif
65*e038c9c4Sjoerg #endif
66*e038c9c4Sjoerg #endif
67