This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: [Bug gas/m68k] parse error with m68k-aout targets


On Thu, Nov 24, 2005 at 12:18:22PM +0100, Gunther Nikl wrote:
> Hello!
> 
> There seems to be a bug for m68k-aout targets with any binutils version
> >= 2.10. The following testcase (extracted from bfd/libbfd.s output)
> triggers an error message:
> 
> -- cut --
> #NO_APP
> .lcomm mask.0,4
> _foo:
> 	orl (mask.0),d0
> 	orl d2,(mask.0)
> 	rts
> -- cut --
> 
> Assembling with:
> 
>   ./gas/as-new bug.s -o bug.o
> 
> yields:
> 
>   gas214-bug.s: Assembler messages:
>   gas214-bug.s:4: Error: parse error -- statement `orl (mask.0),d0' ignored
>   gas214-bug.s:5: Error: parse error -- statement `orl d2,(mask.0)' ignored
> 
> The testcase works fine with gas 2.9.1 and for m68k-elf. Note that for ELF
> a register prefix has to be added.

The trouble is that gas is seeing "(mask" and interpreting this as the
start of "(<reg>)".  "mask" was added as a reg on 1999-05-28, so this
has been around for a long time.

The following patch would fix this particular problem, but I'm not
applying it because it will break valid instructions like
"tstl (%d0.w*2)".  My 68k assembler is so rusty that I can't really help
more than just pointing someone else at the right area.  Sorry.
I suspect that the right fix would be to move quite a bit of code from
m68k-parse.y yylex to new parser rules to properly parse registers.

Index: gas/config/m68k-parse.y
===================================================================
RCS file: /cvs/src/src/gas/config/m68k-parse.y,v
retrieving revision 1.9
diff -u -p -r1.9 m68k-parse.y
--- gas/config/m68k-parse.y	23 Jun 2005 11:40:29 -0000	1.9
+++ gas/config/m68k-parse.y	28 Nov 2005 12:18:34 -0000
@@ -801,9 +801,13 @@ yylex ()
       if (str[1] == '\0' || (str[1] == '&' && str[2] == '\0'))
 	return *str++;
       s = str + 1;
+      c = '\0';
       if (*s == '(')
-	++s;
-      if (m68k_reg_parse (&s) != 0)
+	{
+	  ++s;
+	  c = ')';
+	}
+      if (m68k_reg_parse (&s) != 0 && *s == c)
 	return *str++;
       break;
     case '(':
@@ -816,7 +820,7 @@ yylex ()
 		  || str[-1] == ')')))
 	return *str++;
       s = str + 1;
-      if (m68k_reg_parse (&s) != 0)
+      if (m68k_reg_parse (&s) != 0 && *s == ')')
 	return *str++;
       /* Check for the case of '(expr,...' by scanning ahead.  If we
          find a comma outside of balanced parentheses, we return '('.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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