mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[Mips] Teach llvm-readobj to print MIPS-specific ELF program headers.
The patch reviewed by Michael Spencer. http://llvm-reviews.chandlerc.com/D1846 llvm-svn: 192093
This commit is contained in:
parent
6e389a510f
commit
724835dff7
BIN
test/Object/Inputs/program-headers.mips
Executable file
BIN
test/Object/Inputs/program-headers.mips
Executable file
Binary file not shown.
@ -2,6 +2,8 @@ RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.elf-i3
|
||||
RUN: | FileCheck %s -check-prefix ELF-I386
|
||||
RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.elf-x86-64 \
|
||||
RUN: | FileCheck %s -check-prefix ELF-X86-64
|
||||
RUN: llvm-readobj -program-headers %p/../../Object/Inputs/program-headers.mips \
|
||||
RUN: | FileCheck %s -check-prefix ELF-MIPS
|
||||
|
||||
ELF-I386: ProgramHeaders [
|
||||
ELF-I386-NEXT: ProgramHeader {
|
||||
@ -72,3 +74,31 @@ ELF-X86-64-NEXT: ]
|
||||
ELF-X86-64-NEXT: Alignment: 8
|
||||
ELF-X86-64-NEXT: }
|
||||
ELF-X86-64-NEXT: ]
|
||||
|
||||
ELF-MIPS: ProgramHeaders [
|
||||
ELF-MIPS-NEXT: ProgramHeader {
|
||||
ELF-MIPS-NEXT: Type: PT_MIPS_REGINFO (0x70000000)
|
||||
ELF-MIPS-NEXT: Offset: 0x74
|
||||
ELF-MIPS-NEXT: VirtualAddress: 0x400074
|
||||
ELF-MIPS-NEXT: PhysicalAddress: 0x400074
|
||||
ELF-MIPS-NEXT: FileSize: 24
|
||||
ELF-MIPS-NEXT: MemSize: 24
|
||||
ELF-MIPS-NEXT: Flags [ (0x4)
|
||||
ELF-MIPS-NEXT: PF_R (0x4)
|
||||
ELF-MIPS-NEXT: ]
|
||||
ELF-MIPS-NEXT: Alignment: 4
|
||||
ELF-MIPS-NEXT: }
|
||||
ELF-MIPS-NEXT: ProgramHeader {
|
||||
ELF-MIPS-NEXT: Type: PT_LOAD (0x1)
|
||||
ELF-MIPS-NEXT: Offset: 0x0
|
||||
ELF-MIPS-NEXT: VirtualAddress: 0x400000
|
||||
ELF-MIPS-NEXT: PhysicalAddress: 0x400000
|
||||
ELF-MIPS-NEXT: FileSize: 160
|
||||
ELF-MIPS-NEXT: MemSize: 160
|
||||
ELF-MIPS-NEXT: Flags [ (0x5)
|
||||
ELF-MIPS-NEXT: PF_R (0x4)
|
||||
ELF-MIPS-NEXT: PF_X (0x1)
|
||||
ELF-MIPS-NEXT: ]
|
||||
ELF-MIPS-NEXT: Alignment: 65536
|
||||
ELF-MIPS-NEXT: }
|
||||
ELF-MIPS-NEXT: ]
|
||||
|
@ -391,26 +391,41 @@ static const EnumEntry<unsigned> ElfSectionFlags[] = {
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, SHF_MIPS_NOSTRIP )
|
||||
};
|
||||
|
||||
static const EnumEntry<unsigned> ElfSegmentTypes[] = {
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_NULL ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_LOAD ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_DYNAMIC),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_INTERP ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_NOTE ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_SHLIB ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_PHDR ),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_TLS ),
|
||||
static const char *getElfSegmentType(unsigned Arch, unsigned Type) {
|
||||
// Check potentially overlapped processor-specific
|
||||
// program header type.
|
||||
switch (Arch) {
|
||||
case ELF::EM_ARM:
|
||||
switch (Type) {
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_ARM_EXIDX);
|
||||
}
|
||||
case ELF::EM_MIPS:
|
||||
case ELF::EM_MIPS_RS3_LE:
|
||||
switch (Type) {
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_REGINFO);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_RTPROC);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_OPTIONS);
|
||||
}
|
||||
}
|
||||
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_GNU_EH_FRAME),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_SUNW_EH_FRAME),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_SUNW_UNWIND),
|
||||
switch (Type) {
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_NULL );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_LOAD );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_DYNAMIC);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_INTERP );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_NOTE );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_SHLIB );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_PHDR );
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_TLS );
|
||||
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_GNU_STACK),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_GNU_RELRO),
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_EH_FRAME);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_SUNW_UNWIND);
|
||||
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_ARM_EXIDX),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PT_ARM_UNWIND)
|
||||
};
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_STACK);
|
||||
LLVM_READOBJ_ENUM_CASE(ELF, PT_GNU_RELRO);
|
||||
default: return "";
|
||||
}
|
||||
}
|
||||
|
||||
static const EnumEntry<unsigned> ElfSegmentFlags[] = {
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, PF_X),
|
||||
@ -790,7 +805,9 @@ void ELFDumper<ELFT>::printProgramHeaders() {
|
||||
PE = Obj->end_program_headers();
|
||||
PI != PE; ++PI) {
|
||||
DictScope P(W, "ProgramHeader");
|
||||
W.printEnum ("Type", PI->p_type, makeArrayRef(ElfSegmentTypes));
|
||||
W.printHex ("Type",
|
||||
getElfSegmentType(Obj->getHeader()->e_machine, PI->p_type),
|
||||
PI->p_type);
|
||||
W.printHex ("Offset", PI->p_offset);
|
||||
W.printHex ("VirtualAddress", PI->p_vaddr);
|
||||
W.printHex ("PhysicalAddress", PI->p_paddr);
|
||||
|
Loading…
Reference in New Issue
Block a user