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

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

Differential revision: https://reviews.llvm.org/D86208
This commit is contained in:
Georgii Rymar 2020-08-19 15:38:43 +03:00
parent 48a439a77a
commit 53c4cabd9b
2 changed files with 7 additions and 8 deletions

View File

@ -48,9 +48,9 @@
# ELF32-NEXT: GNU_STACK 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: GNU_RELRO 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: GNU_PROPERTY 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x65a3dbe6 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x65a3dbe7 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x65a41be6 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: OPENBSD_RANDOMIZE 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: OPENBSD_WXNEEDED 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: OPENBSD_BOOTDATA 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x6fffffff 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x70000000 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
# ELF32-NEXT: <unknown>: 0x70000001 0x000314 0x00001000 0x00001000 0x00003 0x00003 0x1
@ -78,9 +78,9 @@
# ELF64-NEXT: GNU_STACK 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: GNU_RELRO 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: GNU_PROPERTY 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x65a3dbe6 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x65a3dbe7 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x65a41be6 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: OPENBSD_RANDOMIZE 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: OPENBSD_WXNEEDED 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: OPENBSD_BOOTDATA 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x6fffffff 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x70000000 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ELF64-NEXT: <unknown>: 0x70000001 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1

View File

@ -1696,8 +1696,7 @@ static StringRef segmentTypeToString(unsigned Arch, unsigned Type) {
static std::string getGNUPtType(unsigned Arch, unsigned Type) {
StringRef Seg = segmentTypeToString(Arch, Type);
// GNU doesn't recognize PT_OPENBSD_*.
if (Seg.empty() || Seg.startswith("PT_OPENBSD_"))
if (Seg.empty())
return std::string("<unknown>: ") + to_string(format_hex(Type, 1));
// E.g. "PT_ARM_EXIDX" -> "EXIDX".