This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[patch] confusing identifiers with registers in intel syntax mode


When using naked registers, GAS can confuse identifiers like
gs_foo with register `gs' (causing an assembler error) or
`short_foo' with `SHORT foo' (causing a linker error).

This patch fixes both problems and adds a test case to intel.s.
Tested with no regressions on ia32 linux.


gas:

2000-10-15  Diego Novillo  <dnovillo@cygnus.com>

	* tc-i386.c (i386_operand_modifier): Only match modifiers SHORT and
	FLAT if they are followed by a space.
	(parse_register): When `allow_naked_reg' is set, do not confuse
	identifiers that start with a register name with a register.

gas/testsuite:

2000-10-15  Diego Novillo  <dnovillo@cygnus.com>

	* intel.s, intel.d: Add new tests for naked registers using intel
	syntax.


Index: config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.60
diff -d -c -p -r1.60 tc-i386.c
*** tc-i386.c	2000/10/05 01:49:36	1.60
--- tc-i386.c	2000/10/15 05:25:06
*************** i386_operand_modifier (op_string, got_a_
*** 3026,3032 ****
        return XWORD_PTR;
      }
  
!   else if (!strncasecmp (*op_string, "SHORT", 5))
      {
        *op_string += 5;
        return SHORT;
--- 3026,3034 ----
        return XWORD_PTR;
      }
  
!   /* Compare with space separator to avoid confusing identifier `short_var'
!      with attribute `short'.  */
!   else if (!strncasecmp (*op_string, "SHORT ", 6))
      {
        *op_string += 5;
        return SHORT;
*************** i386_operand_modifier (op_string, got_a_
*** 3038,3044 ****
        return OFFSET_FLAT;
      }
  
!   else if (!strncasecmp (*op_string, "FLAT", 4))
      {
        *op_string += 4;
        return FLAT;
--- 3040,3048 ----
        return OFFSET_FLAT;
      }
  
!   /* Compare with space separator to avoid confusing identifier `flat_var'
!      with attribute `flat'.  */
!   else if (!strncasecmp (*op_string, "FLAT ", 5))
      {
        *op_string += 4;
        return FLAT;
*************** parse_register (reg_string, end_op)
*** 4234,4239 ****
--- 4238,4249 ----
  	return (const reg_entry *) NULL;
        s++;
      }
+ 
+   /* For naked regs, make sure that we are not dealing with an identifier.
+      This prevents confusing an identifier like `eax_var' with register
+      `eax'.  */
+   if (allow_naked_reg && identifier_chars[(unsigned char) *s])
+     return (const reg_entry *) NULL;
  
    *end_op = s;
  
Index: testsuite/gas/i386/intel.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/intel.d,v
retrieving revision 1.1
diff -d -c -p -r1.1 intel.d
*** intel.d	2000/02/25 11:41:12	1.1
--- intel.d	2000/10/15 05:25:06
*************** Disassembly of section .text:
*** 572,574 ****
--- 572,584 ----
   9b8:	66 0f bd 90 90 90 90 90 [ 	]*bsr    0x90909090\(%eax\),%dx
   9c0:	66 0f be 90 90 90 90 90 [ 	]*movsbw 0x90909090\(%eax\),%dx
   9c8:	66 0f c1 90 90 90 90 90 [ 	]*xadd   %dx,0x90909090\(%eax\)
+ 
+ 000009d0 <gs_foo>:
+  9d0:	c3 [ 	]*ret    
+ 
+ 000009d1 <short_foo>:
+  9d1:	c3 [ 	]*ret    
+ 
+ 000009d2 <bar>:
+  9d2:	e8 f9 ff ff ff [ 	]*call   9d0 <gs_foo>
+  9d7:	e8 f5 ff ff ff [ 	]*call   9d1 <short_foo>
Index: testsuite/gas/i386/intel.s
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/i386/intel.s,v
retrieving revision 1.2
diff -d -c -p -r1.2 intel.s
*** intel.s	2000/02/25 11:55:50	1.2
--- intel.s	2000/10/15 05:25:06
*************** foo:
*** 566,568 ****
--- 566,578 ----
   bsr    dx, 0x90909090[eax]
   movsx  dx, byte ptr 0x90909090[eax]
   xadd   0x90909090[eax], dx
+ 
+ gs_foo:
+  ret
+ 
+ short_foo:
+  ret
+ 
+ bar:
+  call	gs_foo
+  call	short_foo

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]