1 1.1 mrg /* ELF program property for Intel CET. 2 1.1.1.4 mrg Copyright (C) 2017-2022 Free Software Foundation, Inc. 3 1.1 mrg 4 1.1 mrg This file is free software; you can redistribute it and/or modify it 5 1.1 mrg under the terms of the GNU General Public License as published by the 6 1.1 mrg Free Software Foundation; either version 3, or (at your option) any 7 1.1 mrg later version. 8 1.1 mrg 9 1.1 mrg This file is distributed in the hope that it will be useful, but 10 1.1 mrg WITHOUT ANY WARRANTY; without even the implied warranty of 11 1.1 mrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 1.1 mrg General Public License for more details. 13 1.1 mrg 14 1.1 mrg Under Section 7 of GPL version 3, you are granted additional 15 1.1 mrg permissions described in the GCC Runtime Library Exception, version 16 1.1 mrg 3.1, as published by the Free Software Foundation. 17 1.1 mrg 18 1.1 mrg You should have received a copy of the GNU General Public License and 19 1.1 mrg a copy of the GCC Runtime Library Exception along with this program; 20 1.1 mrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 21 1.1 mrg <http://www.gnu.org/licenses/>. 22 1.1 mrg */ 23 1.1 mrg 24 1.1 mrg /* Add x86 feature with IBT and/or SHSTK bits to ELF program property 25 1.1 mrg if they are enabled. Otherwise, contents in this header file are 26 1.1 mrg unused. Define _CET_ENDBR for assembly codes. _CET_ENDBR should be 27 1.1 mrg placed unconditionally at the entrance of a function whose address 28 1.1 mrg may be taken. */ 29 1.1 mrg 30 1.1 mrg #ifndef _CET_H_INCLUDED 31 1.1 mrg #define _CET_H_INCLUDED 32 1.1 mrg 33 1.1 mrg #ifdef __ASSEMBLER__ 34 1.1 mrg 35 1.1 mrg # if defined __CET__ && (__CET__ & 1) != 0 36 1.1 mrg # ifdef __x86_64__ 37 1.1 mrg # define _CET_ENDBR endbr64 38 1.1 mrg # else 39 1.1 mrg # define _CET_ENDBR endbr32 40 1.1 mrg # endif 41 1.1 mrg # else 42 1.1 mrg # define _CET_ENDBR 43 1.1 mrg # endif 44 1.1 mrg 45 1.1 mrg # ifdef __ELF__ 46 1.1 mrg # ifdef __CET__ 47 1.1 mrg # if (__CET__ & 1) != 0 48 1.1 mrg /* GNU_PROPERTY_X86_FEATURE_1_IBT. */ 49 1.1 mrg # define __PROPERTY_IBT 0x1 50 1.1 mrg # else 51 1.1 mrg # define __PROPERTY_IBT 0x0 52 1.1 mrg # endif 53 1.1 mrg 54 1.1 mrg # if (__CET__ & 2) != 0 55 1.1 mrg /* GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ 56 1.1 mrg # define __PROPERTY_SHSTK 0x2 57 1.1 mrg # else 58 1.1 mrg # define __PROPERTY_SHSTK 0x0 59 1.1 mrg # endif 60 1.1 mrg 61 1.1 mrg # define __PROPERTY_BITS (__PROPERTY_IBT | __PROPERTY_SHSTK) 62 1.1 mrg 63 1.1 mrg # ifdef __LP64__ 64 1.1 mrg # define __PROPERTY_ALIGN 3 65 1.1 mrg # else 66 1.1 mrg # define __PROPERTY_ALIGN 2 67 1.1 mrg # endif 68 1.1 mrg 69 1.1 mrg .pushsection ".note.gnu.property", "a" 70 1.1 mrg .p2align __PROPERTY_ALIGN 71 1.1 mrg .long 1f - 0f /* name length. */ 72 1.1 mrg .long 4f - 1f /* data length. */ 73 1.1 mrg /* NT_GNU_PROPERTY_TYPE_0. */ 74 1.1 mrg .long 5 /* note type. */ 75 1.1 mrg 0: 76 1.1 mrg .asciz "GNU" /* vendor name. */ 77 1.1 mrg 1: 78 1.1 mrg .p2align __PROPERTY_ALIGN 79 1.1 mrg /* GNU_PROPERTY_X86_FEATURE_1_AND. */ 80 1.1 mrg .long 0xc0000002 /* pr_type. */ 81 1.1 mrg .long 3f - 2f /* pr_datasz. */ 82 1.1 mrg 2: 83 1.1 mrg /* GNU_PROPERTY_X86_FEATURE_1_XXX. */ 84 1.1 mrg .long __PROPERTY_BITS 85 1.1 mrg 3: 86 1.1 mrg .p2align __PROPERTY_ALIGN 87 1.1 mrg 4: 88 1.1 mrg .popsection 89 1.1 mrg # endif /* __CET__ */ 90 1.1 mrg # endif /* __ELF__ */ 91 1.1 mrg #endif /* __ASSEMBLER__ */ 92 1.1 mrg 93 1.1 mrg #endif /* _CET_H_INCLUDED */ 94