]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
RISC-V: make .insn actually work for 64-bit insns
authorJan Beulich <jbeulich@suse.com>
Fri, 4 Mar 2022 12:37:59 +0000 (13:37 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 4 Mar 2022 12:37:59 +0000 (13:37 +0100)
Presently in this case, due to an undefined behavior shift, at least
with x86 cross builds I'm observing:

Error: value conflicts with instruction length `8,0x0000003f'

Eliminate the UB and extend the respective testcase.

gas/config/tc-riscv.c
gas/testsuite/gas/riscv/insn.d
gas/testsuite/gas/riscv/insn.s

index 322e0f070baab8c1e8a1cfe942b4152b9158f49c..9cc0abfda8811d8915dcc620afe17e4606b1c30c 100644 (file)
@@ -3248,7 +3248,7 @@ riscv_ip_hardcode (char *str,
   insn->match = values[num - 1];
   create_insn (ip, insn);
   unsigned int bytes = riscv_insn_length (insn->match);
-  if (values[num - 1] >> (8 * bytes) != 0
+  if ((bytes < sizeof(values[0]) && values[num - 1] >> (8 * bytes) != 0)
       || (num == 2 && values[0] != bytes))
     return _("value conflicts with instruction length");
 
index e55030ea460d6459ebb283db54eb8ad401f0fc5e..b5780f42861857cf885d9b257ba0e9528790cfb1 100644 (file)
@@ -71,5 +71,9 @@ Disassembly of section .text:
 [^:]+:[        ]+00c58533[     ]+add[  ]+a0,a1,a2
 [^:]+:[        ]+0001[         ]+nop
 [^:]+:[        ]+00000013[     ]+nop
+[^:]+:[        ]+001f 0000 0000[       ].*
+[^:]+:[        ]+0000003f 00000000[    ].*
 [^:]+:[        ]+0001[         ]+nop
 [^:]+:[        ]+00000013[     ]+nop
+[^:]+:[        ]+001f 0000 0000[       ].*
+[^:]+:[        ]+0000003f 00000000[    ].*
index e47f529040de8db8e82113f7a4d332c1848ead3d..ec41acb30bd397c6a27a6dff43bafdf5181fa551 100644 (file)
@@ -56,5 +56,9 @@ target:
 
        .insn 0x0001
        .insn 0x00000013
+       .insn 0x0000001f
+       .insn 0x0000003f
        .insn 0x2, 0x0001
        .insn 0x4, 0x00000013
+       .insn 6, 0x0000001f
+       .insn 8, 0x0000003f