diff options
-rw-r--r-- | lldb/include/lldb/Core/ArchSpec.h | 11 | ||||
-rw-r--r-- | lldb/source/Core/ArchSpec.cpp | 12 | ||||
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 29 |
3 files changed, 44 insertions, 8 deletions
diff --git a/lldb/include/lldb/Core/ArchSpec.h b/lldb/include/lldb/Core/ArchSpec.h index 1df388888b8..012372de2a4 100644 --- a/lldb/include/lldb/Core/ArchSpec.h +++ b/lldb/include/lldb/Core/ArchSpec.h @@ -69,6 +69,9 @@ public: eMIPSABI_O32 = 0x00002000, eMIPSABI_N32 = 0x00004000, eMIPSABI_N64 = 0x00008000, + eMIPSABI_O64 = 0x00020000, + eMIPSABI_EABI32 = 0x00040000, + eMIPSABI_EABI64 = 0x00080000, eMIPSABI_mask = 0x000ff000 }; @@ -289,6 +292,14 @@ public: const char * GetArchitectureName () const; + //----------------------------------------------------------------- + /// if MIPS architecture return true. + /// + /// @return a boolean value. + //----------------------------------------------------------------- + bool + IsMIPS() const; + //------------------------------------------------------------------ /// Returns a string representing current architecture as a target CPU /// for tools like compiler, disassembler etc. diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index 4c5971935ef..24aba81350a 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -507,6 +507,18 @@ ArchSpec::GetArchitectureName () const return "unknown"; } +bool +ArchSpec::IsMIPS() const +{ + const llvm::Triple::ArchType machine = GetMachine(); + if(machine == llvm::Triple::mips || + machine == llvm::Triple::mipsel || + machine == llvm::Triple::mips64 || + machine == llvm::Triple::mips64el) + return true; + return false; +} + std::string ArchSpec::GetClangTargetCPU () { diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index a8bbda13aa3..fe299b17f59 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -1697,8 +1697,7 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, I->section_name = name; - if (arch_spec.GetMachine() == llvm::Triple::mips || arch_spec.GetMachine() == llvm::Triple::mipsel - || arch_spec.GetMachine() == llvm::Triple::mips64 || arch_spec.GetMachine() == llvm::Triple::mips64el) + if (arch_spec.IsMIPS()) { uint32_t arch_flags = arch_spec.GetFlags (); DataExtractor data; @@ -1712,13 +1711,27 @@ ObjectFileELF::GetSectionHeaderInfo(SectionHeaderColl §ion_headers, } } // Settings appropriate ArchSpec ABI Flags - if (header.e_flags & llvm::ELF::EF_MIPS_ABI2) + switch(header.e_flags & llvm::ELF::EF_MIPS_ABI) { - arch_flags |= lldb_private::ArchSpec::eMIPSABI_N32; - } - else if (header.e_flags & llvm::ELF::EF_MIPS_ABI_O32) - { - arch_flags |= lldb_private::ArchSpec::eMIPSABI_O32; + case llvm::ELF::EF_MIPS_ABI_O32: + arch_flags |= lldb_private::ArchSpec::eMIPSABI_O32; + break; + case EF_MIPS_ABI_O64: + arch_flags |= lldb_private::ArchSpec::eMIPSABI_O64; + break; + case EF_MIPS_ABI_EABI32: + arch_flags |= lldb_private::ArchSpec::eMIPSABI_EABI32; + break; + case EF_MIPS_ABI_EABI64: + arch_flags |= lldb_private::ArchSpec::eMIPSABI_EABI64; + break; + default: + // ABI Mask doesn't cover N32 and N64 ABI. + if (header.e_ident[EI_CLASS] == llvm::ELF::ELFCLASS64) + arch_flags |= lldb_private::ArchSpec::eMIPSABI_N64; + else if (header.e_flags && llvm::ELF::EF_MIPS_ABI2) + arch_flags |= lldb_private::ArchSpec::eMIPSABI_N32; + break; } arch_spec.SetFlags (arch_flags); } |