summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-01-16 16:46:51 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-01-16 16:46:51 -0800
commitd77a5ebe0c1683f4f95b11718df53f8b51fd2833 (patch)
treeb665bf4c9da0ca133ef6261e4a7fc945c04b189a
parent69ac5e6150ff3db96156a17f93382f9ef9438611 (diff)
downloadgcc-hjl/cet/master.tar.gz
Add --enable-cet-propertyhjl/cet/master
CET is enabled by run-time loader only if all modules have CET property: [hjl@gnu-tools-1 gcc]$ readelf -n crtbegin.o Displaying notes found in: .note.gnu.property Owner Data size Description GNU 0x00000010 NT_GNU_PROPERTY_TYPE_0 Properties: x86 feature: IBT, SHSTK [hjl@gnu-tools-1 gcc]$ Linker will create CET property only if all input object files have CET property. To create GCC run-time libraries with CET property, CET enabled glibc must be used to build GCC. We can add --enable-cet-property to GCC, which will pass "-z ibt -z shstk" to linker when creating target run-time libraries. We only need it for libgcc and libstdc++, which are used to build and test glibc. config/ PR target/83910 * cet.m4 (GCC_CET_LDFLAGS): New to support --enable-cet-property. libgcc/ PR target/83910 * Makefile.in (CET_LDFLAGS): New. * configure.ac (CET_LDFLAGS): New AC_SUBST. * configure: Regenerated. * config/i386/t-linux (SHLIB_LDFLAGS): Append $(CET_LDFLAGS). libgcc/ PR target/83910 * configure.ac (CET_LDFLAGS): New AC_SUBST. * configure: Regenerated. * src/Makefile.am (CXXLINK): Add $(CET_LDFLAGS). * src/Makefile.in: Regenerated.
-rw-r--r--config/cet.m421
-rw-r--r--libgcc/Makefile.in1
-rw-r--r--libgcc/config/i386/t-linux1
-rw-r--r--libgcc/configure35
-rw-r--r--libgcc/configure.ac2
-rwxr-xr-xlibstdc++-v3/configure53
-rw-r--r--libstdc++-v3/configure.ac2
-rw-r--r--libstdc++-v3/src/Makefile.am2
-rw-r--r--libstdc++-v3/src/Makefile.in3
9 files changed, 109 insertions, 11 deletions
diff --git a/config/cet.m4 b/config/cet.m4
index 715f4bded19..df4fcc1def2 100644
--- a/config/cet.m4
+++ b/config/cet.m4
@@ -36,3 +36,24 @@ if test x$enable_cet = xyes; then
$1="-fcf-protection -mcet"
fi
])
+
+AC_DEFUN([GCC_CET_LDFLAGS],[dnl
+GCC_ENABLE(cet-property, no, ,[enable Intel CET property in target libraries],
+ permit yes|no|default)
+case "$host" in
+ i[[34567]]86-*-linux* | x86_64-*-linux*)
+ if test x$enable_cet_property = xyes; then
+ # Check if CET is enabled.
+ if test x$enable_cet != xyes; then
+ AC_MSG_ERROR([CET must be enabled for --enable-cet-property])
+ fi
+ fi
+ ;;
+ *)
+ enable_cet_property=no
+ ;;
+esac
+if test x$enable_cet_property = xyes; then
+ $1="-Wl,-z,ibt,-z,shstk"
+fi
+])
diff --git a/libgcc/Makefile.in b/libgcc/Makefile.in
index dd8cee99fd3..feb26d6b76c 100644
--- a/libgcc/Makefile.in
+++ b/libgcc/Makefile.in
@@ -256,6 +256,7 @@ HOST_LIBGCC2_CFLAGS =
PICFLAG = @PICFLAG@
CET_FLAGS = @CET_FLAGS@
+CET_LDFLAGS = @CET_LDFLAGS@
# Defined in libgcc2.c, included only in the static library.
LIB2FUNCS_ST = _eprintf __gcc_bcmp
diff --git a/libgcc/config/i386/t-linux b/libgcc/config/i386/t-linux
index 8506a635790..df370df45ec 100644
--- a/libgcc/config/i386/t-linux
+++ b/libgcc/config/i386/t-linux
@@ -2,6 +2,7 @@
# Need to support TImode for x86. Override the settings from
# t-slibgcc-elf-ver and t-linux
SHLIB_MAPFILES = libgcc-std.ver $(srcdir)/config/i386/libgcc-glibc.ver
+SHLIB_LDFLAGS += $(CET_LDFLAGS)
HOST_LIBGCC2_CFLAGS += -mlong-double-80 -DUSE_ELF_SYMVER $(CET_FLAGS)
CRTSTUFF_T_CFLAGS += $(CET_FLAGS)
diff --git a/libgcc/configure b/libgcc/configure
index 38a28c2a48f..9088ec5a941 100644
--- a/libgcc/configure
+++ b/libgcc/configure
@@ -573,6 +573,7 @@ vis_hide
real_host_noncanonical
accel_dir_suffix
force_explicit_eh_registry
+CET_LDFLAGS
CET_FLAGS
fixed_point
enable_decimal_float
@@ -677,6 +678,7 @@ enable_largefile
enable_decimal_float
with_system_libunwind
enable_cet
+enable_cet_property
enable_explicit_exception_frame_registration
with_glibc_version
enable_tls
@@ -1318,6 +1320,8 @@ Optional Features:
to use
--enable-cet enable Intel CET in target libraries
[default=default]
+ --enable-cet-property enable Intel CET property in target libraries
+ [default=no]
--enable-explicit-exception-frame-registration
register exception tables explicitly at module
start, for use e.g. for compatibility with
@@ -4844,6 +4848,37 @@ if test x$enable_cet = xyes; then
fi
+ # Check whether --enable-cet-property was given.
+if test "${enable_cet_property+set}" = set; then :
+ enableval=$enable_cet_property;
+ case "$enableval" in
+ yes|no|default) ;;
+ *) as_fn_error "Unknown argument to enable/disable cet-property" "$LINENO" 5 ;;
+ esac
+
+else
+ enable_cet_property=no
+fi
+
+
+case "$host" in
+ i[34567]86-*-linux* | x86_64-*-linux*)
+ if test x$enable_cet_property = xyes; then
+ # Check if CET is enabled.
+ if test x$enable_cet != xyes; then
+ as_fn_error "CET must be enabled for --enable-cet-property" "$LINENO" 5
+ fi
+ fi
+ ;;
+ *)
+ enable_cet_property=no
+ ;;
+esac
+if test x$enable_cet_property = xyes; then
+ CET_LDFLAGS="-Wl,-z,ibt,-z,shstk"
+fi
+
+
# Check whether --enable-explicit-exception-frame-registration was given.
if test "${enable_explicit_exception_frame_registration+set}" = set; then :
diff --git a/libgcc/configure.ac b/libgcc/configure.ac
index 6e76a68bc0c..f36b565a446 100644
--- a/libgcc/configure.ac
+++ b/libgcc/configure.ac
@@ -239,6 +239,8 @@ GCC_CHECK_SJLJ_EXCEPTIONS
GCC_CET_FLAGS(CET_FLAGS)
AC_SUBST(CET_FLAGS)
+GCC_CET_LDFLAGS(CET_LDFLAGS)
+AC_SUBST(CET_LDFLAGS)
AC_ARG_ENABLE([explicit-exception-frame-registration],
[AC_HELP_STRING([--enable-explicit-exception-frame-registration],
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index f5798d3a603..5187088e852 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -611,6 +611,7 @@ glibcxx_toolexeclibdir
glibcxx_toolexecdir
gxx_include_dir
glibcxx_prefixdir
+CET_LDFLAGS
EXTRA_CFLAGS
CPU_OPT_BITS_RANDOM
CPU_OPT_EXT_RANDOM
@@ -898,6 +899,7 @@ with_default_libstdcxx_abi
enable_libstdcxx_threads
enable_libstdcxx_filesystem_ts
enable_cet
+enable_cet_property
with_gxx_include_dir
enable_version_specific_runtime_libs
with_gcc_major_version_only
@@ -1598,6 +1600,8 @@ Optional Features:
turns on ISO/IEC TS 18822 support [default=auto]
--enable-cet enable Intel CET in target libraries
[default=default]
+ --enable-cet-property enable Intel CET property in target libraries
+ [default=no]
--enable-version-specific-runtime-libs
Specify that runtime libraries should be installed
in a compiler-specific directory
@@ -11605,7 +11609,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11608 "configure"
+#line 11612 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11711,7 +11715,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11714 "configure"
+#line 11718 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15397,7 +15401,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 15400 "configure"
+#line 15404 "configure"
int main()
{
typedef bool atomic_type;
@@ -15432,7 +15436,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15435 "configure"
+#line 15439 "configure"
int main()
{
typedef short atomic_type;
@@ -15467,7 +15471,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15470 "configure"
+#line 15474 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
@@ -15503,7 +15507,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15506 "configure"
+#line 15510 "configure"
int main()
{
typedef long long atomic_type;
@@ -15584,7 +15588,7 @@ $as_echo "$as_me: WARNING: Performance of certain classes will degrade as a resu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 15587 "configure"
+#line 15591 "configure"
int main()
{
_Decimal32 d1;
@@ -15626,7 +15630,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 15629 "configure"
+#line 15633 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
@@ -15660,7 +15664,7 @@ $as_echo "$enable_int128" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 15663 "configure"
+#line 15667 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
@@ -81155,6 +81159,37 @@ EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS $CET_FLAGS"
EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS"
+ # Check whether --enable-cet-property was given.
+if test "${enable_cet_property+set}" = set; then :
+ enableval=$enable_cet_property;
+ case "$enableval" in
+ yes|no|default) ;;
+ *) as_fn_error "Unknown argument to enable/disable cet-property" "$LINENO" 5 ;;
+ esac
+
+else
+ enable_cet_property=no
+fi
+
+
+case "$host" in
+ i[34567]86-*-linux* | x86_64-*-linux*)
+ if test x$enable_cet_property = xyes; then
+ # Check if CET is enabled.
+ if test x$enable_cet != xyes; then
+ as_fn_error "CET must be enabled for --enable-cet-property" "$LINENO" 5
+ fi
+ fi
+ ;;
+ *)
+ enable_cet_property=no
+ ;;
+esac
+if test x$enable_cet_property = xyes; then
+ CET_LDFLAGS="-Wl,-z,ibt,-z,shstk"
+fi
+
+
# Determine cross-compile flags and AM_CONDITIONALs.
#AC_SUBST(GLIBCXX_IS_NATIVE)
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index c90c5091e2e..22957412372 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -495,6 +495,8 @@ EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS $CET_FLAGS"
EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS"
AC_SUBST(EXTRA_CFLAGS)
AC_SUBST(EXTRA_CXX_FLAGS)
+GCC_CET_LDFLAGS(CET_LDFLAGS)
+AC_SUBST(CET_LDFLAGS)
# Determine cross-compile flags and AM_CONDITIONALs.
#AC_SUBST(GLIBCXX_IS_NATIVE)
diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index ba30dde8fec..45077046a39 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -217,7 +217,7 @@ CXXLINK = \
$(LIBTOOL) --tag CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
- $(VTV_CXXLINKFLAGS) \
+ $(VTV_CXXLINKFLAGS) $(CET_LDFLAGS) \
$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
# Symbol versioning for shared libraries.
diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in
index f0ec7bc8e8e..79751d294e2 100644
--- a/libstdc++-v3/src/Makefile.in
+++ b/libstdc++-v3/src/Makefile.in
@@ -173,6 +173,7 @@ CC = @CC@
CCODECVT_CC = @CCODECVT_CC@
CCOLLATE_CC = @CCOLLATE_CC@
CCTYPE_CC = @CCTYPE_CC@
+CET_LDFLAGS = @CET_LDFLAGS@
CFLAGS = @CFLAGS@
CLOCALE_CC = @CLOCALE_CC@
CLOCALE_H = @CLOCALE_H@
@@ -511,7 +512,7 @@ CXXLINK = \
$(LIBTOOL) --tag CXX \
$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CXX) \
- $(VTV_CXXLINKFLAGS) \
+ $(VTV_CXXLINKFLAGS) $(CET_LDFLAGS) \
$(OPT_LDFLAGS) $(SECTION_LDFLAGS) $(AM_CXXFLAGS) $(LTLDFLAGS) -o $@
@ENABLE_SYMVERS_TRUE@CLEANFILES = libstdc++-symbols.ver $(version_dep)