summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-01 11:07:19 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-01 11:07:19 +0000
commited37b773e1bc87a7e5280943e60451f4adc5abcb (patch)
treee64ab4afdc256a11194ef0b24b267de21c02ef77
parentb6fdca612dedef69d7f5d9a40c36c37f0f7cfb47 (diff)
[llvm-readobj] Add support for Mips specific ELF header e_flags.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207744 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml9
-rw-r--r--tools/llvm-readobj/ELFDumper.cpp30
2 files changed, 34 insertions, 5 deletions
diff --git a/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml b/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml
index 19cc91e235c..7d098077dd5 100644
--- a/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml
+++ b/test/Object/yaml2obj-elf-file-headers-with-e_flags.yaml
@@ -5,12 +5,13 @@ FileHeader:
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
- Flags: [ EF_MIPS_NOREORDER, EF_MIPS_ABI_O32 ]
+ Flags: [ EF_MIPS_NOREORDER, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R2 ]
# CHECK: Format: ELF32-mips
# CHECK: Arch: mipsel
# CHECK: Machine: EM_MIPS
-# CHECK: Flags [ (0x1001)
-# CHECK-NEXT: 0x1
-# CHECK-NEXT: 0x1000
+# CHECK: Flags [ (0x70001001)
+# CHECK-NEXT: EF_MIPS_ABI_O32 (0x1000)
+# CHECK-NEXT: EF_MIPS_ARCH_32R2 (0x70000000)
+# CHECK-NEXT: EF_MIPS_NOREORDER (0x1)
# CHECK-NEXT: ]
diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp
index ab898327ca2..21f9866035f 100644
--- a/tools/llvm-readobj/ELFDumper.cpp
+++ b/tools/llvm-readobj/ELFDumper.cpp
@@ -437,6 +437,27 @@ static const EnumEntry<unsigned> ElfSegmentFlags[] = {
LLVM_READOBJ_ENUM_ENT(ELF, PF_R)
};
+static const EnumEntry<unsigned> ElfHeaderMipsFlags[] = {
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_NOREORDER),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_PIC),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_CPIC),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI2),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_32BITMODE),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_NAN2008),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_O32),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MICROMIPS),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_ASE_M16),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_1),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_2),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_3),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_4),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_5),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_32),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_64),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_32R2),
+ LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_64R2)
+};
+
template<class ELFT>
void ELFDumper<ELFT>::printFileHeaders() {
const typename ELFO::Elf_Ehdr *Header = Obj->getHeader();
@@ -464,7 +485,14 @@ void ELFDumper<ELFT>::printFileHeaders() {
W.printHex ("Entry", Header->e_entry);
W.printHex ("ProgramHeaderOffset", Header->e_phoff);
W.printHex ("SectionHeaderOffset", Header->e_shoff);
- W.printFlags ("Flags", Header->e_flags);
+ switch (Header->e_machine) {
+ case EM_MIPS:
+ W.printFlags("Flags", Header->e_flags, makeArrayRef(ElfHeaderMipsFlags),
+ unsigned(ELF::EF_MIPS_ARCH));
+ break;
+ default:
+ W.printFlags("Flags", Header->e_flags);
+ }
W.printNumber("HeaderSize", Header->e_ehsize);
W.printNumber("ProgramHeaderEntrySize", Header->e_phentsize);
W.printNumber("ProgramHeaderCount", Header->e_phnum);