summaryrefslogtreecommitdiff
path: root/tools/llvm-readobj/ELFDumper.cpp
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2013-10-07 08:58:27 +0000
committerSimon Atanasyan <simon@atanasyan.com>2013-10-07 08:58:27 +0000
commitc84c742eddc0c57c34271471f332c9857d79e672 (patch)
tree2f62762bb00d6e909a1a226d397179320ab2c759 /tools/llvm-readobj/ELFDumper.cpp
parente778f82a1e33826ab012bb970a406c9acf37349b (diff)
[Mips] Teach llvm-readobj to print MIPS-specific ELF program headers.
The patch reviewed by Michael Spencer. http://llvm-reviews.chandlerc.com/D1846 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-readobj/ELFDumper.cpp')
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index ffa0e01425e..f384824d5ed 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -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 ),
-
- 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),
-
- LLVM_READOBJ_ENUM_ENT(ELF, PT_GNU_STACK),
- LLVM_READOBJ_ENUM_ENT(ELF, PT_GNU_RELRO),
-
- LLVM_READOBJ_ENUM_ENT(ELF, PT_ARM_EXIDX),
- LLVM_READOBJ_ENUM_ENT(ELF, PT_ARM_UNWIND)
-};
+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);
+ }
+ }
+
+ 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_CASE(ELF, PT_GNU_EH_FRAME);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_SUNW_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);