[LLDB][MIPS] Detect MIPS application specific extensions like micromips
SUMMARY:
The patch detects MIPS application specific extensions (ASE) like micromips by reading
ELF header.e_flags and SHT_MIPS_ABIFLAGS section. MIPS triple does not contain ASE
information like micromips, mips16, DSP, MSA etc. These can be read from header.e_flags
or SHT_MIPS_ABIFLAGS section.
Reviewers: clayborg
Subscribers: mohit.bhakkad, sagar, lldb-commits
Differential Revision: http://reviews.llvm.org/D11133
llvm-svn: 242381
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 5fc83f0..789fd49 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1437,6 +1437,25 @@
assert(spec_ostype == ostype);
}
+ 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)
+ {
+ switch (header.e_flags & llvm::ELF::EF_MIPS_ARCH_ASE)
+ {
+ case llvm::ELF::EF_MIPS_MICROMIPS:
+ arch_spec.SetFlags (ArchSpec::eMIPSAse_micromips);
+ break;
+ case llvm::ELF::EF_MIPS_ARCH_ASE_M16:
+ arch_spec.SetFlags (ArchSpec::eMIPSAse_mips16);
+ break;
+ case llvm::ELF::EF_MIPS_ARCH_ASE_MDMX:
+ arch_spec.SetFlags (ArchSpec::eMIPSAse_mdmx);
+ break;
+ default:
+ break;
+ }
+ }
+
// If there are no section headers we are done.
if (header.e_shnum == 0)
return 0;
@@ -1483,6 +1502,22 @@
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 (header.sh_type == SHT_MIPS_ABIFLAGS)
+ {
+ DataExtractor data;
+ if (section_size && (data.SetData (object_data, header.sh_offset, section_size) == section_size))
+ {
+ lldb::offset_t ase_offset = 12; // MIPS ABI Flags Version: 0
+ uint32_t arch_flags = arch_spec.GetFlags ();
+ arch_flags |= data.GetU32 (&ase_offset);
+ arch_spec.SetFlags (arch_flags);
+ }
+ }
+ }
+
if (name == g_sect_name_gnu_debuglink)
{
DataExtractor data;