This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Expression evaluation bug
- To: Mikulas Patocka <mikulas at artax dot karlin dot mff dot cuni dot cz>
- Subject: Re: Expression evaluation bug
- From: Alan Modra <alan at linuxcare dot com dot au>
- Date: Sun, 25 Mar 2001 15:16:13 +1000 (EST)
- cc: binutils at sources dot redhat dot com
On Sat, 24 Mar 2001, Mikulas Patocka wrote:
> movl (, %ecx, (2+2)), %eax
Grumble. I guess it's a bug that we don't at least flag this as a syntax
error. Oh well, not too hard to fix, at least for AT&T mode. Someone
else can tackle an equivalent intel mode change if they feel like it.
gas/ChangeLog
* config/tc-i386.c (i386_scale): Accept an absolute expression for
scale factor, and return the end of the expression.
(i386_operand): Modify for above.
Normally I wouldn't think about installing this sort of fix on the branch,
especially this late in the release cycle. In this case though I'm
willing to risk it as the x86 test suite is fairly exhaustive in it's
testing of valid base/index expressions. Philip, what do you think?
Alan Modra
--
Linuxcare
Index: gas/config/tc-i386.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i386.c,v
retrieving revision 1.91
diff -u -p -r1.91 tc-i386.c
--- tc-i386.c 2001/03/19 11:28:20 1.91
+++ tc-i386.c 2001/03/25 04:21:13
@@ -3344,35 +3344,38 @@ i386_immediate (imm_start)
return 1;
}
-static int i386_scale PARAMS ((char *));
+static char *i386_scale PARAMS ((char *));
-static int
+static char *
i386_scale (scale)
char *scale;
{
- if (!isdigit (*scale))
- goto bad_scale;
+ offsetT val;
+ char *save = input_line_pointer;
+
+ input_line_pointer = scale;
+ val = get_absolute_expression ();
- switch (*scale)
+ switch (val)
{
- case '0':
- case '1':
+ case 0:
+ case 1:
i.log2_scale_factor = 0;
break;
- case '2':
+ case 2:
i.log2_scale_factor = 1;
break;
- case '4':
+ case 4:
i.log2_scale_factor = 2;
break;
- case '8':
+ case 8:
i.log2_scale_factor = 3;
break;
default:
- bad_scale:
as_bad (_("expecting scale factor of 1, 2, 4, or 8: got `%s'"),
scale);
- return 0;
+ input_line_pointer = save;
+ return NULL;
}
if (i.log2_scale_factor != 0 && ! i.index_reg)
{
@@ -3382,7 +3385,9 @@ i386_scale (scale)
i.log2_scale_factor = 0;
#endif
}
- return 1;
+ scale = input_line_pointer;
+ input_line_pointer = save;
+ return scale;
}
static int i386_displacement PARAMS ((char *, char *));
@@ -3830,12 +3835,14 @@ i386_operand (operand_string)
}
/* Check for scale factor. */
- if (isdigit ((unsigned char) *base_string))
+ if (*base_string != ')')
{
- if (!i386_scale (base_string))
+ char *end_scale = i386_scale (base_string);
+
+ if (!end_scale)
return 0;
- ++base_string;
+ base_string = end_scale;
if (is_space_char (*base_string))
++base_string;
if (*base_string != ')')