diff options
author | Nitesh Jain <nitesh.jain@imgtec.com> | 2017-03-31 11:06:25 +0000 |
---|---|---|
committer | Nitesh Jain <nitesh.jain@imgtec.com> | 2017-03-31 11:06:25 +0000 |
commit | 706c5205584acc65b1140968e6197165f525c487 (patch) | |
tree | 51ca75efe82613a212c01d89dd2cd17dd8198220 /lldb/source/Plugins/ObjectFile | |
parent | 750bde62ddaa12ac5ec81d7568f697868f2c6607 (diff) | |
download | bcm5719-llvm-706c5205584acc65b1140968e6197165f525c487.tar.gz bcm5719-llvm-706c5205584acc65b1140968e6197165f525c487.zip |
[LLDB][MIPS] Fix Core file Architecture and OS information.
Reviewers: labath, clayborg
Subscribers: jaydeep, bhushan, lldb-commits, slthakur
Differential Revision: https://reviews.llvm.org/D31280
llvm-svn: 299199
Diffstat (limited to 'lldb/source/Plugins/ObjectFile')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index a218782b32f..6e2001b2163 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -288,10 +288,26 @@ static uint32_t kalimbaVariantFromElfFlags(const elf::elf_word e_flags) { return kal_arch_variant; } -static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags, - uint32_t endian) { - const uint32_t mips_arch = e_flags & llvm::ELF::EF_MIPS_ARCH; +static uint32_t mipsVariantFromElfFlags (const elf::ELFHeader &header) { + const uint32_t mips_arch = header.e_flags & llvm::ELF::EF_MIPS_ARCH; + uint32_t endian = header.e_ident[EI_DATA]; uint32_t arch_variant = ArchSpec::eMIPSSubType_unknown; + uint32_t fileclass = header.e_ident[EI_CLASS]; + + // If there aren't any elf flags available (e.g core elf file) then return default + // 32 or 64 bit arch (without any architecture revision) based on object file's class. + if (header.e_type == ET_CORE) { + switch (fileclass) { + case llvm::ELF::ELFCLASS32: + return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips32el + : ArchSpec::eMIPSSubType_mips32; + case llvm::ELF::ELFCLASS64: + return (endian == ELFDATA2LSB) ? ArchSpec::eMIPSSubType_mips64el + : ArchSpec::eMIPSSubType_mips64; + default: + return arch_variant; + } + } switch (mips_arch) { case llvm::ELF::EF_MIPS_ARCH_1: @@ -326,7 +342,7 @@ static uint32_t mipsVariantFromElfFlags(const elf::elf_word e_flags, static uint32_t subTypeFromElfHeader(const elf::ELFHeader &header) { if (header.e_machine == llvm::ELF::EM_MIPS) - return mipsVariantFromElfFlags(header.e_flags, header.e_ident[EI_DATA]); + return mipsVariantFromElfFlags(header); return llvm::ELF::EM_CSR_KALIMBA == header.e_machine ? kalimbaVariantFromElfFlags(header.e_flags) @@ -1349,6 +1365,10 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, } break; } + if (arch_spec.IsMIPS() && + arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS) + // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform + arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } // Process NetBSD ELF notes. else if ((note.n_name == LLDB_NT_OWNER_NETBSD) && @@ -1450,6 +1470,12 @@ ObjectFileELF::RefineModuleDetailsFromNote(lldb_private::DataExtractor &data, break; } } + if (arch_spec.IsMIPS() && + arch_spec.GetTriple().getOS() == llvm::Triple::OSType::UnknownOS) + // In case of MIPSR6, the LLDB_NT_OWNER_GNU note is missing + // for some cases (e.g. compile with -nostdlib) + // Hence set OS to Linux + arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux); } } |