]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
aarch64: Fix scbnds validation
authorAlex Coplan <alex.coplan@arm.com>
Thu, 11 Nov 2021 16:57:22 +0000 (16:57 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Thu, 11 Nov 2021 16:57:22 +0000 (16:57 +0000)
commit862dbfa125c21d0a3daff2b9dba50fc3bdd4d9d6
treedd8f0535f6771f3b991adc2f89b90b430b0598ce
parentc1df4645c4a66364e2f792aa3a71373ba7e66aac
aarch64: Fix scbnds validation

Prior to this patch, we were failing to validate scbnds instructions
properly in multiple ways. The code in tc-aarch64.c:parse_operands
failed to check if the expression parsing code actually returned a
constant (O_constant) immediate. For sufficiently large immediates this
would result in O_big instead and this was not handled.

Moreover, the code to coerce the immediate form into the immediate +
shift form of the instruction was buggy in multiple ways: using the
wrong mask to check if the lower bits were set and checking the wrong
variable.

Finally, the code in operand_general_constraint_met_p was only checking
if the immediate is in range for the shifted case: it should be checking
this in both cases.

As well as fixing these issues, this patch improves the error messages
in a couple of cases and adds tests for various valid and invalid cases.

gas/ChangeLog:

2021-11-11  Alex Coplan  <alex.coplan@arm.com>

* config/tc-aarch64.c (parse_shift): Improve error message for
O_big expressions.
(parse_operands): In AARCH64_OPND_A64C_IMM6_EXT case, handle
parse_shifter_operand_imm returning non-O_constant
expressions; fix logic for coercion to the shifted form.
* testsuite/gas/aarch64/scbnds-immed.d: New test.
* testsuite/gas/aarch64/scbnds-immed.s: Assembly thereof.
* testsuite/gas/aarch64/scbnds-invalid.d: New test.
* testsuite/gas/aarch64/scbnds-invalid.l: Error output thereof.
* testsuite/gas/aarch64/scbnds-invalid.s: Assembly thereof.

opcodes/ChangeLog:

2021-11-11  Alex Coplan  <alex.coplan@arm.com>

* aarch64-opc.c (operand_general_constraint_met_p): Always check
if the immediate is in range for AARCH64_OPND_A64C_IMM6_EXT.
gas/ChangeLog
gas/config/tc-aarch64.c
gas/testsuite/gas/aarch64/scbnds-immed.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/scbnds-immed.s [new file with mode: 0644]
gas/testsuite/gas/aarch64/scbnds-invalid.d [new file with mode: 0644]
gas/testsuite/gas/aarch64/scbnds-invalid.l [new file with mode: 0644]
gas/testsuite/gas/aarch64/scbnds-invalid.s [new file with mode: 0644]
opcodes/ChangeLog
opcodes/aarch64-opc.c