Enable building libssp with Intel CET
authorIgor Tsimbalist <igor.v.tsimbalist@intel.com>
Fri, 17 Nov 2017 22:32:46 +0000 (23:32 +0100)
committerIgor Tsimbalist <itsimbal@gcc.gnu.org>
Fri, 17 Nov 2017 22:32:46 +0000 (23:32 +0100)
libssp/
* Makefile.am: Update AM_CFLAGS, update
libssp_nonshared_la_CFLAGS.
* Makefile.in: Regenerate.
* configure: Likewise.
* aclocal.m4: Likewise.
* configure.ac: Set CET_FLAGS. Update XCFLAGS.

From-SVN: r254898

libssp/ChangeLog
libssp/Makefile.am
libssp/Makefile.in
libssp/aclocal.m4
libssp/configure
libssp/configure.ac

index 65733b08ac68960dfd4ec548c209109c866c2377..17df1ee2ff19f5fa9bb251793e8821526a368c3e 100644 (file)
@@ -1,3 +1,12 @@
+2017-11-17  Igor Tsimbalist  <igor.v.tsimbalist@intel.com>
+
+       * Makefile.am: Update AM_CFLAGS, update
+       libssp_nonshared_la_CFLAGS.
+       * Makefile.in: Regenerate.
+       * configure: Likewise.
+       * aclocal.m4: Likewise.
+       * configure.ac: Set CET_FLAGS. Update XCFLAGS.
+
 2017-04-01  Jonathan Yong  <10walls@gmail.com>
 
        * ssp.c (__guard_setup): Suppress unused variable warning.
index 72df8e791297a48f3662b0674c28921cd3f3f5d7..9134f96383e0f7ab364552737e1bb8da4501b0f1 100644 (file)
@@ -34,6 +34,7 @@ version_dep =
 endif
 
 AM_CFLAGS = -Wall
+AM_CFLAGS += $(XCFLAGS)
 
 toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
 
@@ -53,7 +54,7 @@ libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
 
 libssp_nonshared_la_SOURCES = \
        ssp-local.c
-libssp_nonshared_la_CFLAGS = -prefer-pic
+libssp_nonshared_la_CFLAGS = -prefer-pic $(XCFLAGS)
 libssp_nonshared_la_LIBADD = 
 libssp_nonshared_la_DEPENDENCIES = $(libssp_nonshared_la_LIBADD)
 libssp_nonshared_la_LDFLAGS = -static
index 96b03ae124812d1b09e28b923cf9a9d171aab1ed..e2a754008945fd9e3c0127ea72b6217effb03c4d 100644 (file)
@@ -69,7 +69,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
        $(top_srcdir)/../config/override.m4 \
        $(top_srcdir)/../libtool.m4 $(top_srcdir)/../ltoptions.m4 \
        $(top_srcdir)/../ltsugar.m4 $(top_srcdir)/../ltversion.m4 \
-       $(top_srcdir)/../lt~obsolete.m4 $(top_srcdir)/configure.ac
+       $(top_srcdir)/../lt~obsolete.m4 \
+       $(top_srcdir)/../config/enable.m4 \
+       $(top_srcdir)/../config/cet.m4 $(top_srcdir)/configure.ac
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@@ -210,6 +212,7 @@ SET_MAKE = @SET_MAKE@
 SHELL = @SHELL@
 STRIP = @STRIP@
 VERSION = @VERSION@
+XCFLAGS = @XCFLAGS@
 abs_builddir = @abs_builddir@
 abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
@@ -286,7 +289,7 @@ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
 @LIBSSP_USE_SYMVER_FALSE@version_dep = 
 @LIBSSP_USE_SYMVER_GNU_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = $(srcdir)/ssp.map
 @LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = ssp.map-sun
-AM_CFLAGS = -Wall
+AM_CFLAGS = -Wall $(XCFLAGS)
 toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
 libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
 nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
@@ -304,7 +307,7 @@ libssp_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
 libssp_nonshared_la_SOURCES = \
        ssp-local.c
 
-libssp_nonshared_la_CFLAGS = -prefer-pic
+libssp_nonshared_la_CFLAGS = -prefer-pic $(XCFLAGS)
 libssp_nonshared_la_LIBADD = 
 libssp_nonshared_la_DEPENDENCIES = $(libssp_nonshared_la_LIBADD)
 libssp_nonshared_la_LDFLAGS = -static
index 927988e5814e903b343196191ebca3202014bc7d..7eeae0cf2a9a312205134d38a555560f25b4b511 100644 (file)
@@ -1000,3 +1000,5 @@ m4_include([../ltoptions.m4])
 m4_include([../ltsugar.m4])
 m4_include([../ltversion.m4])
 m4_include([../lt~obsolete.m4])
+m4_include([../config/enable.m4])
+m4_include([../config/cet.m4])
index b14e922e6f158a419b7dd7e8bef1fddbf063b6bb..a96b39197ffe34dbb10deeb67df03bebceef1d91 100755 (executable)
@@ -633,6 +633,7 @@ LIBSSP_USE_SYMVER_GNU_FALSE
 LIBSSP_USE_SYMVER_GNU_TRUE
 LIBSSP_USE_SYMVER_FALSE
 LIBSSP_USE_SYMVER_TRUE
+XCFLAGS
 CPP
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
@@ -736,6 +737,7 @@ enable_version_specific_runtime_libs
 enable_maintainer_mode
 enable_multilib
 enable_dependency_tracking
+enable_cet
 enable_symvers
 enable_shared
 enable_static
@@ -1376,6 +1378,8 @@ Optional Features:
   --enable-multilib       build many library versions (default)
   --disable-dependency-tracking  speeds up one-time build
   --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-cet            enable Intel CET in target libraries
+                          [default=default]
   --disable-symvers       disable symbol versioning for libssp
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
@@ -4077,6 +4081,76 @@ fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 CFLAGS="$save_CFLAGS"
 
+# Add CET specific flags if CET is enabled
+ # Check whether --enable-cet was given.
+if test "${enable_cet+set}" = set; then :
+  enableval=$enable_cet;
+      case "$enableval" in
+       yes|no|default) ;;
+       *) as_fn_error "Unknown argument to enable/disable cet" "$LINENO" 5 ;;
+                          esac
+
+else
+  enable_cet=default
+fi
+
+
+case "$host" in
+  i[34567]86-*-linux* | x86_64-*-linux*)
+    case "$enable_cet" in
+      default)
+       # Check if assembler supports CET.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+asm ("setssbsy");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  enable_cet=yes
+else
+  enable_cet=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       ;;
+      yes)
+       # Check if assembler supports CET.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+asm ("setssbsy");
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  as_fn_error "assembler with CET support is required for --enable-cet" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       ;;
+    esac
+    ;;
+  *)
+    enable_cet=no
+    ;;
+esac
+if test x$enable_cet = xyes; then
+  CET_FLAGS="-fcf-protection -mcet"
+fi
+
+XCFLAGS="$XCFLAGS $CET_FLAGS"
+
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether hidden visibility is supported" >&5
 $as_echo_n "checking whether hidden visibility is supported... " >&6; }
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
@@ -10671,7 +10745,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10674 "configure"
+#line 10748 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10777,7 +10851,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10780 "configure"
+#line 10854 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
index 9e4a22a24d47e9b8467ffa2dc45b445d5e636f45..0d228c17d1a38297fb4a6d280d6dfc7d98cc3f84 100644 (file)
@@ -62,6 +62,11 @@ void __attribute__((noinline)) bar (char *x)
 [AC_MSG_RESULT(no)])
 CFLAGS="$save_CFLAGS"
 
+# Add CET specific flags if CET is enabled
+GCC_CET_FLAGS(CET_FLAGS)
+XCFLAGS="$XCFLAGS $CET_FLAGS"
+AC_SUBST(XCFLAGS)
+
 AC_MSG_CHECKING([whether hidden visibility is supported])
 AC_TRY_COMPILE([
 void __attribute__((visibility ("hidden"))) bar (void) {}],,