From patchwork Sun Feb 14 17:26:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1440300 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=n7v1gSd2; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DdvLG0JKZz9sBy for ; Mon, 15 Feb 2021 04:27:00 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 092EB3835400; Sun, 14 Feb 2021 17:26:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 092EB3835400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1613323609; bh=W6+kKHuhikDNAt4/Eigj8OouqJ2BA42qaunpRgxAlEg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=n7v1gSd22+wGehVqtaNC/19QAsrdHIbzi137qu5OKOJAa7ENNClQM9YMp2YgLWtXW mwizOvwulLYTUOD8PddAkrv8u4bEYERAxSs9Ynl+aGYWIxDN1bfQxI/hxJ4R23Jer6 JmPXHsyvvSY7GbzammfQv3/LuM6H0QfoLE1vfFrg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 863C238708E7 for ; Sun, 14 Feb 2021 17:26:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 863C238708E7 Received: by mail-pg1-x52f.google.com with SMTP id t26so2940904pgv.3 for ; Sun, 14 Feb 2021 09:26:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=W6+kKHuhikDNAt4/Eigj8OouqJ2BA42qaunpRgxAlEg=; b=OCwnIuxZi16dlFab03e/JvOa1Y+9mS2w4T0IezSEeNVjr3GjM0RE3V9er+XmR5hrsQ vdf7v0sw07TGnb03Nq0NKmv8ift97316ASkiicIPmx/Wc9GrmoJte2Z91BhkJFsJ5w/r lwKEtoHrVCsDaz5gLtbt6yQ9kHAKleYQ31xGbZF/HQ2iSPNc+WcdixDiu149n7flcMRN NWLtv8FBfkzORNNaawRslaMj9yQoRyiiCJdawO4SwuO5j7CV6lG52FPDc+7wv1ZgPcZs XyMSzDT/Cq4py9dzC7ZMAVUR9f78QMhTTTdcocybbdyrkTx9LM9hk+CGEfQ5ZAxv6JAk SzNw== X-Gm-Message-State: AOAM53051JZHj+h30GjXGjZfq2uS8yErqf9dMl2R1GKoMW59N90k/C4w zl2JJ7NUpHwFa+gQCtY71kTk9z8L5tM= X-Google-Smtp-Source: ABdhPJyKlMOFV4ucC/b0c99/2F9hzsm40DBVK537OE9l54PS1zKMCuzD+HAP4Fu/B8Q5E+6owjFJEA== X-Received: by 2002:a63:fc11:: with SMTP id j17mr11596644pgi.379.1613323604058; Sun, 14 Feb 2021 09:26:44 -0800 (PST) Received: from gnu-cfl-2.localdomain (c-69-181-90-243.hsd1.ca.comcast.net. [69.181.90.243]) by smtp.gmail.com with ESMTPSA id s184sm15990803pfc.106.2021.02.14.09.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Feb 2021 09:26:43 -0800 (PST) Received: from gnu-cfl-2.localdomain (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id E2A7D1A017F; Sun, 14 Feb 2021 09:26:41 -0800 (PST) To: binutils@sourceware.org Subject: [PATCH] GCC_CET_HOST_FLAGS: Check if host supports multi-byte NOPs Date: Sun, 14 Feb 2021 09:26:40 -0800 Message-Id: <20210214172640.4809-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3039.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "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