This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: gas/4460: x86 assembler is broken
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: binutils at sources dot redhat dot com
- Date: Fri, 4 May 2007 09:32:54 +0930
- Subject: Re: PATCH: gas/4460: x86 assembler is broken
- References: <20070503233031.GA9679@lucon.org>
On Thu, May 03, 2007 at 04:30:31PM -0700, H. J. Lu wrote:
> The problem is an operand may have 2 trailing white spaces while
> operand () in expr.c only expects one. Add --enable-checking to gas
> triggers this problem. We can change the generic part of assembler
> or change x86 assembler to remove the extra trailing white space.
> Here is a patch to change x86 assembler. I will check it in if the
> problem isn't fixed in 24 hours.
>
>
>
> H.J.
> ---
> gas/
>
> 2007-05-03 H.J. Lu <hongjiu.lu@intel.com>
>
> PR gas/4460
> * config/tc-i386.c (i386_displacement): Remove trailing white
> space.
Better to catch the problem where the extra space is added, I think.
* config/tc-i386.c (lex_got): Don't replace the reloc token with
a space if we already have a space.
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.264
diff -u -p -r1.264 tc-i386.c
--- gas/config/tc-i386.c 3 May 2007 21:07:15 -0000 1.264
+++ gas/config/tc-i386.c 3 May 2007 23:49:44 -0000
@@ -4477,9 +4477,6 @@ lex_got (enum bfd_reloc_code_real *reloc
if (GOT_symbol == NULL)
GOT_symbol = symbol_find_or_make (GLOBAL_OFFSET_TABLE_NAME);
- /* Replace the relocation token with ' ', so that
- errors like foo@GOTOFF1 will be detected. */
-
/* The length of the first part of our input line. */
first = cp - input_line_pointer;
@@ -4495,9 +4492,12 @@ lex_got (enum bfd_reloc_code_real *reloc
be necessary, but be safe. */
tmpbuf = xmalloc (first + second + 2);
memcpy (tmpbuf, input_line_pointer, first);
- tmpbuf[first] = ' ';
- memcpy (tmpbuf + first + 1, past_reloc, second);
- tmpbuf[first + second + 1] = '\0';
+ if (second != 0 && *past_reloc != ' ')
+ /* Replace the relocation token with ' ', so that
+ errors like foo@GOTOFF1 will be detected. */
+ tmpbuf[first++] = ' ';
+ memcpy (tmpbuf + first, past_reloc, second);
+ tmpbuf[first + second] = '\0';
return tmpbuf;
}
> gas/testsuite/
>
> 2007-05-03 H.J. Lu <hongjiu.lu@intel.com>
>
> PR gas/4460
> * gas/i386/gotpc.s: Add a new test.
> * gas/i386/reloc64.s: Likewise.
>
> * gas/i386/gotpc.d: Updated.
> * gas/i386/reloc64.d: Likewise.
Please commit.
--
Alan Modra
IBM OzLabs - Linux Technology Centre