diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config.gcc | 4 | ||||
-rw-r--r-- | gcc/config/i386/cet.h | 93 | ||||
-rw-r--r-- | gcc/doc/install.texi | 13 |
4 files changed, 114 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 030a13c..a08574d7a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com> + + * config.gcc (extra_headers): Add cet.h for x86 targets. + * config/i386/cet.h: New file. + * doc/install.texi: Add --enable-cet/--disable-cet. + 2017-11-17 Richard Biener <rguenther@suse.de> PR tree-optimization/83017 diff --git a/gcc/config.gcc b/gcc/config.gcc index 8ee8e8c..24f9044 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -379,7 +379,7 @@ i[34567]86-*-*) avx512vbmivlintrin.h avx5124fmapsintrin.h avx5124vnniwintrin.h avx512vpopcntdqintrin.h clwbintrin.h mwaitxintrin.h clzerointrin.h pkuintrin.h sgxintrin.h cetintrin.h - gfniintrin.h" + gfniintrin.h cet.h" ;; x86_64-*-*) cpu_type=i386 @@ -404,7 +404,7 @@ x86_64-*-*) avx512vbmivlintrin.h avx5124fmapsintrin.h avx5124vnniwintrin.h avx512vpopcntdqintrin.h clwbintrin.h mwaitxintrin.h clzerointrin.h pkuintrin.h sgxintrin.h cetintrin.h - gfniintrin.h" + gfniintrin.h cet.h" ;; ia64-*-*) extra_headers=ia64intrin.h diff --git a/gcc/config/i386/cet.h b/gcc/config/i386/cet.h new file mode 100644 index 0000000..7300844 --- /dev/null +++ b/gcc/config/i386/cet.h @@ -0,0 +1,93 @@ +/* ELF program property for Intel CET. + Copyright (C) 2017 Free Software Foundation, Inc. + + This file is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3, or (at your option) any + later version. + + This file is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + <http://www.gnu.org/licenses/>. + */ + +/* Add x86 feature with IBT and/or SHSTK bits to ELF program property + if they are enabled. Otherwise, contents in this header file are + unused. Define _CET_ENDBR for assembly codes. _CET_ENDBR should be + placed unconditionally at the entrance of a function whose address + may be taken. */ + +#ifndef _CET_H_INCLUDED +#define _CET_H_INCLUDED + +#ifdef __ASSEMBLER__ + +# ifdef __IBT__ +# ifdef __x86_64__ +# define _CET_ENDBR endbr64 +# else +# define _CET_ENDBR endbr32 +# endif +# else +# define _CET_ENDBR +# endif + +# ifdef __ELF__ +# ifdef __CET__ +# ifdef __IBT__ +/* GNU_PROPERTY_X86_FEATURE_1_IBT. */ +# define __PROPERTY_IBT 0x1 +# else +# define __PROPERTY_IBT 0x0 +# endif + +# ifdef __SHSTK__ +/* GNU_PROPERTY_X86_FEATURE_1_SHSTK. */ +# define __PROPERTY_SHSTK 0x2 +# else +# define __PROPERTY_SHSTK 0x0 +# endif + +# define __PROPERTY_BITS (__PROPERTY_IBT | __PROPERTY_SHSTK) + +# ifdef __LP64__ +# define __PROPERTY_ALIGN 3 +# else +# define __PROPERTY_ALIGN 2 +# endif + + .pushsection ".note.gnu.property", "a" + .p2align __PROPERTY_ALIGN + .long 1f - 0f /* name length. */ + .long 4f - 1f /* data length. */ + /* NT_GNU_PROPERTY_TYPE_0. */ + .long 5 /* note type. */ +0: + .asciz "GNU" /* vendor name. */ +1: + .p2align __PROPERTY_ALIGN + /* GNU_PROPERTY_X86_FEATURE_1_AND. */ + .long 0xc0000002 /* pr_type. */ + .long 3f - 2f /* pr_datasz. */ +2: + /* GNU_PROPERTY_X86_FEATURE_1_XXX. */ + .long __PROPERTY_BITS +3: + .p2align __PROPERTY_ALIGN +4: + .popsection +# endif /* __CET__ */ +# endif /* __ELF__ */ +#endif /* __ASSEMBLER__ */ + +#endif /* _CET_H_INCLUDED */ diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index 22e5731..a9032c9 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -2065,6 +2065,19 @@ explicitly specify the directory where they are installed. The shorthand for @option{--with-hsa-runtime-lib=@/@var{hsainstalldir}/lib} and @option{--with-hsa-runtime-include=@/@var{hsainstalldir}/include}. + +@item --enable-cet +@itemx --disable-cet +Enable building target run-time libraries with control-flow +instrumentation, see @option{-fcf-protection} option. When +@code{--enable-cet} is specified target libraries are configured +to add @option{-fcf-protection} and, if needed, other target +specific options to a set of building options. + +The option is enabled by default on Linux/x86 if target binutils +supports @code{Intel CET} instructions. In this case the target +libraries are configured to get additional @option{-fcf-protection} +and @option{-mcet} options. @end table @subheading Cross-Compiler-Specific Options |