From ff035ef67334c4a5011d2f28a8b1c5813c1da9d5 Mon Sep 17 00:00:00 2001 From: Igor Tsimbalist Date: Fri, 17 Nov 2017 23:32:46 +0100 Subject: [PATCH] Enable building libssp with Intel CET 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 | 9 ++++++ libssp/Makefile.am | 3 +- libssp/Makefile.in | 9 ++++-- libssp/aclocal.m4 | 2 ++ libssp/configure | 78 +++++++++++++++++++++++++++++++++++++++++++-- libssp/configure.ac | 5 +++ 6 files changed, 100 insertions(+), 6 deletions(-) diff --git a/libssp/ChangeLog b/libssp/ChangeLog index 65733b08ac6..17df1ee2ff1 100644 --- a/libssp/ChangeLog +++ b/libssp/ChangeLog @@ -1,3 +1,12 @@ +2017-11-17 Igor Tsimbalist + + * 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. diff --git a/libssp/Makefile.am b/libssp/Makefile.am index 72df8e79129..9134f96383e 100644 --- a/libssp/Makefile.am +++ b/libssp/Makefile.am @@ -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 diff --git a/libssp/Makefile.in b/libssp/Makefile.in index 96b03ae1248..e2a75400894 100644 --- a/libssp/Makefile.in +++ b/libssp/Makefile.in @@ -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 diff --git a/libssp/aclocal.m4 b/libssp/aclocal.m4 index 927988e5814..7eeae0cf2a9 100644 --- a/libssp/aclocal.m4 +++ b/libssp/aclocal.m4 @@ -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]) diff --git a/libssp/configure b/libssp/configure index b14e922e6f1..a96b39197ff 100755 --- a/libssp/configure +++ b/libssp/configure @@ -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 diff --git a/libssp/configure.ac b/libssp/configure.ac index 9e4a22a24d4..0d228c17d1a 100644 --- a/libssp/configure.ac +++ b/libssp/configure.ac @@ -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) {}],,