]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
aarch64: Fix incorrect sysreg notes operand notes
authorAlice Carlotti <alice.carlotti@arm.com>
Tue, 4 Nov 2025 12:28:56 +0000 (12:28 +0000)
committerAlice Carlotti <alice.carlotti@arm.com>
Thu, 4 Dec 2025 16:21:55 +0000 (16:21 +0000)
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.

opcodes/aarch64-opc.c

index b074765920ed88f2d39c5fdf738a7c472db03eb3..d7e697e72479824f47c3c93f5b379851983683b5 100644 (file)
@@ -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");
            }
        }