0

I'm playing with RISC-V. I have a .img file and I want to disassemble it into a .asm file, so I ran the following command:

> riscv64-unknown-elf-objdump -d xxx.img > xxx.asm

However, I got this issue:

riscv64-unknown-elf-objdump: xxx.img: file format not recognized

How can I fix it? I have no idea what to do with this issue.

1 Answers1

0

If you run:

riscv64-unknown-elf-objdump --help

You'll see a line like:

riscv64-unknown-elf-objdump: supported architectures: riscv riscv:rv64 riscv:rv32

These are the supported architectures that you need to pass as the -m argument. Normally, an ELF file will encode this information so there's no guesswork, but in the case of using a flat file, there's no way for objdump to know how the instructions are supposed to be interpreted. The final command is:

riscv64-unknown-elf-objdump -b binary -m riscv:rv64 -D xxx.bin
Gunchars
  • 9,555
  • 3
  • 28
  • 27