[PATCH] gas/aarch64: fix assertion failure caused by glitch in optional operand handling

Jiong Wang jiong.wang@arm.com
Mon Jun 2 11:21:00 GMT 2014


AArch64 gas support optional operand format, for example, "ret x30" could be
written as "ret".

The user could also give the register themselves, like "ret xx", while the
given
operand may be in wrong register format.

The problem is We have glitch in our current invalid operand handling code
when
optional operand involved in.

our current code logic is:

if operand_is_wrong
  goto invalid_label

invalid_label:
  if (!operand_could_be_optional)
    report_operand_error ();

  use_default_value () <-- A
  clear_errors ()

The logic is wrong because if the operand given by user is in wrong format,
and
the operand is optional, still we will reach A, and the error is propagated
to
later stage in assembler, and we eventually run into the following assertion
failure:

02:38:40: Assertion failure in output_operand_error_record at
...tc-aarch64.c line 3905.
02:38:40: Please report this bug.

*this patch modify the code logic to*

if operand_is_wrong
  goto invalid_label

invalid_label:
  if (!operand_could_be_optional)
    report_operand_error ();
   
  if (given_operand)
    report_operand_error ();

  use_default_value ()
  clear_errors ()

OK for trunk ?

Thanks.

Jiong

gas/
  * config/tc-aarch64.c (END_OF_INSN): New macro.
  (parse_operands): Handle operand given and be in wrong
  format when operand is optional.

gas/testsuite/
  * gas/aarch64/diagnostic.s: New test patterns.
  * gas/aarch64/diagnostic.l: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-optionalv2.patch
Type: application/octet-stream
Size: 4539 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20140602/7a4c5374/attachment.obj>


More information about the Binutils mailing list