aboutsummaryrefslogtreecommitdiff
path: root/gdb/utils.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2021-11-30 17:50:24 +0000
committerRichard Sandiford <richard.sandiford@arm.com>2021-11-30 17:50:24 +0000
commit2dd3146b4ffcb8528a6e093741ba31636afdf8ae (patch)
treea2543c17fb985705cd980f6cb61b53f41300ff96 /gdb/utils.c
parent90fe61ced1c9aa4afb263326e336330d15603fbf (diff)
downloadbinutils-2dd3146b4ffcb8528a6e093741ba31636afdf8ae.zip
binutils-2dd3146b4ffcb8528a6e093741ba31636afdf8ae.tar.gz
binutils-2dd3146b4ffcb8528a6e093741ba31636afdf8ae.tar.bz2
aarch64: Check for register aliases before mnemonics
Previously we would not accept: A .req B if A happened to be the name of an instruction. Adding new instructions could therefore invalidate existing register aliases. I noticed this with a test that used "zero" as a register alias for "xzr", where "zero" is now also the name of an SME instruction. I don't have any evidence that "real" code is doing this, but it seems at least plausible. This patch switches things so that we check for register aliases first. It might slow down parsing slightly, but the difference is unlikely to be noticeable. Things like: b .req + 0 still work, since create_register_alias checks for " .req ", and with the input scrubber, we'll only keep whitespace after .req if it's followed by another name. If there's some valid expression that I haven't thought about that is scrubbed to " .req ", users could avoid the ambiguity by wrapping .req in parentheses. The new test for invalid aliases already passed. I just wanted something to exercise the !dot condition. I can't find a way of exercising the (existing) p == base condition, but I'm not brave enough to say that it can never happen. If it does happen, get_mnemonic_name would return an empty string. gas/ * config/tc-aarch64.c (opcode_lookup): Move mnemonic extraction code to... (md_assemble): ...here. Check for register aliases first. * testsuite/gas/aarch64/register_aliases.d, testsuite/gas/aarch64/register_aliases.s: Test for a register alias called "zero". * testsuite/gas/aarch64/register_aliases_invalid.d, testsuite/gas/aarch64/register_aliases_invalid.l, testsuite/gas/aarch64/register_aliases_invalid.s: New test.
Diffstat (limited to 'gdb/utils.c')
0 files changed, 0 insertions, 0 deletions