public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
@ 2021-02-14 17:26 H.J. Lu
  2021-03-15 13:24 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2021-02-14 17:26 UTC (permalink / raw)
  To: binutils; +Cc: gcc-patches

Check if host supports multi-byte NOPs before enabling CET on host.

config/

	PR binutils/27397
	* cet.m4 (GCC_CET_HOST_FLAGS): Check if host supports multi-byte
	NOPs.

libiberty/

	PR binutils/27397
	* configure: Regenerated.
---
 config/cet.m4       | 19 ++++++++++++++++---
 libiberty/configure | 29 +++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/config/cet.m4 b/config/cet.m4
index c67fb4f35b6..7718be1afe8 100644
--- a/config/cet.m4
+++ b/config/cet.m4
@@ -130,6 +130,18 @@ fi
 if test x$may_have_cet = xyes; then
   if test x$cross_compiling = xno; then
     AC_TRY_RUN([
+int
+main ()
+{
+  asm ("endbr32");
+  return 0;
+}
+    ],
+    [have_multi_byte_nop=yes],
+    [have_multi_byte_nop=no])
+    have_cet=no
+    if test x$have_multi_byte_nop = xyes; then
+      AC_TRY_RUN([
 static void
 foo (void)
 {
@@ -155,9 +167,10 @@ main ()
   bar ();
   return 0;
 }
-    ],
-    [have_cet=no],
-    [have_cet=yes])
+      ],
+      [have_cet=no],
+      [have_cet=yes])
+    fi
     if test x$enable_cet = xno -a x$have_cet = xyes; then
       AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
     fi
diff --git a/libiberty/configure b/libiberty/configure
index 160b8c9e8b1..29a690d44fc 100755
--- a/libiberty/configure
+++ b/libiberty/configure
@@ -5539,6 +5539,34 @@ else
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
+int
+main ()
+{
+  asm ("endbr32");
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  have_multi_byte_nop=yes
+else
+  have_multi_byte_nop=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+    have_cet=no
+    if test x$have_multi_byte_nop = xyes; then
+      if test "$cross_compiling" = yes; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run test program while cross compiling
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
 static void
 foo (void)
 {
@@ -5575,6 +5603,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   conftest.$ac_objext conftest.beam conftest.$ac_ext
 fi
 
+    fi
     if test x$enable_cet = xno -a x$have_cet = xyes; then
       as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
     fi
-- 
2.29.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs
  2021-02-14 17:26 [PATCH] GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs H.J. Lu
@ 2021-03-15 13:24 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2021-03-15 13:24 UTC (permalink / raw)
  To: Binutils; +Cc: GCC Patches

On Sun, Feb 14, 2021 at 9:26 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> Check if host supports multi-byte NOPs before enabling CET on host.
>
> config/
>
>         PR binutils/27397
>         * cet.m4 (GCC_CET_HOST_FLAGS): Check if host supports multi-byte
>         NOPs.
>
> libiberty/
>
>         PR binutils/27397
>         * configure: Regenerated.
> ---
>  config/cet.m4       | 19 ++++++++++++++++---
>  libiberty/configure | 29 +++++++++++++++++++++++++++++
>  2 files changed, 45 insertions(+), 3 deletions(-)
>
> diff --git a/config/cet.m4 b/config/cet.m4
> index c67fb4f35b6..7718be1afe8 100644
> --- a/config/cet.m4
> +++ b/config/cet.m4
> @@ -130,6 +130,18 @@ fi
>  if test x$may_have_cet = xyes; then
>    if test x$cross_compiling = xno; then
>      AC_TRY_RUN([
> +int
> +main ()
> +{
> +  asm ("endbr32");
> +  return 0;
> +}
> +    ],
> +    [have_multi_byte_nop=yes],
> +    [have_multi_byte_nop=no])
> +    have_cet=no
> +    if test x$have_multi_byte_nop = xyes; then
> +      AC_TRY_RUN([
>  static void
>  foo (void)
>  {
> @@ -155,9 +167,10 @@ main ()
>    bar ();
>    return 0;
>  }
> -    ],
> -    [have_cet=no],
> -    [have_cet=yes])
> +      ],
> +      [have_cet=no],
> +      [have_cet=yes])
> +    fi
>      if test x$enable_cet = xno -a x$have_cet = xyes; then
>        AC_MSG_ERROR([Intel CET must be enabled on Intel CET enabled host])
>      fi
> diff --git a/libiberty/configure b/libiberty/configure
> index 160b8c9e8b1..29a690d44fc 100755
> --- a/libiberty/configure
> +++ b/libiberty/configure
> @@ -5539,6 +5539,34 @@ else
>    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
>  /* end confdefs.h.  */
>
> +int
> +main ()
> +{
> +  asm ("endbr32");
> +  return 0;
> +}
> +
> +_ACEOF
> +if ac_fn_c_try_run "$LINENO"; then :
> +  have_multi_byte_nop=yes
> +else
> +  have_multi_byte_nop=no
> +fi
> +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
> +  conftest.$ac_objext conftest.beam conftest.$ac_ext
> +fi
> +
> +    have_cet=no
> +    if test x$have_multi_byte_nop = xyes; then
> +      if test "$cross_compiling" = yes; then :
> +  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
> +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
> +as_fn_error $? "cannot run test program while cross compiling
> +See \`config.log' for more details" "$LINENO" 5; }
> +else
> +  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
>  static void
>  foo (void)
>  {
> @@ -5575,6 +5603,7 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
>    conftest.$ac_objext conftest.beam conftest.$ac_ext
>  fi
>
> +    fi
>      if test x$enable_cet = xno -a x$have_cet = xyes; then
>        as_fn_error $? "Intel CET must be enabled on Intel CET enabled host" "$LINENO" 5
>      fi
> --
> 2.29.2
>

If there are no objections,  I will check it in on Wednesday.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-15 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-14 17:26 [PATCH] GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs H.J. Lu
2021-03-15 13:24 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).