]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: honor quoted figure braces in i386_att_operand()
authorJan Beulich <jbeulich@suse.com>
Mon, 7 Jun 2021 10:05:35 +0000 (12:05 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 7 Jun 2021 10:05:35 +0000 (12:05 +0200)
When AVX512 support was added, symbol quotation was not paid attention
to. Just like the (base,index,scale) specifier gets parsed from the end
of the expression, the {...} also wants parsing from the end; in no case
is the first { found a guarantee of a masking or broadcasting specifier.

gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/gas/i386/quoted.d
gas/testsuite/gas/i386/quoted.s

index f490eeff4b209d7150e56d7ab75089728e797a04..e4cf2afc21c3656ed048269e215305e6eff4ce75 100644 (file)
@@ -1,3 +1,10 @@
+2021-06-07  Jan Beulich  <jbeulich@suse.com>
+
+       * config/tc-i386.c (i386_att_operand): Re-write handling of
+       vector operations operand suffix.
+       * testsuite/gas/i386/unary.s: Add more cases.
+       * testsuite/gas/i386/unary.d: Adjust expectations.
+
 2021-06-07  Jan Beulich  <jbeulich@suse.com>
 
        * config/tc-i386.c (parse_operands): Reduce scope of
index c838823e088ebabd8b89d5ca5ce7fb05eef1ff71..a87496857f69da0df866c459c1211ae1eca6b857 100644 (file)
@@ -11488,7 +11488,6 @@ i386_att_operand (char *operand_string)
       /* Start and end of displacement string expression (if found).  */
       char *displacement_string_start;
       char *displacement_string_end;
-      char *vop_start;
 
     do_memory_reference:
       if (i.mem_operands == 1 && !maybe_adjust_templates ())
@@ -11509,18 +11508,43 @@ i386_att_operand (char *operand_string)
       base_string = op_string + strlen (op_string);
 
       /* Handle vector operations.  */
-      vop_start = strchr (op_string, '{');
-      if (vop_start && vop_start < base_string)
+      --base_string;
+      if (is_space_char (*base_string))
+       --base_string;
+
+      if (*base_string == '}')
        {
+         char *vop_start = NULL;
+
+         while (base_string-- > op_string)
+           {
+             if (*base_string == '"')
+               break;
+             if (*base_string != '{')
+               continue;
+
+             vop_start = base_string;
+
+             --base_string;
+             if (is_space_char (*base_string))
+               --base_string;
+
+             if (*base_string != '}')
+               break;
+
+             vop_start = NULL;
+           }
+
+         if (!vop_start)
+           {
+             as_bad (_("unbalanced figure braces"));
+             return 0;
+           }
+
          if (check_VecOperations (vop_start) == NULL)
            return 0;
-         base_string = vop_start;
        }
 
-      --base_string;
-      if (is_space_char (*base_string))
-       --base_string;
-
       /* If we only have a displacement, set-up for it to be parsed later.  */
       displacement_string_start = op_string;
       displacement_string_end = base_string + 1;
index 11b28c03fc3828fb56002e3bc6e6a8f2dc9e51d8..c73576a3f52245d4217debfc00406057b1588eed 100644 (file)
@@ -13,6 +13,8 @@ Disassembly of section .text:
 [      ]*[a-f0-9]+:[   ]*a1 00 00 00 00[        ]+mov    0x0,%eax      [a-f0-9]+: (R_386_|dir)32       x\(y
 [      ]*[a-f0-9]+:[   ]*a1 00 00 00 00[        ]+mov    0x0,%eax      [a-f0-9]+: (R_386_|dir)32       x\)y
 [      ]*[a-f0-9]+:[   ]*a1 00 00 00 00[        ]+mov    0x0,%eax      [a-f0-9]+: (R_386_|dir)32       x\?y
+[      ]*[a-f0-9]+:[   ]*a1 00 00 00 00[        ]+mov    0x0,%eax      [a-f0-9]+: (R_386_|dir)32       x\{y
+[      ]*[a-f0-9]+:[   ]*a1 00 00 00 00[        ]+mov    0x0,%eax      [a-f0-9]+: (R_386_|dir)32       x\{z\}
 [      ]*[a-f0-9]+:[   ]*ff 15 00 00 00 00[     ]+call   \*0x0 [a-f0-9]+: (R_386_|dir)32       x\(y\)
 [      ]*[a-f0-9]+:[   ]*26 ff 15 00 00 00 00[  ]+call   \*%es:0x0     [a-f0-9]+: (R_386_|dir)32       x\(y\)
 [      ]*[a-f0-9]+:[   ]*26 ff 15 00 00 00 00[  ]+call   \*%es:0x0     [a-f0-9]+: (R_386_|dir)32       x\(y\)
index 1e57c86007f232a0bd0ade22025ceb029cb45fbd..21ada4696103553ef2e210f8292980ab0f7c7b46 100644 (file)
@@ -8,6 +8,8 @@ quoted:
        mov     "x(y", %eax
        mov     "x)y", %eax
        mov     "x?y", %eax
+       mov     "x{y", %eax
+       mov     "x{z}", %eax
 
        call    *"x(y)"
        call    *%es:"x(y)"