This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[gas] fix expression crash
- From: Nathan Sidwell <nathan at codesourcery dot com>
- To: binutils <binutils at sources dot redhat dot com>
- Date: Tue, 04 May 2010 15:40:50 +0100
- Subject: [gas] fix expression crash
This patch fixes a confusing error message and a crash. If the user gives a
string argument where a numeric one is expected, things go badly wrong (for
instance confusing .byte and .ascii).
.byte " "
[One space] gives:
foo.S:1: Error: bad expression
foo.S:1: Error: junk at end of line, first unrecognized character is `"'
.byte " "
[Two spaces] gives:
foo.S:1: Error: bad expression
foo.S:1: Internal error!
this fixes things to give:
'unexpected `"' in expression'
tested on arm-eabi, ok?
nathan
--
Nathan Sidwell :: http://www.codesourcery.com :: CodeSourcery
2010-05-04 Julian Brown <julian@codesourcery.com>
* read.c (cons_worker): Detect and reject unexpected string argument.
2010-05-04 Nathan Sidwell <nathan@codesourcery.com>
testsuite/
* gas/all/byte.s: New.
* gas/all/byte.l: New.
* gas/all/byte.d: New.
* gas/all/gas.exp: Add it.
Index: read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.164
diff -c -3 -p -r1.164 read.c
*** read.c 21 Apr 2010 18:17:45 -0000 1.164
--- read.c 4 May 2010 14:35:07 -0000
*************** cons_worker (int nbytes, /* 1=.byte, 2=.
*** 3865,3871 ****
parse_mri_cons (&exp, (unsigned int) nbytes);
else
#endif
! TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
if (rva)
{
--- 3865,3879 ----
parse_mri_cons (&exp, (unsigned int) nbytes);
else
#endif
! {
! if (*input_line_pointer == '"')
! {
! as_bad (_("unexpected `\"' in expression"));
! ignore_rest_of_line ();
! return;
! }
! TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
! }
if (rva)
{
Index: testsuite/gas/all/byte.d
===================================================================
RCS file: testsuite/gas/all/byte.d
diff -N testsuite/gas/all/byte.d
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/all/byte.d 4 May 2010 14:35:07 -0000
***************
*** 0 ****
--- 1,2 ----
+ #name: bad byte directive
+ #error-output: byte.l
Index: testsuite/gas/all/byte.l
===================================================================
RCS file: testsuite/gas/all/byte.l
diff -N testsuite/gas/all/byte.l
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/all/byte.l 4 May 2010 14:35:07 -0000
***************
*** 0 ****
--- 1,3 ----
+ [^:]*: Assembler messages:
+ [^:]*:1: Error: unexpected `"' in expression
+ [^:]*:2: Error: unexpected `"' in expression
Index: testsuite/gas/all/byte.s
===================================================================
RCS file: testsuite/gas/all/byte.s
diff -N testsuite/gas/all/byte.s
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/gas/all/byte.s 4 May 2010 14:35:07 -0000
***************
*** 0 ****
--- 1,2 ----
+ .byte " "
+ .byte " "
Index: testsuite/gas/all/gas.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/all/gas.exp,v
retrieving revision 1.59
diff -c -3 -p -r1.59 gas.exp
*** testsuite/gas/all/gas.exp 29 Sep 2009 14:17:09 -0000 1.59
--- testsuite/gas/all/gas.exp 4 May 2010 14:35:07 -0000
*************** if { ![istarget "tic4x*-*-*"] && ![istar
*** 329,334 ****
--- 329,336 ----
run_dump_test relax
}
+ run_dump_test byte
+
# .quad is 16 bytes on i960.
if { ![istarget "i960-*-*"] } {
run_dump_test quad