This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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.

Attachment: fix-optionalv2.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]