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