This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Allow llvm-objdump to disassemble objects with unrecognised versions of known extensions
ClosedPublic

Authored by asb on Mar 14 2023, 11:08 PM.

Details

Summary

This Moves ELFObjectFile to using RISCVISAInfo::parseNormalizedArchString which is not an NFC, as the test changes show. D144353 transitioned LLD to using this function, which is specialised to parsing arch strings in the normalised format specified in the psABI rather than user-authored strings accepted in -march, which has greater flexibility.

parseNormalizedArchString does not ignore or produce an error for ISA extensions with a version that isn't recognised/supported by LLVM. As current GCC is marking its objects with a higher version of the A, F, and D extensions than LLVM (see extension versioning discussion this massively improves the usability of llvm-objdump with such binaries.

This patch also solves the issues addressed in D146070, though I've opted to post both because I suspect this patch may attract more discussion about questions such as if/when warning should be produced, while D146070 is hopefully more straightforward to land. One challenge with producing warnings for unrecognised versions is that LLVM lacks a good infrastructure for doing this from utility code like RISCVISAInfo.

Diff Detail

Event Timeline

asb created this revision.Mar 14 2023, 11:08 PM
Herald added a project: Restricted Project. · View Herald Transcript
asb requested review of this revision.Mar 14 2023, 11:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2023, 11:08 PM
asb edited the summary of this revision. (Show Details)Mar 14 2023, 11:12 PM
MaskRay accepted this revision.EditedMar 22 2023, 11:06 AM

The unknown_ext_version.s case is common (for GCC uses) and will get improved.

It seems that llvm-objdump -d noncanonicalized_arch.o can ideally report a warning and continue dumping. The case is rare and less important, so stopping dumping for the case is fine with me.

llvm/test/tools/llvm-objdump/ELF/RISCV/riscv-attributes.s
19

Use FileCheck -DFILE=noncanonicalized_arch.o

Add error: to check that this is an error.

Add NONCANON-NOT: {{.}} to assert that there is no dumping after the error message.

This revision is now accepted and ready to land.Mar 22 2023, 11:06 AM
asb updated this revision to Diff 508420.Mar 26 2023, 8:05 AM
asb marked an inline comment as done.

Rebase and address review comments.