]> 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)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:59:24 +0000 (15:59 -0700)
commitafc62fdf46a88d780890e1bb1d2b7e74ff5fdd27
tree2d0314305380d518389c52b9d7a106e39d3380b3
parent4b9a164ea998296ef9f8abe0f90a14fdc0f74ff8
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