]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
RISC-V: Add string length check for operands in AS
authorLi Xu <xuli1@eswincomputing.com>
Wed, 14 Dec 2022 07:32:40 +0000 (07:32 +0000)
committerNelson Chu <nelson@rivosinc.com>
Wed, 14 Dec 2022 09:23:12 +0000 (17:23 +0800)
commit207cc92d92c863298c530498e2dbf71a2b5fd8ae
treecb511015d63057430220e610218660331642843f
parenteb99386180bb187f3ef3a59b222f16c8dfe3b81e
RISC-V: Add string length check for operands in AS

The current AS accepts invalid operands due to miss of operands length check.
For example, "e6" is an invalid operand in (vsetvli a0, a1, e6, mf8, tu, ma),
but it's still accepted by assembler.  In detail, the condition check "strncmp
(array[i], *s, len) == 0" in arg_lookup function passes with "strncmp ("e64",
"e6", 2)" in the case above.  So the generated encoding is same as that of
(vsetvli a0, a1, e64, mf8, tu, ma).

This patch fixes issue above by prompting an error in such case and also adds
a new testcase.

gas/ChangeLog:

        * config/tc-riscv.c (arg_lookup): Add string length check for operands.
        * testsuite/gas/riscv/vector-insns-fail-vsew.d: New testcase for an illegal vsew.
        * testsuite/gas/riscv/vector-insns-fail-vsew.l: Likewise.
        * testsuite/gas/riscv/vector-insns-fail-vsew.s: Likewise.
gas/config/tc-riscv.c
gas/testsuite/gas/riscv/vector-insns-fail-vsew.d [new file with mode: 0644]
gas/testsuite/gas/riscv/vector-insns-fail-vsew.l [new file with mode: 0644]
gas/testsuite/gas/riscv/vector-insns-fail-vsew.s [new file with mode: 0644]