3 dnl (SHELL-CODE_HANDLER)
5 AC_DEFUN([GCC_CET_FLAGS],[dnl
6 GCC_ENABLE(cet, auto, ,[enable Intel CET in target libraries],
8 AC_MSG_CHECKING([for CET support])
10 # NB: Avoid nested save_CFLAGS and save_LDFLAGS.
12 i[[34567]]86-*-linux* | x86_64-*-linux*)
15 # Check if target supports multi-byte NOPs
16 # and if compiler and assembler support CET insn.
17 cet_save_CFLAGS="$CFLAGS"
18 CFLAGS="$CFLAGS -fcf-protection"
23 #if !defined(__SSE2__)
24 #error target does not support multi-byte NOPs
31 CFLAGS="$cet_save_CFLAGS"
34 # Check if assembler supports CET.
38 [asm ("setssbsy");])],
40 [AC_MSG_ERROR([assembler with CET support is required for --enable-cet])])
48 if test x$enable_cet = xyes; then
49 $1="-fcf-protection -mshstk"
57 dnl GCC_CET_HOST_FLAGS
58 dnl (SHELL-CODE_HANDLER)
60 AC_DEFUN([GCC_CET_HOST_FLAGS],[dnl
61 GCC_ENABLE(cet, auto, ,[enable Intel CET in host libraries],
63 AC_MSG_CHECKING([for CET support])
66 i[[34567]]86-*-linux* | x86_64-*-linux*)
68 cet_save_CFLAGS="$CFLAGS"
69 CFLAGS="$CFLAGS -fcf-protection"
72 # Check if target supports multi-byte NOPs
73 # and if compiler and assembler support CET.
78 #if !defined(__SSE2__)
79 #error target does not support multi-byte NOPs
88 # Check if compiler and assembler support CET.
92 [asm ("setssbsy");])],
95 if test $support_cet = "no"; then
96 if test x$enable_bootstrap != xno \
97 && test -z "${with_build_subdir}" \
98 && (test ! -f ../stage_current \
99 || test `cat ../stage_current` != "stage1"); then
100 # Require CET support only for the final GCC build.
101 AC_MSG_ERROR([compiler and assembler with CET support are required for --enable-cet])
103 # Don't enable CET without CET support for non-bootstrap
104 # build, in stage1 nor for build support.
110 CFLAGS="$cet_save_CFLAGS"
118 cet_save_CFLAGS="$CFLAGS"
119 CFLAGS="$CFLAGS -fcf-protection=none"
120 cet_save_LDFLAGS="$LDFLAGS"
121 LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk"
122 if test x$may_have_cet = xyes; then
123 # Check whether -fcf-protection=none -Wl,-z,ibt,-z,shstk work.
130 if test x$may_have_cet = xyes; then
131 if test x$cross_compiling = xno; then
140 [have_multi_byte_nop=yes],
141 [have_multi_byte_nop=no])
143 if test x$have_multi_byte_nop = xyes; then
151 __attribute__ ((noinline, noclone))
152 xxx (void (*f) (void))
158 __attribute__ ((noinline, noclone))
174 if test x$enable_cet = xno -a x$have_cet = xyes; then
175 AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
179 # Enable CET in cross compiler if possible so that it will run on both
180 # CET and non-CET hosts.
183 if test x$enable_cet = xyes; then
189 CFLAGS="$cet_save_CFLAGS"
190 LDFLAGS="$cet_save_LDFLAGS"