PR28977 tc-i386.c internal error in parse_register
authorAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2022 06:03:51 +0000 (16:33 +1030)
committerAlan Modra <amodra@gmail.com>
Fri, 18 Mar 2022 06:54:13 +0000 (17:24 +1030)
PR 28977
* config/tc-i386.c (parse_register): Handle X_op not O_register
as for a non-reg_section symbol.  Simplify array bounds check.

gas/config/tc-i386.c

index 1cc14feeccf45c8434f67ce89bfa5c79b4e3b7a9..8ef71b62e426f94477047d8cb6e3a608aa00ef76 100644 (file)
@@ -12952,17 +12952,18 @@ parse_register (char *reg_string, char **end_op)
        {
          const expressionS *e = symbol_get_value_expression (symbolP);
 
-         know (e->X_op == O_register);
-         know (e->X_add_number >= 0
-               && (valueT) e->X_add_number < i386_regtab_size);
-         r = i386_regtab + e->X_add_number;
-         if (!check_register (r))
+         if (e->X_op == O_register
+             && (valueT) e->X_add_number < i386_regtab_size)
            {
-             as_bad (_("register '%s%s' cannot be used here"),
-                     register_prefix, r->reg_name);
-             r = &bad_reg;
+             r = i386_regtab + e->X_add_number;
+             if (!check_register (r))
+               {
+                 as_bad (_("register '%s%s' cannot be used here"),
+                         register_prefix, r->reg_name);
+                 r = &bad_reg;
+               }
+             *end_op = input_line_pointer;
            }
-         *end_op = input_line_pointer;
        }
       *input_line_pointer = c;
       input_line_pointer = save;