This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Don't print OS/Processor specific prefix for known ELF file types.
ClosedPublic

Authored by grimar on Dec 14 2020, 7:16 AM.

Details

Summary

This is a change suggested in post commit comments for
D93096 (https://reviews.llvm.org/D93096#2451796).

Imagine we want to add a custom OS specific ELF file type.
For that we can update the ElfObjectFileType array:

static const EnumEntry<unsigned> ElfObjectFileType[] = {
...
  {"Core",         "CORE (Core file)",         ELF::ET_CORE},
  {"MyType",       "MyType (my description)",     0xfe01},
};

The current code then might print:

OS Specific: (MyType (my description))

Though instead we probably would like to see a nicer output, e.g:

Type: MyType (my description)

To achieve that we can reorder the code slightly.

It is impossible to add a test I think, because we have no custom values in
the ElfObjectFileType array in LLVM.

Diff Detail

Event Timeline

grimar created this revision.Dec 14 2020, 7:16 AM
grimar requested review of this revision.Dec 14 2020, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 14 2020, 7:16 AM
grimar retitled this revision from [llvm-readelf] - Don't OS/Processor specific prefix for known ELF file types. to [llvm-readelf] - Don't print OS/Processor specific prefix for known ELF file types..Dec 14 2020, 7:17 AM

Obviously, this looks good to me, since this was my original suggestion, but it's probably best for @MaskRay or others to agree.

MaskRay accepted this revision.Dec 14 2020, 9:32 AM

This is certainly fine:) Known ElfObjectFileType values can be handled first. Good to know there are indeed OS-specific ET_* in use)

This revision is now accepted and ready to land.Dec 14 2020, 9:32 AM