From: Paul Brook <paul@codesourcery.com>
To: binutils@sourceware.org
Subject: [patch] Missing error messages for Arm parse errors
Date: Thu, 16 Mar 2006 00:49:00 -0000 [thread overview]
Message-ID: <200603160049.06997.paul@codesourcery.com> (raw)
I recently noticed that one of the arm operand parsing routines returned FAIL
without setting inst.error. This results in gas silently accepting the
malformed instruction.
Obviously it's preferable to have specific error messages, but it's an easy
mistake to make, and silently generating wrong code is really bad. The patch
below adds a catch-all "syntax error" to catch these cases.
Tested with cross to arm-none-eabi.
Ok?
2006-03-16 Paul Brook <paul@codesourcery.com>
* config/tc-arm.c (parse_operands): Set default error message.
Index: gas/config/tc-arm.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/gas/config/tc-arm.c,v
retrieving revision 1.246
diff -u -p -r1.246 tc-arm.c
--- gas/config/tc-arm.c 10 Mar 2006 17:20:30 -0000 1.246
+++ gas/config/tc-arm.c 16 Mar 2006 00:09:32 -0000
@@ -4130,7 +4139,13 @@ parse_operands (char *str, const unsigne
failure:
if (!backtrack_pos)
- return FAIL;
+ {
+ /* The parse routine should already have set inst.error, but set a
+ defaut here just in case. */
+ if (!inst.error)
+ inst.error = _("syntax error");
+ return FAIL;
+ }
/* Do not backtrack over a trailing optional argument that
absorbed some text. We will only fail again, with the
@@ -4138,7 +4153,11 @@ parse_operands (char *str, const unsigne
probably less helpful than the current one. */
if (backtrack_index == i && backtrack_pos != str
&& upat[i+1] == OP_stop)
- return FAIL;
+ {
+ if (!inst.error)
+ inst.error = _("syntax error");
+ return FAIL;
+ }
/* Try again, skipping the optional argument at backtrack_pos. */
str = backtrack_pos;
next reply other threads:[~2006-03-16 0:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-16 0:49 Paul Brook [this message]
2006-04-07 15:18 ` Nick Clifton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200603160049.06997.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).