From a758825238b44774f974f3760d80b44c3ca78480 Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Thu, 1 May 2014 11:07:19 +0000 Subject: [PATCH] [llvm-readobj] Add support for Mips specific ELF header e_flags. llvm-svn: 207744 --- ...aml2obj-elf-file-headers-with-e_flags.yaml | 9 +++--- tools/llvm-readobj/ELFDumper.cpp | 30 ++++++++++++++++++- 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 ElfSegmentFlags[] = { LLVM_READOBJ_ENUM_ENT(ELF, PF_R) }; +static const EnumEntry 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 void ELFDumper::printFileHeaders() { const typename ELFO::Elf_Ehdr *Header = Obj->getHeader(); @@ -464,7 +485,14 @@ void ELFDumper::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);