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