Index: lld/test/ELF/linkerscript/non-alloc-segment.s =================================================================== --- lld/test/ELF/linkerscript/non-alloc-segment.s +++ lld/test/ELF/linkerscript/non-alloc-segment.s @@ -29,7 +29,7 @@ # CHECK-NEXT: 00 .text # CHECK-NEXT: 01 .foo -# PHDR: Type: (0x12345678) +# PHDR: Type: Unknown (0x12345678) # PHDR-NEXT: Offset: 0x1004 # PHDR-NEXT: VirtualAddress # PHDR-NEXT: PhysicalAddress Index: lld/test/ELF/linkerscript/phdrs.s =================================================================== --- lld/test/ELF/linkerscript/phdrs.s +++ lld/test/ELF/linkerscript/phdrs.s @@ -99,7 +99,7 @@ # INT-PHDRS: ProgramHeaders [ # INT-PHDRS: ProgramHeader { -# INT-PHDRS: Type: (0x11223344) +# INT-PHDRS: Type: Unknown (0x11223344) # INT-PHDRS-NEXT: Offset: 0xB0 # INT-PHDRS-NEXT: VirtualAddress: 0xB0 # INT-PHDRS-NEXT: PhysicalAddress: 0xB0 Index: llvm/test/tools/llvm-readobj/ELF/program-headers.test =================================================================== --- llvm/test/tools/llvm-readobj/ELF/program-headers.test +++ llvm/test/tools/llvm-readobj/ELF/program-headers.test @@ -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 @@ # ARM-GNU-NEXT: : 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 Index: llvm/tools/llvm-readobj/ELFDumper.cpp =================================================================== --- llvm/tools/llvm-readobj/ELFDumper.cpp +++ llvm/tools/llvm-readobj/ELFDumper.cpp @@ -6516,9 +6516,10 @@ 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);