Skip to content

Commit

Permalink
CET shouldn't be enabled in 32-bit run-time libraries by defualt
Browse files Browse the repository at this point in the history
ENDBR32 and RDSSPD are multi-byte NOPs on x86-64 processors and
newer x86 processors, starting Pentium Pro.  They are UD on older
32-bit processors. Detect this at configure time and adjust the
default value for enable_cet. GCC will enable CET in 32-bit run-time
libraries in any case if --enable-cet is used to configure GCC.

	PR target/84148
	* config/cet.m4: Check if target support multi-byte NOPS (SSE).
	* libatomic/configure: Regenerate.
	* libbacktrace/configure: Likewise.
	* libgcc/configure: Likewise.
	* libgfortran/configure: Likewise.
	* libgomp/configure: Likewise.
	* libitm/configure: Likewise.
	* libmpx/configure: Likewise.
	* libobjc/configure: Likewise.
	* libquadmath/configure: Likewise.
	* libsanitizer/configure: Likewise.
	* libssp/configure: Likewise.
	* libstdc++-v3/configure: Likewise.
	* libvtv/configure: Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257809 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
itsimbal committed Feb 19, 2018
1 parent c12ddda commit 5611e64
Show file tree
Hide file tree
Showing 28 changed files with 300 additions and 23 deletions.
5 changes: 5 additions & 0 deletions config/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* cet.m4: Check if target support multi-byte NOPS (SSE).

2018-02-06 Eric Botcazou <ebotcazou@adacore.com>

* gcc-plugin.m4 (GCC_ENABLE_PLUGINS): Remove -q option passed to grep.
Expand Down
16 changes: 14 additions & 2 deletions config/cet.m4
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,24 @@ dnl
AC_DEFUN([GCC_CET_FLAGS],[dnl
GCC_ENABLE(cet, default, ,[enable Intel CET in target libraries],
permit yes|no|default)
AC_MSG_CHECKING([for CET support])
case "$host" in
i[[34567]]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[],
[asm ("setssbsy");])],
[
#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif
])],
[enable_cet=yes],
[enable_cet=no])
;;
Expand All @@ -34,5 +43,8 @@ case "$host" in
esac
if test x$enable_cet = xyes; then
$1="-fcf-protection -mcet"
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
])
5 changes: 5 additions & 0 deletions libatomic/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-01-03 Jakub Jelinek <jakub@redhat.com>

Update copyright years.
Expand Down
17 changes: 16 additions & 1 deletion libatomic/configure
Original file line number Diff line number Diff line change
Expand Up @@ -15314,18 +15314,28 @@ else
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }

case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif

;
return 0;
}
Expand Down Expand Up @@ -15365,6 +15375,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

XCFLAGS="$XCFLAGS $CET_FLAGS"
Expand Down
5 changes: 5 additions & 0 deletions libbacktrace/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-02-15 Jakub Jelinek <jakub@redhat.com>

PR other/82368
Expand Down
17 changes: 16 additions & 1 deletion libbacktrace/configure
Original file line number Diff line number Diff line change
Expand Up @@ -11802,18 +11802,28 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }
case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif
;
return 0;
}
Expand Down Expand Up @@ -11853,6 +11863,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
EXTRA_FLAGS="$EXTRA_FLAGS $CET_FLAGS"
Expand Down
5 changes: 5 additions & 0 deletions libgcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-02-16 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84239
Expand Down
17 changes: 16 additions & 1 deletion libgcc/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4790,18 +4790,28 @@ else
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }
case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif
;
return 0;
}
Expand Down Expand Up @@ -4841,6 +4851,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
Expand Down
5 changes: 5 additions & 0 deletions libgfortran/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-02-18 Jerry DeLisle <jvdelisle@gcc.gnu.org>

PR libgfortran/84412
Expand Down
21 changes: 18 additions & 3 deletions libgfortran/configure
Original file line number Diff line number Diff line change
Expand Up @@ -5804,18 +5804,28 @@ else
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }

case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif

;
return 0;
}
Expand Down Expand Up @@ -5855,6 +5865,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

AM_FCFLAGS="$AM_FCFLAGS $CET_FLAGS"
Expand Down Expand Up @@ -12498,7 +12513,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12501 "configure"
#line 12516 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -12604,7 +12619,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 12607 "configure"
#line 12622 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down
5 changes: 5 additions & 0 deletions libgomp/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-19 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-02-16 Jakub Jelinek <jakub@redhat.com>

PR fortran/84418
Expand Down
19 changes: 17 additions & 2 deletions libgomp/configure
Original file line number Diff line number Diff line change
Expand Up @@ -15142,7 +15142,7 @@ fi

# Plugins for offload execution, configure.ac fragment. -*- mode: autoconf -*-
#
# Copyright (C) 2014-2017 Free Software Foundation, Inc.
# Copyright (C) 2014-2018 Free Software Foundation, Inc.
#
# Contributed by Mentor Embedded.
#
Expand Down Expand Up @@ -16633,18 +16633,28 @@ else
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }

case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif

;
return 0;
}
Expand Down Expand Up @@ -16684,6 +16694,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

XCFLAGS="$XCFLAGS $CET_FLAGS"
Expand Down
5 changes: 5 additions & 0 deletions libitm/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2018-01-03 Jakub Jelinek <jakub@redhat.com>

Update copyright years.
Expand Down
17 changes: 16 additions & 1 deletion libitm/configure
Original file line number Diff line number Diff line change
Expand Up @@ -17603,18 +17603,28 @@ else
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CET support" >&5
$as_echo_n "checking for CET support... " >&6; }

case "$host" in
i[34567]86-*-linux* | x86_64-*-linux*)
case "$enable_cet" in
default)
# Check if assembler supports CET.
# Check if target supports multi-byte NOPs
# and if assembler supports CET insn.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

#if !defined(__SSE2__)
#error target does not support multi-byte NOPs
#else
asm ("setssbsy");
#endif

;
return 0;
}
Expand Down Expand Up @@ -17654,6 +17664,11 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
esac
if test x$enable_cet = xyes; then
CET_FLAGS="-fcf-protection -mcet"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

XCFLAGS="$XCFLAGS $CET_FLAGS"
Expand Down
7 changes: 6 additions & 1 deletion libmpx/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>
2018-02-14 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

PR target/84148
* configure: Regenerate.

2017-11-17 Igor Tsimbalist <igor.v.tsimbalist@intel.com>

* Makefile.in: Regenerate.
* acinclude.m4: Add enable.m4 and cet.m4.
Expand Down
Loading

0 comments on commit 5611e64

Please sign in to comment.