mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-26 05:47:26 +08:00
aarch64: move bogus assertion
Asserting "idx" to be non-negative when subsequent code handles this case is bogus. In fact the assertion triggers e.g. when mistakenly using the arm32 comment character @ following an instruction. While doing this I also noticed that despite there being local variables "detail" and "idx", not all places where they could be used did actually make use of them, so this is being adjusted at once. Finally, for the code to be slightly more robust, also change comparisons against -1 to such checking for a (non-)negative value.
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
2014-10-21 Jan Beulich <jbeulich@suse.com>
|
||||||
|
|
||||||
|
* config/tc-aarch64.c (output_operand_error_record): Move down
|
||||||
|
assertion of idx being non-negative. Use local variables when
|
||||||
|
available.
|
||||||
|
|
||||||
2014-10-18 Alan Modra <amodra@gmail.com>
|
2014-10-18 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR 17493
|
PR 17493
|
||||||
|
@ -3939,11 +3939,11 @@ output_info (const char *format, ...)
|
|||||||
static void
|
static void
|
||||||
output_operand_error_record (const operand_error_record *record, char *str)
|
output_operand_error_record (const operand_error_record *record, char *str)
|
||||||
{
|
{
|
||||||
int idx = record->detail.index;
|
|
||||||
const aarch64_opcode *opcode = record->opcode;
|
|
||||||
enum aarch64_opnd opd_code = (idx != -1 ? opcode->operands[idx]
|
|
||||||
: AARCH64_OPND_NIL);
|
|
||||||
const aarch64_operand_error *detail = &record->detail;
|
const aarch64_operand_error *detail = &record->detail;
|
||||||
|
int idx = detail->index;
|
||||||
|
const aarch64_opcode *opcode = record->opcode;
|
||||||
|
enum aarch64_opnd opd_code = (idx >= 0 ? opcode->operands[idx]
|
||||||
|
: AARCH64_OPND_NIL);
|
||||||
|
|
||||||
switch (detail->kind)
|
switch (detail->kind)
|
||||||
{
|
{
|
||||||
@ -3955,20 +3955,22 @@ output_operand_error_record (const operand_error_record *record, char *str)
|
|||||||
case AARCH64_OPDE_RECOVERABLE:
|
case AARCH64_OPDE_RECOVERABLE:
|
||||||
case AARCH64_OPDE_FATAL_SYNTAX_ERROR:
|
case AARCH64_OPDE_FATAL_SYNTAX_ERROR:
|
||||||
case AARCH64_OPDE_OTHER_ERROR:
|
case AARCH64_OPDE_OTHER_ERROR:
|
||||||
gas_assert (idx >= 0);
|
|
||||||
/* Use the prepared error message if there is, otherwise use the
|
/* Use the prepared error message if there is, otherwise use the
|
||||||
operand description string to describe the error. */
|
operand description string to describe the error. */
|
||||||
if (detail->error != NULL)
|
if (detail->error != NULL)
|
||||||
{
|
{
|
||||||
if (detail->index == -1)
|
if (idx < 0)
|
||||||
as_bad (_("%s -- `%s'"), detail->error, str);
|
as_bad (_("%s -- `%s'"), detail->error, str);
|
||||||
else
|
else
|
||||||
as_bad (_("%s at operand %d -- `%s'"),
|
as_bad (_("%s at operand %d -- `%s'"),
|
||||||
detail->error, detail->index + 1, str);
|
detail->error, idx + 1, str);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
as_bad (_("operand %d should be %s -- `%s'"), idx + 1,
|
{
|
||||||
|
gas_assert (idx >= 0);
|
||||||
|
as_bad (_("operand %d should be %s -- `%s'"), idx + 1,
|
||||||
aarch64_get_operand_desc (opd_code), str);
|
aarch64_get_operand_desc (opd_code), str);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AARCH64_OPDE_INVALID_VARIANT:
|
case AARCH64_OPDE_INVALID_VARIANT:
|
||||||
@ -4073,28 +4075,28 @@ output_operand_error_record (const operand_error_record *record, char *str)
|
|||||||
if (detail->data[0] != detail->data[1])
|
if (detail->data[0] != detail->data[1])
|
||||||
as_bad (_("%s out of range %d to %d at operand %d -- `%s'"),
|
as_bad (_("%s out of range %d to %d at operand %d -- `%s'"),
|
||||||
detail->error ? detail->error : _("immediate value"),
|
detail->error ? detail->error : _("immediate value"),
|
||||||
detail->data[0], detail->data[1], detail->index + 1, str);
|
detail->data[0], detail->data[1], idx + 1, str);
|
||||||
else
|
else
|
||||||
as_bad (_("%s expected to be %d at operand %d -- `%s'"),
|
as_bad (_("%s expected to be %d at operand %d -- `%s'"),
|
||||||
detail->error ? detail->error : _("immediate value"),
|
detail->error ? detail->error : _("immediate value"),
|
||||||
detail->data[0], detail->index + 1, str);
|
detail->data[0], idx + 1, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AARCH64_OPDE_REG_LIST:
|
case AARCH64_OPDE_REG_LIST:
|
||||||
if (detail->data[0] == 1)
|
if (detail->data[0] == 1)
|
||||||
as_bad (_("invalid number of registers in the list; "
|
as_bad (_("invalid number of registers in the list; "
|
||||||
"only 1 register is expected at operand %d -- `%s'"),
|
"only 1 register is expected at operand %d -- `%s'"),
|
||||||
detail->index + 1, str);
|
idx + 1, str);
|
||||||
else
|
else
|
||||||
as_bad (_("invalid number of registers in the list; "
|
as_bad (_("invalid number of registers in the list; "
|
||||||
"%d registers are expected at operand %d -- `%s'"),
|
"%d registers are expected at operand %d -- `%s'"),
|
||||||
detail->data[0], detail->index + 1, str);
|
detail->data[0], idx + 1, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AARCH64_OPDE_UNALIGNED:
|
case AARCH64_OPDE_UNALIGNED:
|
||||||
as_bad (_("immediate value should be a multiple of "
|
as_bad (_("immediate value should be a multiple of "
|
||||||
"%d at operand %d -- `%s'"),
|
"%d at operand %d -- `%s'"),
|
||||||
detail->data[0], detail->index + 1, str);
|
detail->data[0], idx + 1, str);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Reference in New Issue
Block a user