public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: jbeulich@suse.com
Subject: [PATCH v2] x86: Warn .insn instruction with length > 15 bytes
Date: Tue,  6 Feb 2024 03:33:58 -0800	[thread overview]
Message-ID: <20240206113358.999065-1-hjl.tools@gmail.com> (raw)

Change .insn instruction with length > 15 bytes from error to warning.

	PR gas/31323
	* config/tc-i386.c (output_insn): Issue a warning when .insn
	instruction length exceeds the limit of 15 bytes.
	* testsuite/gas/i386/oversized64.s: Add a test for .insn
	* testsuite/gas/i386/oversized64.l: Updated.
---
 gas/config/tc-i386.c                 | 10 ++++++++--
 gas/testsuite/gas/i386/oversized64.l |  8 ++++++++
 gas/testsuite/gas/i386/oversized64.s |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c
index 8f3a1b6f686..047aaba567e 100644
--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -11780,8 +11780,14 @@ output_insn (const struct last_insn *last_insn)
 	{
 	  j = encoding_length (insn_start_frag, insn_start_off, frag_more (0));
 	  if (j > 15)
-	    as_bad (_("instruction length of %u bytes exceeds the limit of 15"),
-		    j);
+	    {
+	      if (dot_insn ())
+		as_warn (_("instruction length of %u bytes exceeds the limit of 15"),
+			j);
+	      else
+		as_bad (_("instruction length of %u bytes exceeds the limit of 15"),
+			j);
+	    }
 	  else if (fragP)
 	    {
 	      /* NB: Don't add prefix with GOTPC relocation since
diff --git a/gas/testsuite/gas/i386/oversized64.l b/gas/testsuite/gas/i386/oversized64.l
index ac32c4d8139..f709456c5e5 100644
--- a/gas/testsuite/gas/i386/oversized64.l
+++ b/gas/testsuite/gas/i386/oversized64.l
@@ -4,6 +4,7 @@
 .*:7: Error: instruction length.*
 .*:9: Error: instruction length.*
 .*:10: Error: instruction length.*
+.*:13: Warning: instruction length.*
 GAS LISTING .*
 
 
@@ -37,4 +38,11 @@ GAS LISTING .*
 [ 	]*10[ 	]+48812CC5[ 	]*
 [ 	]*10[ 	]+00000000[ 	]*
 [ 	]*10[ 	]+44332211[ 	]*
+[ 	]*11[ 	]+
+[ 	]*12[ 	]+\.att_syntax prefix
+[ 	]*13[ 	]+\?\?\?\? 6762F1FC[ 	]+.insn EVEX.L0.0f 12/0, \$0x11223344,\(,%eax,8\),%rax
+\*\*\*\*  Warning: instruction length of 16 bytes exceeds the limit of 15
+[ 	]*13[ 	]+080C04C5[ 	]*
+[ 	]*13[ 	]+00000000[ 	]*
+[ 	]*13[ 	]+44332211[ 	]*
 #pass
diff --git a/gas/testsuite/gas/i386/oversized64.s b/gas/testsuite/gas/i386/oversized64.s
index 9db09af3f15..77a08a9c533 100644
--- a/gas/testsuite/gas/i386/oversized64.s
+++ b/gas/testsuite/gas/i386/oversized64.s
@@ -8,3 +8,6 @@ long64:
 
 	xacquire lock add qword ptr gs:[eax*8], 0x11223344
 	xrelease lock sub qword ptr gs:[eax*8], 0x11223344
+
+	.att_syntax prefix
+	.insn EVEX.L0.0f 12/0, $0x11223344,(,%eax,8),%rax
-- 
2.43.0


                 reply	other threads:[~2024-02-06 11:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240206113358.999065-1-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).