1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[llvm-readobj] - Print "Unknown" when a program header is unknown.

Currently, when a program header type is unknown, we dont print anything:

```
ProgramHeader {
  Type:  (0x60000000)
```

With this patch the output will be:

```
ProgramHeader {
  Type: Unknown (0x60000000)
```

It was discussed in D85526 and consistent with what we print for
'--sections' already, e.g.:

```
Section {
  Name: .sec
  Type: Unknown (0x7FFFFFFF)
}
```

Differential revision: https://reviews.llvm.org/D86213
This commit is contained in:
Georgii Rymar 2020-08-19 16:23:51 +03:00
parent 8908aecdf3
commit f23c466d76
2 changed files with 13 additions and 12 deletions

View File

@ -222,7 +222,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x60000000)
# ELF-LLVM-NEXT: Type: Unknown (0x60000000)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -330,7 +330,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x6FFFFFFF)
# ELF-LLVM-NEXT: Type: Unknown (0x6FFFFFFF)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -342,7 +342,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x70000000)
# ELF-LLVM-NEXT: Type: Unknown (0x70000000)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -354,7 +354,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x70000001)
# ELF-LLVM-NEXT: Type: Unknown (0x70000001)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -366,7 +366,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x70000002)
# ELF-LLVM-NEXT: Type: Unknown (0x70000002)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -378,7 +378,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x70000003)
# ELF-LLVM-NEXT: Type: Unknown (0x70000003)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -390,7 +390,7 @@
# ELF-LLVM-NEXT: Alignment: 1
# ELF-LLVM-NEXT: }
# ELF-LLVM-NEXT: ProgramHeader {
# ELF-LLVM-NEXT: Type: (0x7FFFFFFF)
# ELF-LLVM-NEXT: Type: Unknown (0x7FFFFFFF)
# ELF32-LLVM-NEXT: Offset: 0x314
# ELF64-LLVM-NEXT: Offset: 0x548
# ELF-LLVM-NEXT: VirtualAddress: 0x1000
@ -596,11 +596,11 @@ ProgramHeaders:
# ARM-GNU-NEXT: <unknown>: 0x70000002 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
# ARM-LLVM: ProgramHeader {
# ARM-LLVM: Type: (0x70000000)
# ARM-LLVM: Type: Unknown (0x70000000)
# ARM-LLVM: ProgramHeader {
# ARM-LLVM-NEXT: Type: PT_ARM_EXIDX (0x70000001)
# ARM-LLVM: ProgramHeader {
# ARM-LLVM-NEXT: Type: (0x70000002)
# ARM-LLVM-NEXT: Type: Unknown (0x70000002)
## Check how we dump MIPS specific program headers.
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_MIPS %s -o %tmips.elf

View File

@ -6524,9 +6524,10 @@ void LLVMStyle<ELFT>::printProgramHeaders(const ELFO *Obj) {
for (const Elf_Phdr &Phdr : *PhdrsOrErr) {
DictScope P(W, "ProgramHeader");
W.printHex("Type",
segmentTypeToString(Obj->getHeader()->e_machine, Phdr.p_type),
Phdr.p_type);
StringRef Type =
segmentTypeToString(Obj->getHeader()->e_machine, Phdr.p_type);
W.printHex("Type", Type.empty() ? "Unknown" : Type, Phdr.p_type);
W.printHex("Offset", Phdr.p_offset);
W.printHex("VirtualAddress", Phdr.p_vaddr);
W.printHex("PhysicalAddress", Phdr.p_paddr);