Implement CET

This commit is contained in:
Petr Písař 2021-01-11 13:20:41 +01:00
parent 25c98b9ed0
commit f54ff1daa3
3 changed files with 2773 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,98 @@
From 70fcff23652339438cabef86f2d3d9c645678687 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 20 Dec 2020 13:55:40 -0800
Subject: [PATCH 2/2] Pass -mshstk to the compiler when Intel CET is enable
Copied from PCRE2.
---
CMakeLists.txt | 18 ++++++++++++++++++
Makefile.am | 3 +++
configure.ac | 15 +++++++++++++++
3 files changed, 36 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 858a34b..74c27e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -112,6 +112,24 @@ CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
CHECK_TYPE_SIZE("long long" LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
+# Check whether Intel CET is enabled, and if so, adjust compiler flags. This
+# code was written by PH, trying to imitate the logic from the autotools
+# configuration.
+
+CHECK_C_SOURCE_COMPILES(
+ "#ifndef __CET__
+ #error CET is not enabled
+ #endif
+ int main() { return 0; }"
+ INTEL_CET_ENABLED
+)
+
+IF (INTEL_CET_ENABLED)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mshstk")
+ENDIF(INTEL_CET_ENABLED)
+
+
+
# User-configurable options
#
# (Note: CMakeSetup displays these in alphabetical order, regardless of
diff --git a/Makefile.am b/Makefile.am
index 22b6947..984c686 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -250,6 +250,7 @@ libpcre_la_SOURCES = \
libpcre_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
+ $(CET_CFLAGS) \
$(AM_CFLAGS)
libpcre_la_LIBADD =
@@ -289,6 +290,7 @@ libpcre16_la_SOURCES = \
libpcre16_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
+ $(CET_CFLAGS) \
$(AM_CFLAGS)
libpcre16_la_LIBADD =
@@ -328,6 +330,7 @@ libpcre32_la_SOURCES = \
libpcre32_la_CFLAGS = \
$(VISIBILITY_CFLAGS) \
+ $(CET_CFLAGS) \
$(AM_CFLAGS)
libpcre32_la_LIBADD =
diff --git a/configure.ac b/configure.ac
index 6a3e5f3..15f37d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1043,6 +1043,21 @@ fi # enable_coverage
AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
+AC_MSG_CHECKING([whether Intel CET is enabled])
+AC_LANG_PUSH([C])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,
+ [[#ifndef __CET__
+# error CET is not enabled
+#endif]])],
+ [intel_cet_enabled=yes],
+ [intel_cet_enabled=no])
+AC_MSG_RESULT([$intel_cet_enabled])
+if test "$intel_cet_enabled" = yes; then
+ CET_CFLAGS="-mshstk"
+ AC_SUBST([CET_CFLAGS])
+fi
+AC_LANG_POP([C])
+
# Produce these files, in addition to config.h.
AC_CONFIG_FILES(
Makefile
--
2.29.2

View File

@ -2,7 +2,7 @@
#%%global rcversion RC1
Name: pcre
Version: 8.44
Release: %{?rcversion:0.}2%{?rcversion:.%rcversion}%{?dist}
Release: %{?rcversion:0.}3%{?rcversion:.%rcversion}%{?dist}
%global myversion %{version}%{?rcversion:-%rcversion}
Summary: Perl-compatible regular expression library
## Source package only:
@ -45,6 +45,10 @@ Patch3: pcre-8.42-Declare-POSIX-regex-function-names-as-macros-to-PCRE.patch
# Fix reading an uninitialized memory when populating a name table,
# upstream bug #2661, proposed to the upstream
Patch4: pcre-8.44-Inicialize-name-table-memory-region.patch
# Implement CET, bug #1909554, proposed to the upstream
# <https://lists.exim.org/lurker/message/20201220.222016.d8cd6d61.en.html>
Patch5: pcre-8.44-JIT-compiler-update-for-Intel-CET.patch
Patch6: pcre-8.44-Pass-mshstk-to-the-compiler-when-Intel-CET-is-enable.patch
BuildRequires: readline-devel
BuildRequires: autoconf
BuildRequires: automake
@ -133,6 +137,8 @@ Utilities demonstrating PCRE capabilities like pcregrep or pcretest.
%patch2 -p2
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
# Because of the multilib patch
libtoolize --copy --force
autoreconf -vif
@ -225,6 +231,9 @@ make %{?_smp_mflags} check VERBOSE=yes
%{_mandir}/man1/pcretest.*
%changelog
* Mon Jan 11 2021 Petr Pisar <ppisar@redhat.com> - 8.44-3
- Implement CET (bug #1909554)
* Mon Oct 19 2020 Petr Pisar <ppisar@redhat.com> - 8.44-2
- Fix reading an uninitialized memory when populating a name table
(upstream bug #2661)