This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj/elf] - Cleanup helpers that are used to print segment types. NFCI.
ClosedPublic

Authored by grimar on Aug 12 2020, 5:06 AM.

Details

Summary

getElfSegmentType and getElfPtType are methods that are used for printing
segment types for LLVM and GNU styles accordingly.

This patch does a cleanup and simplification that allows to avoid
the code duplication and to get rid of one macro.

Diff Detail

Event Timeline

grimar created this revision.Aug 12 2020, 5:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 5:06 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar requested review of this revision.Aug 12 2020, 5:06 AM
grimar planned changes to this revision.Aug 12 2020, 5:48 AM
grimar updated this revision to Diff 285055.Aug 12 2020, 5:58 AM
  • Teach the code about "PT_OPENBSD_*". One of the tests failed previously, I've not noticed it at first.
jhenderson accepted this revision.Aug 13 2020, 1:26 AM

get rid of one of macro.

"get rid of one macro"

LGTM, since we're not making the behaviour worse, but it would be nice to add support for the PT_OPENBSD versions in GNU mode too, unless there's a compelling reason not to. That can be a separate change though.

llvm/tools/llvm-readobj/ELFDumper.cpp
1709–1710

I'm curious what others here think, but I don't think we need to emulate GNU's behaviour where they simply don't recognise a specific PT_* value (unless it clashes with another value). It seems to me like the better thing to do would be to ask GNU to add support for it in binutils.

This revision is now accepted and ready to land.Aug 13 2020, 1:26 AM
grimar added inline comments.Aug 13 2020, 4:06 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
1709–1710

I'm curious what others here think, but I don't think we need to emulate GNU's behaviour where they simply don't recognise a specific PT_* value

I agree that we probably shouldn't and might want to go ahead and remove this condition in a follow-up even without waiting for GNU. Cleanup/refactoring changes (like this patch) are better to be NFC anyways too though.

I'll re-check what the latest binutils code do here and probably submit a bug for them.

grimar edited the summary of this revision. (Show Details)Aug 13 2020, 4:06 AM
MaskRay added inline comments.Aug 13 2020, 10:04 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
1709–1710

Agree