简体   繁体   English

区分 rv64imafd 和 rv64imafdc isa

[英]Differentiating between rv64imafd and rv64imafdc isa

How can differentiate between a rv64imafd and rv64imafdc binary without executing them?如何在不执行它们的情况下区分 rv64imafd 和 rv64imafdc 二进制文件? 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.我不想每次都转储可执行文件以在我的 imafd 板上进行测试。
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.我试图研究这两个文件的 objdump,即使操作码之间存在明显差异,但这还不够。 Let me know if I can share more information on this regard.让我知道我是否可以分享有关这方面的更多信息。

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.即使您使用 rv64imafd 标志进行编译,如果您链接到使用 rv64imadfc 编译的库(或 crt 文件),您的可执行文件也可以是 rv64imadfc。
This seems to be the case because your final executable contains the c flag even if you compile to rv64imafd.这似乎是因为即使您编译为 rv64imafd,您的最终可执行文件也包含 c 标志。
If you are using https://github.com/riscv/riscv-gnu-toolchain如果您使用的是https://github.com/riscv/riscv-gnu-toolchain
The build defaults to targeting rv64gc so you are linking against rv64gc libraries.构建默认以 rv64gc 为目标,因此您链接的是 rv64gc 库。 if you used --enable-multilib you are linking against rv64imafdc.如果您使用了 --enable-multilib,您将链接到 rv64imafdc。

In order to generate an rv64imafd executable you have three choices:为了生成 rv64imafd 可执行文件,您有三个选择:

  • use the nostdlib and nostartfiles options and pass the necessary files (compiled with rv64imafd) by hand.使用 nostdlib 和 nostartfiles 选项并手动传递必要的文件(使用 rv64imafd 编译)。
  • build a toolchain with -march=rv64imafd -mabi=lp64d使用-march=rv64imafd -mabi=lp64d构建工具链
  • modify t-elf-multilib to also generate rv64imafd and build the toolchain with --enable-multilib option.修改t-elf-multilib以生成 rv64imafd 并使用--enable-multilib选项构建工具链。

objdump or a program that does an equivalent level of decoding is probably necessary to confirm no compressed instructions are present in the binary.可能需要objdump或执行等效解码级别的程序来确认二进制文件中不存在压缩指令。 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.但是,如果编译时启用了压缩指令,则 GNU 工具链生成的 ELF 可执行文件使用 elf 二进制文件的标志进行编码。

$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
  ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM