[PATCH 1/2] RISC-V: Fix abort when displaying .dword

Alan Modra amodra@gmail.com
Wed Feb 12 07:25:16 GMT 2025


On Tue, Feb 11, 2025 at 09:08:30PM -0800, Charlie Jenkins wrote:
> In the normal case an instruction won't be split into 5, 6, or 7 byte
> sections. However a .dword disassembled with -D can cause an instruction
> to split across the 6 byte boundary. 6 byte instructions were not
> supported so riscv_disassemble_data() would abort.

I think it is worse than just needing to cope with 5, 6, or 7 bytes.
riscv-dis.c:1444 sets dump_size from riscv_insn_length which
looks like it can be up to 22 bytes.  A carefully constructed testcase
that gets this value from riscv_insn_length but then has only 20
bytes in the section will result in riscv_disassemble_data being
called with bytes_per_chunk of 20.

cat > xxx.s <<EOF
 .byte 0x7f,0xef,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
EOF
gas/as-new -o xxx.o xxx.s
binutils/objcopy --strip-symbol '$d' xxx.o xx.o
binutils/objdump -d xx.o

-- 
Alan Modra


More information about the Binutils mailing list