[2/4] x86: move register check in immediate operand parsing

Message ID 536bc135-32cb-f39c-c3b7-061c85470a7f@suse.com
State New
Headers show
Series
  • x86: assorted relocation handling related adjustments (part IV)
Related show

Commit Message

H.J. Lu via Binutils May 6, 2021, 6:07 a.m.
i386_finalize_immediate() is used for both AT&T and Intel immediate
operand handling. Move an AT&T-only check to i386_immediate(), which at
the same time allows it to cover other cases as well, giving an overall
better / more consistent diagnostic.

gas/
2021-05-XX  Jan Beulich  <jbeulich@suse.com>

	* config/tc-i386.c (i386_finalize_immediate): Move register
	check ...
	(i386_immediate): ... here.

Patch

--- a/gas/config/tc-i386.c
+++ b/gas/config/tc-i386.c
@@ -10688,10 +10688,16 @@  i386_immediate (char *imm_start)
     {
       free (gotfree_input_line);
 
-      if (exp->X_op == O_constant || exp->X_op == O_register)
+      if (exp->X_op == O_constant)
 	exp->X_op = O_illegal;
     }
 
+  if (exp_seg == reg_section)
+    {
+      as_bad (_("illegal immediate register operand %s"), imm_start);
+      return 0;
+    }
+
   return i386_finalize_immediate (exp_seg, exp, types, imm_start);
 }
 
@@ -10729,12 +10735,6 @@  i386_finalize_immediate (segT exp_seg AT
       return 0;
     }
 #endif
-  else if (!intel_syntax && exp_seg == reg_section)
-    {
-      if (imm_start)
-	as_bad (_("illegal immediate register operand %s"), imm_start);
-      return 0;
-    }
   else
     {
       /* This is an address.  The size of the address will be