This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Start recognizing 'PT_OPENBSD_*' segment types.
ClosedPublic

Authored by grimar on Aug 19 2020, 5:49 AM.

Details

Summary

Its a follow-up for D85830, it stops ignoring 'PT_OPENBSD_*' segment types.
Now them are recognized properly.

Note: GNU readelf does not recognize them, though perhaps it shouldn't.
Anyways, it was reported to binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=26405#c0

Diff Detail

Event Timeline

grimar created this revision.Aug 19 2020, 5:49 AM
grimar requested review of this revision.Aug 19 2020, 5:49 AM

GNU readelf does not handle them properly, I've reported a bug to binutils: https://sourceware.org/bugzilla/show_bug.cgi?id=26405#c0

PT_LOOS through PT_HIOS - Values in this inclusive range are reserved for operating system-specific semantics.

I think it is entirely fair for readelf not to decode them. PT_OPENBSD_BOOTDATA may be a legacy thing. PT_OPENBSD_RANDOMIZE and PT_OPENBSD_WXNEEDED have some references. I think we choose to display the strings just because that makes code simpler.

jhenderson accepted this revision.Aug 21 2020, 12:18 AM

On the basis that this makes the code simpler, and there's no strong motivation not to do this, LGTM.

We might want to consider a strategy for better deciding when to interpret these and other OS-specific segment types however, since not all OSes will support them, and in the worst case, there could even be duplicate meanings for a given value. The alternative to supporting them would be to remove them from the program header definition, of course.

This revision is now accepted and ready to land.Aug 21 2020, 12:18 AM
MaskRay accepted this revision.Aug 21 2020, 12:31 AM

We might want to consider a strategy for better deciding when to interpret these and other OS-specific segment types however, since not all OSes will support them

We can just check for ELFOSABI_OPENBSD I think.

grimar edited the summary of this revision. (Show Details)Aug 21 2020, 1:24 AM