[PATCH] RISC-V: don't disassemble unrecognized insns as .byte

Maciej W. Rozycki macro@orcam.me.uk
Mon Jan 30 03:33:55 GMT 2023


Hi Nelson,

> 0000000000000000 <.text>:
>    0: 0001                .short 0x0001
>    2: 0001                .2byte 0x1
>    4: 0001                .short 0x0001
> ...
> 
> The .<N>byte in assembly will also be treated as data to dump, so
> ideally, dump these unrecognized instructions as .insn is probably
> more reasonable and won't be confused.

 I wasn't aware about the RISC-V `.insn' pseudo-op.  I think it will make 
a lot of sense to use it here then, so I'd be happier with either:

   2: 0001                .insn 0x0001

or:

   2: 0001                .insn 0x2, 0x1

and analogously for unrecognised instructions comprised of a higher number 
of parcels according to the opcode allocation, e.g.:

Disassembly of section .text:
0000000000000000 <foo> .insn	0x00000000001f

or:

Disassembly of section .text:
0000000000000000 <foo> .insn	0x6, 0x1f

(here in the `--prefix-addresses' format).  The single-argument format may 
by clearer to the casual eye at the cost of extra leading zeros with some 
encodings.

  Maciej


More information about the Binutils mailing list