[Lldb-commits] [lldb] r216541 - Add support for kalimba architecture variants 3, 4 and 5.

Matthew Gardiner mg11 at csr.com
Wed Aug 27 05:09:40 PDT 2014


Author: mg11
Date: Wed Aug 27 07:09:39 2014
New Revision: 216541

URL: http://llvm.org/viewvc/llvm-project?rev=216541&view=rev
Log:
Add support for kalimba architecture variants 3, 4 and 5.
Add entries to core_definitions and elf_arch_entries for
those variants. Select the subtype for the variant by parsing
the e_flags field of the elf header.

Modified:
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=216541&r1=216540&r2=216541&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Wed Aug 27 07:09:39 2014
@@ -103,6 +103,9 @@ public:
         eCore_uknownMach64,
 
         eCore_kalimba,
+        eCore_kalimba3,
+        eCore_kalimba4,
+        eCore_kalimba5,
 
         kNumCores,
 
@@ -135,7 +138,10 @@ public:
         kCore_x86_64_last   = eCore_x86_64_x86_64h,
 
         kCore_hexagon_first  = eCore_hexagon_generic,
-        kCore_hexagon_last   = eCore_hexagon_hexagonv5
+        kCore_hexagon_last   = eCore_hexagon_hexagonv5,
+
+        kCore_kalimba_first = eCore_kalimba,
+        kCore_kalimba_last = eCore_kalimba5
     };
 
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=216541&r1=216540&r2=216541&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Wed Aug 27 07:09:39 2014
@@ -116,7 +116,10 @@ static const CoreDefinition g_core_defin
     { eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32  , "unknown-mach-32" },
     { eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64  , "unknown-mach-64" },
 
-    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba  , "kalimba" }
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba  , "kalimba" },
+    { eByteOrderBig   , 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba3  , "kalimba3" },
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba4  , "kalimba4" },
+    { eByteOrderLittle, 4, 1, 1 , llvm::Triple::kalimba , ArchSpec::eCore_kalimba5  , "kalimba5" }
 };
 
 // Ensure that we have an entry in the g_core_definitions for each core. If you comment out an entry above,
@@ -258,7 +261,10 @@ static const ArchDefinitionEntry g_elf_a
     { ArchSpec::eCore_x86_64_x86_64   , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // AMD64
     { ArchSpec::eCore_mips64          , llvm::ELF::EM_MIPS   , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // MIPS
     { ArchSpec::eCore_hexagon_generic , llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // HEXAGON
-    { ArchSpec::eCore_kalimba ,         llvm::ELF::EM_CSR_KALIMBA, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }  // KALIMBA
+    { ArchSpec::eCore_kalimba ,         llvm::ELF::EM_CSR_KALIMBA, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA
+    { ArchSpec::eCore_kalimba3 ,        llvm::ELF::EM_CSR_KALIMBA, 3, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA
+    { ArchSpec::eCore_kalimba4 ,        llvm::ELF::EM_CSR_KALIMBA, 4, 0xFFFFFFFFu, 0xFFFFFFFFu },  // KALIMBA
+    { ArchSpec::eCore_kalimba5 ,        llvm::ELF::EM_CSR_KALIMBA, 5, 0xFFFFFFFFu, 0xFFFFFFFFu }  // KALIMBA
 
 };
 
@@ -993,6 +999,16 @@ cores_match (const ArchSpec::Core core1,
         }
         break;
 
+    case ArchSpec::eCore_kalimba:
+    case ArchSpec::eCore_kalimba3:
+    case ArchSpec::eCore_kalimba4:
+    case ArchSpec::eCore_kalimba5:
+        if (core2 >= ArchSpec::kCore_kalimba_first && core2 <= ArchSpec::kCore_kalimba_last)
+        {
+            return true;
+        }
+        break;
+
     default:
         break;
     }

Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=216541&r1=216540&r2=216541&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Wed Aug 27 07:09:39 2014
@@ -258,6 +258,35 @@ ELFNote::Parse(const DataExtractor &data
     return true;
 }
 
+static uint32_t
+kalimbaVariantFromElfFlags(const elf::elf_word e_flags)
+{
+    const uint32_t dsp_rev = e_flags & 0xFF;
+    uint32_t kal_arch_variant = LLDB_INVALID_CPUTYPE;
+    switch(dsp_rev)
+    {
+        // TODO(mg11) Support more variants
+        case 10:
+            kal_arch_variant = 3;
+            break;
+        case 14:
+            kal_arch_variant = 4;
+            break;
+        default:
+            break;           
+    }
+    return kal_arch_variant;
+}
+
+static uint32_t
+subTypeFromElfHeader(const elf::ELFHeader& header)
+{
+    return
+        llvm::ELF::EM_CSR_KALIMBA == header.e_machine ?
+        kalimbaVariantFromElfFlags(header.e_flags) :
+        LLDB_INVALID_CPUTYPE;
+}
+
 // Arbitrary constant used as UUID prefix for core files.
 const uint32_t
 ObjectFileELF::g_core_uuid_magic(0xE210C);
@@ -545,9 +574,12 @@ ObjectFileELF::GetModuleSpecifications (
             {
                 ModuleSpec spec;
                 spec.GetFileSpec() = file;
+
+                const uint32_t sub_type = subTypeFromElfHeader(header);
                 spec.GetArchitecture().SetArchitecture(eArchTypeELF,
                                                        header.e_machine,
-                                                       LLDB_INVALID_CPUTYPE);
+                                                       sub_type);
+
                 if (spec.GetArchitecture().IsValid())
                 {
                     llvm::Triple::OSType ostype;
@@ -1270,7 +1302,9 @@ ObjectFileELF::GetSectionHeaderInfo(Sect
     // We'll refine this with note data as we parse the notes.
     if (arch_spec.GetTriple ().getOS () == llvm::Triple::OSType::UnknownOS)
     {
-        arch_spec.SetArchitecture (eArchTypeELF, header.e_machine, LLDB_INVALID_CPUTYPE);
+        const uint32_t sub_type = subTypeFromElfHeader(header);
+        arch_spec.SetArchitecture (eArchTypeELF, header.e_machine, sub_type);
+
         switch (arch_spec.GetAddressByteSize())
         {
         case 4:





More information about the lldb-commits mailing list