Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RISCV dissassembly options numeric and no-aliases

I cloned the riscv-tools repository (master branch) and followed the build procedure. Everything went fine.

Then I tried compiling the hello world program for a RV32IM instruction set, doing this:

riscv64-unknown-elf-gcc -m32 -march=RV32IM -o hello hello.c -save-temps

I used options save-temps to keep the intermediate files. (hello.s, hello.i, hello.o)

Everything is OK so far, I can run the hello world program with:

spike pk hello
Hello world!

Now I wanted to take a look at the assembly code for this program. I did the following and I do get the assembly code into hello.dump

riscv64-unknown-elf-objdump -D -S -l -F  hello.o > hello.o.dump

Now what I would be interested to see is the assembly code without pseudo instructions and with the non ABI-register names.

It appears to be possible to get that, when I do:

riscv64-unknown-elf-objdump --target-help

I get this:

The following RISC-V-specific disassembler options are supported for use
with the -M switch (multiple options should be separated by commas):

numeric       Print numeric reigster names, rather than ABI names.

no-aliases    Disassemble only into canonical instructions, rather
              than into pseudoinstructions.

However when I try adding these options, it does not work.

riscv64-unknown-elf-objdump -D -S -l -F  -Mno-aliases hello.o > hello.o.dump
Unrecognized disassembler option: no-aliases

riscv64-unknown-elf-objdump -D -S -l -F  -Mnumeric hello.o > hello.o.dump
Unrecognized disassembler option: numeric

riscv64-unknown-elf-objdump -D -S -l -F  -Mnumeric,no-aliases hello.o > hello.o.dump
Unrecognized disassembler option: numeric
Unrecognized disassembler option: no-aliases

Is it a command syntax error or is it just not supported yet by the disassembler?

like image 743
odarcy Avatar asked Oct 31 '25 15:10

odarcy


1 Answers

I can reproduce this and get the same error message. However, riscv64-unknown-elf-objdump returns 0 and the output file does contain an assembler dump without pseudoinstructions and/or with numeric register names, as requested by the option. So it seems like this is working as expected, it just also outputs an irritating error message.

The riscv-tools repo has not been updated since Feb. I also tried this with a build of a more recent version of riscv-gnu-toolchain and here I don't get the error message. So I'd say this is a non-critical bug that already has been fixed in riscv-gnu-toolchain and thus it will be fixed in riscv-tools as soon as riscv-gnu-toolchain is updated there.

like image 115
CliffordVienna Avatar answered Nov 03 '25 07:11

CliffordVienna