Differentiating between rv64imafd and rv64imafdc isa

1.3k views Asked by At

How can differentiate between a rv64imafd and rv64imafdc binary without executing them? I am using few compiler flags for changing the extensions but I'm not sure how to verify it. I don't want to dump the executable every time for testing on my imafd board.
I tried to study objdump of both the files and even though there was a clear difference between the opcodes, but it is not enough. Let me know if I can share more information on this regard.

2

There are 2 answers

2
yflelion On BEST ANSWER

Even if you compile with the rv64imafd flag, your executable can be rv64imadfc if you link to a library (or a crt file) compiled with rv64imadfc.
This seems to be the case because your final executable contains the c flag even if you compile to rv64imafd.
If you are using https://github.com/riscv/riscv-gnu-toolchain
The build defaults to targeting rv64gc so you are linking against rv64gc libraries. if you used --enable-multilib you are linking against rv64imafdc.

In order to generate an rv64imafd executable you have three choices:

  • use the nostdlib and nostartfiles options and pass the necessary files (compiled with rv64imafd) by hand.
  • build a toolchain with -march=rv64imafd -mabi=lp64d
  • modify t-elf-multilib to also generate rv64imafd and build the toolchain with --enable-multilib option.
2
TheThirdOne On

objdump or a program that does an equivalent level of decoding is probably necessary to confirm no compressed instructions are present in the binary. However ELF executables made by the GNU toolchain use the flags of the elf binary to encode if it was compiled with compressed instructions enabled.

$readelf -h no_compressed.o 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  ...
  Flags:                             0x4, double-float ABI
  ...
$ readelf -h compressed.o 
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  ...
  Flags:                             0x5, RVC, double-float ABI
  ...