From 9069eb28d45baaa8baf5e3790b03b0e2cc5b49b3 Mon Sep 17 00:00:00 2001 From: Igor Tsimbalist Date: Fri, 17 Nov 2017 22:34:50 +0100 Subject: [PATCH] Enable building libsanitizer with Intel CET libsanitizer/ * acinclude.m4: Add enable.m4 and cet.m4. * Makefile.in: Regenerate. * asan/Makefile.am: Update AM_CXXFLAGS. * asan/Makefile.in: Regenerate. * configure: Likewise. * configure.ac: Set CET_FLAGS. Update EXTRA_CFLAGS, EXTRA_CXXFLAGS, EXTRA_ASFLAGS. * interception/Makefile.am: Update AM_CXXFLAGS. * interception/Makefile.in: Regenerate. * libbacktrace/Makefile.am: Update AM_CFLAGS, AM_CXXFLAGS. * libbacktrace/Makefile.in: Regenerate. * lsan/Makefile.am: Update AM_CXXFLAGS. * lsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am: Update AM_CXXFLAGS, AM_CCASFLAGS. * sanitizer_common/sanitizer_linux_x86_64.S: Include cet.h. Add _CET_ENDBR macro. * sanitizer_common/Makefile.in: Regenerate. * tsan/Makefile.am: Update AM_CXXFLAGS. * tsan/Makefile.in: Regenerate. * tsan/tsan_rtl_amd64.S Include cet.h. Add _CET_ENDBR macro. * ubsan/Makefile.am: Update AM_CXXFLAGS. * ubsan/Makefile.in: Regenerate. From-SVN: r254896 --- libsanitizer/ChangeLog | 26 ++++++ libsanitizer/Makefile.in | 6 +- libsanitizer/acinclude.m4 | 2 + libsanitizer/asan/Makefile.am | 1 + libsanitizer/asan/Makefile.in | 8 +- libsanitizer/configure | 84 ++++++++++++++++++- libsanitizer/configure.ac | 9 ++ libsanitizer/interception/Makefile.am | 1 + libsanitizer/interception/Makefile.in | 8 +- libsanitizer/libbacktrace/Makefile.am | 2 + libsanitizer/libbacktrace/Makefile.in | 11 ++- libsanitizer/lsan/Makefile.am | 1 + libsanitizer/lsan/Makefile.in | 8 +- libsanitizer/sanitizer_common/Makefile.am | 2 + libsanitizer/sanitizer_common/Makefile.in | 9 +- .../sanitizer_common/sanitizer_linux_x86_64.S | 2 + libsanitizer/tsan/Makefile.am | 1 + libsanitizer/tsan/Makefile.in | 8 +- libsanitizer/tsan/tsan_rtl_amd64.S | 7 ++ libsanitizer/ubsan/Makefile.am | 1 + libsanitizer/ubsan/Makefile.in | 8 +- 21 files changed, 187 insertions(+), 18 deletions(-) diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog index f94a53bcd37..497c4eaed5c 100644 --- a/libsanitizer/ChangeLog +++ b/libsanitizer/ChangeLog @@ -1,3 +1,29 @@ +2017-11-17 Igor Tsimbalist + + * acinclude.m4: Add enable.m4 and cet.m4. + * Makefile.in: Regenerate. + * asan/Makefile.am: Update AM_CXXFLAGS. + * asan/Makefile.in: Regenerate. + * configure: Likewise. + * configure.ac: Set CET_FLAGS. Update EXTRA_CFLAGS, + EXTRA_CXXFLAGS, EXTRA_ASFLAGS. + * interception/Makefile.am: Update AM_CXXFLAGS. + * interception/Makefile.in: Regenerate. + * libbacktrace/Makefile.am: Update AM_CFLAGS, AM_CXXFLAGS. + * libbacktrace/Makefile.in: Regenerate. + * lsan/Makefile.am: Update AM_CXXFLAGS. + * lsan/Makefile.in: Regenerate. + * sanitizer_common/Makefile.am: Update AM_CXXFLAGS, + AM_CCASFLAGS. + * sanitizer_common/sanitizer_linux_x86_64.S: Include cet.h. + Add _CET_ENDBR macro. + * sanitizer_common/Makefile.in: Regenerate. + * tsan/Makefile.am: Update AM_CXXFLAGS. + * tsan/Makefile.in: Regenerate. + * tsan/tsan_rtl_amd64.S Include cet.h. Add _CET_ENDBR macro. + * ubsan/Makefile.am: Update AM_CXXFLAGS. + * ubsan/Makefile.in: Regenerate. + 2017-11-08 Jakub Jelinek PR bootstrap/82670 diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in index fd0f7fd78f9..a9fea21eaf8 100644 --- a/libsanitizer/Makefile.in +++ b/libsanitizer/Makefile.in @@ -75,7 +75,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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 \ @@ -174,6 +175,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ diff --git a/libsanitizer/acinclude.m4 b/libsanitizer/acinclude.m4 index 8e606e7a6d9..059b4595d75 100644 --- a/libsanitizer/acinclude.m4 +++ b/libsanitizer/acinclude.m4 @@ -2,6 +2,8 @@ dnl ---------------------------------------------------------------------- dnl This whole bit snagged from libgfortran. sinclude(../libtool.m4) +sinclude(../config/enable.m4) +sinclude(../config/cet.m4) dnl The lines below arrange for aclocal not to bring an installed dnl libtool.m4 into aclocal.m4, while still arranging for automake to dnl add a definition of LIBTOOL to Makefile.in. diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am index 709b6c8d75b..f105b035796 100644 --- a/libsanitizer/asan/Makefile.am +++ b/libsanitizer/asan/Makefile.am @@ -10,6 +10,7 @@ endif AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros -fno-ipa-icf AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config toolexeclib_LTLIBRARIES = libasan.la diff --git a/libsanitizer/asan/Makefile.in b/libsanitizer/asan/Makefile.in index db3c3ced8b9..4cf27e712f7 100644 --- a/libsanitizer/asan/Makefile.in +++ b/libsanitizer/asan/Makefile.in @@ -69,7 +69,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -184,6 +185,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -304,7 +308,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros -fno-ipa-icf \ - $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -std=gnu++11 + $(LIBSTDCXX_RAW_CXX_CXXFLAGS) -std=gnu++11 $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config toolexeclib_LTLIBRARIES = libasan.la nodist_toolexeclib_HEADERS = libasan_preinit.o diff --git a/libsanitizer/configure b/libsanitizer/configure index 8e0c47ea838..a0104d8c2ab 100755 --- a/libsanitizer/configure +++ b/libsanitizer/configure @@ -604,6 +604,9 @@ ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +EXTRA_CXXFLAGS +EXTRA_CFLAGS +EXTRA_ASFLAGS get_gcc_base_ver SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS TSAN_TARGET_DEPENDENT_OBJECTS @@ -774,6 +777,7 @@ enable_fast_install with_gnu_ld enable_libtool_lock with_gcc_major_version_only +enable_cet ' ac_precious_vars='build_alias host_alias @@ -1421,6 +1425,8 @@ Optional Features: --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) + --enable-cet enable Intel CET in target libraries + [default=default] Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -12032,7 +12038,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12035 "configure" +#line 12041 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12138,7 +12144,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12141 "configure" +#line 12147 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -16519,6 +16525,80 @@ fi +# Add CET specific flags if Intel 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 + +EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS" +EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS" +EXTRA_ASFLAGS=$CET_FLAGS + + + + cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac index b0c485b0f7b..0d11afd1948 100644 --- a/libsanitizer/configure.ac +++ b/libsanitizer/configure.ac @@ -380,4 +380,13 @@ AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS]) # Determine what GCC version number to use in filesystem paths. GCC_BASE_VER +# Add CET specific flags if Intel CET is enabled. +GCC_CET_FLAGS(CET_FLAGS) +EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS" +EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS" +EXTRA_ASFLAGS=$CET_FLAGS +AC_SUBST(EXTRA_ASFLAGS) +AC_SUBST(EXTRA_CFLAGS) +AC_SUBST(EXTRA_CXXFLAGS) + AC_OUTPUT diff --git a/libsanitizer/interception/Makefile.am b/libsanitizer/interception/Makefile.am index bd3172309bd..22ce8d5edac 100644 --- a/libsanitizer/interception/Makefile.am +++ b/libsanitizer/interception/Makefile.am @@ -7,6 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libinterception.la diff --git a/libsanitizer/interception/Makefile.in b/libsanitizer/interception/Makefile.in index c71fb57b8b8..4eb64562e70 100644 --- a/libsanitizer/interception/Makefile.in +++ b/libsanitizer/interception/Makefile.in @@ -65,7 +65,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -132,6 +133,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -252,7 +256,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++11 + -std=gnu++11 $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libinterception.la interception_files = \ diff --git a/libsanitizer/libbacktrace/Makefile.am b/libsanitizer/libbacktrace/Makefile.am index 34bfb1eef27..9c752272be1 100644 --- a/libsanitizer/libbacktrace/Makefile.am +++ b/libsanitizer/libbacktrace/Makefile.am @@ -39,8 +39,10 @@ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \ C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter AM_CFLAGS = $(C_WARN_FLAGS) +AM_CFLAGS += $(EXTRA_CFLAGS) AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) noinst_LTLIBRARIES = libsanitizer_libbacktrace.la diff --git a/libsanitizer/libbacktrace/Makefile.in b/libsanitizer/libbacktrace/Makefile.in index dff04cfa3ea..e23aa846a56 100644 --- a/libsanitizer/libbacktrace/Makefile.in +++ b/libsanitizer/libbacktrace/Makefile.in @@ -97,7 +97,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -174,6 +175,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -295,8 +299,9 @@ WARN_FLAGS = -W -Wall -Wwrite-strings -Wmissing-format-attribute \ C_WARN_FLAGS = $(WARN_FLAGS) -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition CXX_WARN_FLAGS = $(WARN_FLAGS) -Wno-unused-parameter -AM_CFLAGS = $(C_WARN_FLAGS) -AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions -std=gnu++11 +AM_CFLAGS = $(C_WARN_FLAGS) $(EXTRA_CFLAGS) +AM_CXXFLAGS = $(CXX_WARN_FLAGS) -fno-rtti -fno-exceptions -std=gnu++11 \ + $(EXTRA_CXXFLAGS) noinst_LTLIBRARIES = libsanitizer_libbacktrace.la libsanitizer_libbacktrace_la_SOURCES = \ ../../libbacktrace/backtrace.h \ diff --git a/libsanitizer/lsan/Makefile.am b/libsanitizer/lsan/Makefile.am index 700d15fce57..423ffc249e0 100644 --- a/libsanitizer/lsan/Makefile.am +++ b/libsanitizer/lsan/Makefile.am @@ -7,6 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libsanitizer_lsan.la diff --git a/libsanitizer/lsan/Makefile.in b/libsanitizer/lsan/Makefile.in index 85502500728..a88d1f82647 100644 --- a/libsanitizer/lsan/Makefile.in +++ b/libsanitizer/lsan/Makefile.in @@ -67,7 +67,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -177,6 +178,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -297,7 +301,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++11 + -std=gnu++11 $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libsanitizer_lsan.la @LSAN_SUPPORTED_TRUE@toolexeclib_LTLIBRARIES = liblsan.la diff --git a/libsanitizer/sanitizer_common/Makefile.am b/libsanitizer/sanitizer_common/Makefile.am index adaab4cee54..246985b9933 100644 --- a/libsanitizer/sanitizer_common/Makefile.am +++ b/libsanitizer/sanitizer_common/Makefile.am @@ -7,6 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) if LIBBACKTRACE_SUPPORTED AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ -I $(top_srcdir)/../libbacktrace \ @@ -14,6 +15,7 @@ AM_CXXFLAGS += -DSANITIZER_LIBBACKTRACE -DSANITIZER_CP_DEMANGLE \ -I $(top_srcdir)/../include \ -include $(top_srcdir)/libbacktrace/backtrace-rename.h endif +AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libsanitizer_common.la diff --git a/libsanitizer/sanitizer_common/Makefile.in b/libsanitizer/sanitizer_common/Makefile.in index b2acc5caf56..b0f5ac25a7f 100644 --- a/libsanitizer/sanitizer_common/Makefile.in +++ b/libsanitizer/sanitizer_common/Makefile.in @@ -71,7 +71,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -177,6 +178,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -297,7 +301,8 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++11 $(am__append_1) + -std=gnu++11 $(EXTRA_CXXFLAGS) $(am__append_1) +AM_CCASFLAGS = $(EXTRA_ASFLAGS) ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libsanitizer_common.la sanitizer_common_files = \ diff --git a/libsanitizer/sanitizer_common/sanitizer_linux_x86_64.S b/libsanitizer/sanitizer_common/sanitizer_linux_x86_64.S index 8ff909542b6..846d1a43370 100644 --- a/libsanitizer/sanitizer_common/sanitizer_linux_x86_64.S +++ b/libsanitizer/sanitizer_common/sanitizer_linux_x86_64.S @@ -10,12 +10,14 @@ #if defined(__linux__) && defined(__x86_64__) #include "../builtins/assembly.h" +#include "cet.h" // If the "naked" function attribute were supported for x86 we could // do this via inline asm. .text .balign 4 DEFINE_COMPILERRT_FUNCTION(internal_sigreturn) + _CET_ENDBR mov $0xf, %eax // 0xf == SYS_rt_sigreturn mov %rcx, %r10 syscall diff --git a/libsanitizer/tsan/Makefile.am b/libsanitizer/tsan/Makefile.am index c218983e2fe..753cb8f4fc1 100644 --- a/libsanitizer/tsan/Makefile.am +++ b/libsanitizer/tsan/Makefile.am @@ -7,6 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libtsan.la diff --git a/libsanitizer/tsan/Makefile.in b/libsanitizer/tsan/Makefile.in index e32e9c0bfa1..629056bf17b 100644 --- a/libsanitizer/tsan/Makefile.in +++ b/libsanitizer/tsan/Makefile.in @@ -68,7 +68,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -193,6 +194,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -313,7 +317,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++11 + -std=gnu++11 $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libtsan.la nodist_toolexeclib_HEADERS = libtsan_preinit.o diff --git a/libsanitizer/tsan/tsan_rtl_amd64.S b/libsanitizer/tsan/tsan_rtl_amd64.S index 98947fd2a1b..4eb1ffdd2b7 100644 --- a/libsanitizer/tsan/tsan_rtl_amd64.S +++ b/libsanitizer/tsan/tsan_rtl_amd64.S @@ -2,6 +2,7 @@ #if defined(__x86_64__) #include "sanitizer_common/sanitizer_asm.h" +#include "cet.h" #if !defined(__APPLE__) .section .text @@ -13,6 +14,7 @@ ASM_HIDDEN(__tsan_trace_switch) .globl ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk) ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk): CFI_STARTPROC + _CET_ENDBR # Save scratch registers. push %rax CFI_ADJUST_CFA_OFFSET(8) @@ -93,6 +95,7 @@ ASM_HIDDEN(__tsan_report_race) .globl ASM_TSAN_SYMBOL(__tsan_report_race_thunk) ASM_TSAN_SYMBOL(__tsan_report_race_thunk): CFI_STARTPROC + _CET_ENDBR # Save scratch registers. push %rax CFI_ADJUST_CFA_OFFSET(8) @@ -177,6 +180,7 @@ ASM_HIDDEN(__tsan_setjmp) ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)) ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp): CFI_STARTPROC + _CET_ENDBR // save env parameter push %rdi CFI_ADJUST_CFA_OFFSET(8) @@ -218,6 +222,7 @@ ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)) ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)) ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp): CFI_STARTPROC + _CET_ENDBR // save env parameter push %rdi CFI_ADJUST_CFA_OFFSET(8) @@ -259,6 +264,7 @@ ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)) ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)) ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp): CFI_STARTPROC + _CET_ENDBR // save env parameter push %rdi CFI_ADJUST_CFA_OFFSET(8) @@ -315,6 +321,7 @@ ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)) ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp)) ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp): CFI_STARTPROC + _CET_ENDBR // save env parameter push %rdi CFI_ADJUST_CFA_OFFSET(8) diff --git a/libsanitizer/ubsan/Makefile.am b/libsanitizer/ubsan/Makefile.am index fea000c0c8e..2bff6be93b7 100644 --- a/libsanitizer/ubsan/Makefile.am +++ b/libsanitizer/ubsan/Makefile.am @@ -7,6 +7,7 @@ DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti -fomit-frame-pointer -funwind-tables -fvisibility=hidden -Wno-variadic-macros AM_CXXFLAGS += $(LIBSTDCXX_RAW_CXX_CXXFLAGS) AM_CXXFLAGS += -std=gnu++11 +AM_CXXFLAGS += $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libubsan.la diff --git a/libsanitizer/ubsan/Makefile.in b/libsanitizer/ubsan/Makefile.in index e757d29cd4a..d75260f1ef7 100644 --- a/libsanitizer/ubsan/Makefile.in +++ b/libsanitizer/ubsan/Makefile.in @@ -67,7 +67,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/../libtool.m4 \ - $(top_srcdir)/configure.ac + $(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) mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs @@ -171,6 +172,9 @@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ +EXTRA_ASFLAGS = @EXTRA_ASFLAGS@ +EXTRA_CFLAGS = @EXTRA_CFLAGS@ +EXTRA_CXXFLAGS = @EXTRA_CXXFLAGS@ FGREP = @FGREP@ FORMAT_FILE = @FORMAT_FILE@ GREP = @GREP@ @@ -291,7 +295,7 @@ AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic \ -Wno-long-long -fPIC -fno-builtin -fno-exceptions -fno-rtti \ -fomit-frame-pointer -funwind-tables -fvisibility=hidden \ -Wno-variadic-macros $(LIBSTDCXX_RAW_CXX_CXXFLAGS) \ - -std=gnu++11 + -std=gnu++11 $(EXTRA_CXXFLAGS) ACLOCAL_AMFLAGS = -I m4 toolexeclib_LTLIBRARIES = libubsan.la ubsan_plugin_files = \ -- 2.30.2