From eedc73a224df61694fe4802ddec8eb9ad1822f32 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 28 Apr 2020 05:42:34 -0700 Subject: Check whether -fcf-protection=none -Wl,-z,ibt,-z,shstk work first GCC_CET_HOST_FLAGS uses -Wl,-z,ibt,-z,shstk to check if Linux/x86 host has Intel CET enabled by introducing an Intel CET violation on purpose. To avoid false positive, check whether -Wl,-z,ibt,-z,shstk works first. -fcf-protection=none is added to avoid false negative when -fcf-protection is enabled by default. config/ PR bootstrap/94739 * cet.m4 (GCC_CET_HOST_FLAGS): Add -fcf-protection=none to -Wl,-z,ibt,-z,shstk. Check whether -fcf-protection=none -Wl,-z,ibt,-z,shstk works first. libiberty/ PR bootstrap/94739 * configure: Regenerated. lto-plugin/ PR bootstrap/94739 * configure: Regenerated. --- lto-plugin/ChangeLog | 5 +++++ lto-plugin/configure | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'lto-plugin') diff --git a/lto-plugin/ChangeLog b/lto-plugin/ChangeLog index d5f7ef0329c..4ffbf122ebd 100644 --- a/lto-plugin/ChangeLog +++ b/lto-plugin/ChangeLog @@ -1,3 +1,8 @@ +2020-04-28 H.J. Lu + + PR bootstrap/94739 + * configure: Regenerated. + 2020-04-25 H.J. Lu PR bootstrap/94739 diff --git a/lto-plugin/configure b/lto-plugin/configure index e55b35ecf38..1baf6cc70b8 100755 --- a/lto-plugin/configure +++ b/lto-plugin/configure @@ -5741,9 +5741,33 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ;; esac +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -fcf-protection=none" +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk" +if test x$may_have_cet = xyes; then + # Check whether -fcf-protection=none -Wl,-z,ibt,-z,shstk work. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + may_have_cet=yes +else + may_have_cet=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi + if test x$may_have_cet = xyes; then - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,-z,ibt,-z,shstk" if test "$cross_compiling" = yes; then : { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} @@ -5789,7 +5813,6 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi - LDFLAGS="$save_LDFLAGS" if test x$enable_cet = xno -a x$have_cet = xyes; then as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5 fi @@ -5802,6 +5825,8 @@ else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi +CFLAGS="$save_CFLAGS" +LDFLAGS="$save_LDFLAGS" @@ -11916,7 +11941,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11919 "configure" +#line 11944 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12022,7 +12047,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12025 "configure" +#line 12050 "configure" #include "confdefs.h" #if HAVE_DLFCN_H -- cgit v1.2.3