public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] x86: restrict prefix use with .insn VEX/XOP/EVEX
@ 2023-09-01 12:30 Jan Beulich
  0 siblings, 0 replies; only message in thread
From: Jan Beulich @ 2023-09-01 12:30 UTC (permalink / raw)
  To: Binutils; +Cc: H.J. Lu

Avoid triggering the respective abort() in output_insn().

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10806,6 +10806,29 @@ s_insn (int dummy ATTRIBUTE_UNUSED)
   if (line > end && i.vec_encoding == vex_encoding_default)
     i.vec_encoding = evex ? vex_encoding_evex : vex_encoding_vex;
 
+  if (i.vec_encoding != vex_encoding_default)
+    {
+      /* Only address size and segment override prefixes are permitted with
+         VEX/XOP/EVEX encodings.  */
+      const unsigned char *p = i.prefix;
+
+      for (j = 0; j < ARRAY_SIZE (i.prefix); ++j, ++p)
+	{
+	  if (!*p)
+	    continue;
+
+	  switch (j)
+	    {
+	    case SEG_PREFIX:
+	    case ADDR_PREFIX:
+	      break;
+	    default:
+		  as_bad (_("illegal prefix used with VEX/XOP/EVEX"));
+		  goto bad;
+	    }
+	}
+    }
+
   if (line > end && *line == '.')
     {
       /* Length specifier (VEX.L, XOP.L, EVEX.L'L).  */

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-01 12:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 12:30 [PATCH] x86: restrict prefix use with .insn VEX/XOP/EVEX Jan Beulich

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).