]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: disallow x0 with certain macro-insns
authorJan Beulich <jbeulich@suse.com>
Fri, 24 Nov 2023 08:53:15 +0000 (09:53 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 24 Nov 2023 08:53:15 +0000 (09:53 +0100)
commit27b33966b18ed8bf1701a60999448224b1d28273
tree2d6ad5e3535f234553e9afacf7f4d18eb9ca2560
parent6c0c7d489bdf106d90b300aeb8d042c7b1ad3d2b
RISC-V: disallow x0 with certain macro-insns

While for some of the macro insns using x0 is kind of okay, as they
would merely resolve to a sequence of hint insns (and hence not cause
misbehavior at runtime), several of them have the degenerate AUIPC
followed by a load, store, or branch using other than the designated
symbol as address and hence causing runtime issues. Refuse to assemble
those, leveraging that the matching function so far wasn't really used
for macro insns: NULL is now allowed, indicating a match (which imo is
preferable over converting match_never() to match_always()), while
other matching functions now (also) used for macro insns need to avoid
calling match_opcode().

Note that for LA the restriction is slightly too strict: In non-PIC mode
using x0 would be okay-ish as per above (as it's just LLA there). Yet
libopcodes doesn't know what mode gas is presently assembling for, so we
want to err on the safe side.

Acked-by: Palmer Dabbelt <palmer@rivosinc.com>
gas/NEWS
gas/config/tc-riscv.c
opcodes/riscv-dis.c
opcodes/riscv-opc.c