[binutils-gdb] aarch64: Fix incorrect sysreg notes operand notes
Alice Carlotti
acarlotti@sourceware.org
Thu Dec 4 16:24:36 GMT 2025
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f9e512968b489276d5c950084e26fa2a49a9b983
commit f9e512968b489276d5c950084e26fa2a49a9b983
Author: Alice Carlotti <alice.carlotti@arm.com>
Date: Tue Nov 4 12:28:56 2025 +0000
aarch64: Fix incorrect sysreg notes operand notes
When support for Armv8-R was added in 2020, aarch64_print_operand was
modified to check architecture features when searching for a system
register name. However, this mismatch is then conflated with
read-only/write-only mismatches, leading to incorrect note emission when
reading a read-only or writing a write-only system register that is not
available in whichever of Armv8-A or Armv8-R we are using.
The original code also segfaults when parsing `msr mpuir_el1, w1'. This
segfault arises while suggesting alternative assembler input with
corrected qualifiers, due to a missing NULL check when attempting to
emit notes. The segfault is unreachable after this change, but a
subsequent patch will incorporate NULL checking anyway.
Once notes are enabled by default, an existing `mrs x0, mpuir_el1' test
will verify that the incorrect notes are no longer generated.
Diff:
---
opcodes/aarch64-opc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index b074765920e..d7e697e7247 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -5024,9 +5024,11 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc,
indicates what we didn't want for this instruction. e.g. If
F_REG_READ is there, that means we were looking for a write
register. See aarch64_ext_sysreg. */
- if (aarch64_sys_regs[i].flags & F_REG_WRITE)
+ if (aarch64_sys_regs[i].flags & F_REG_WRITE
+ && !(opnd->sysreg.flags & F_REG_WRITE))
*notes = _("reading from a write-only register");
- else if (aarch64_sys_regs[i].flags & F_REG_READ)
+ else if (aarch64_sys_regs[i].flags & F_REG_READ
+ && !(opnd->sysreg.flags & F_REG_READ))
*notes = _("writing to a read-only register");
}
}
More information about the Binutils-cvs
mailing list