This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Implement --section-details option.
ClosedPublic

Authored by grimar on Oct 13 2020, 3:01 AM.

Details

Summary

--section-details/-t is a GNU readelf option that produce
an output that is an alternative to --sections.

Diff Detail

Event Timeline

grimar created this revision.Oct 13 2020, 3:01 AM
Herald added a project: Restricted Project. · View Herald Transcript
grimar requested review of this revision.Oct 13 2020, 3:01 AM

I'm not going to have time to look at this today, and am off for the rest of the week. I'll try to look early next week. Don't forget to update the llvm-readelf documentation.

grimar updated this revision to Diff 298558.Oct 16 2020, 12:17 AM
  • Updated documentation to mention the new option.

llvm-readelf -S is actually an equivalent to readelf -S --wide in terms of formatting. It probably makes sense for us to do the same with -t (i.e. match the wide formatting), with all the content except the flags on one line.

llvm/test/tools/llvm-readobj/ELF/section-details.test
4
20

We should have at least one section with a long name that goes beyond the first column width, I think.

22

Any reason not to have all 5s for the entsize? What about a high alignment (since the addralign field is much wider than one byte)?

76

Is UNKNOWN printed for "known" OS/Processor specific flags with GNU readelf?

159

When reading this comment, I was expecting to see --sections win when specified first (latter could mean the latter as specified on the command-line).

168

I'd move this case to be immediately after the "standard" 64-bit case.

llvm/tools/llvm-readobj/ELFDumper.cpp
4204

Test case?

4212–4213

Shouldn't this use reportUniqueWarning? Also, test case?

4266
grimar updated this revision to Diff 300234.Oct 23 2020, 4:56 AM
grimar marked 9 inline comments as done.
  • Addressed review comments.

Now depends on D90019

grimar added inline comments.Oct 25 2020, 11:00 PM
llvm/test/tools/llvm-readobj/ELF/section-details.test
22

Done.

76

GNU readelf prints the following for sh_flags = 0xffffffffffffffff:

[ffffffffffffffff]: WRITE, ALLOC, EXEC, MERGE, STRINGS, INFO LINK, LINK ORDER, OS NONCONF, GROUP, TLS, COMPRESSED, GNU_MBIND, EXCLUDE, OS (000000000ef00000), PROC (0000000070000000), UNKNOWN (ffffffff000ff008)

I.e. it prints "OS", "PROC" and "UNKNOWN" separatelly. I've updated implementation to follow.

llvm/tools/llvm-readobj/ELFDumper.cpp
4212–4213

I've added a single test case that covers both warnings.
(Sorry, I think I just forgot about these places initially).

jhenderson accepted this revision.Oct 27 2020, 2:17 AM

LGTM, thanks.

llvm/test/tools/llvm-readobj/ELF/section-details.test
76

(grumbles quietly about SHF_EXCLUDE usurping a bit from the processor-specific range making the PROC value not match SHF_MASK_PROC...)

This revision is now accepted and ready to land.Oct 27 2020, 2:17 AM
This revision was automatically updated to reflect the committed changes.
MaskRay added inline comments.Oct 27 2020, 9:54 AM
llvm/test/tools/llvm-readobj/ELF/section-details.test
76

This is unfortunate but many architectures using this bit for other purposes are not supported by LLVM at all:)