ARM: Detect thumb mode elf images.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:00 +0000 (12:58 -0500)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 2 Jun 2010 17:58:00 +0000 (12:58 -0500)
src/base/loader/elf_object.cc
src/base/loader/object_file.hh
src/sim/process.cc

index 60f0f99b49b3e8ba8d68f573afafe2a76388ef41..6096cb2e3665c80264f13796bfa0e661b73a5e1a 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "gelf.h"
 
+#include "base/bitfield.hh"
 #include "base/loader/elf_object.hh"
 #include "base/loader/symtab.hh"
 #include "base/misc.hh"
@@ -96,7 +97,11 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
         } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
             arch = ObjectFile::Alpha;
         } else if (ehdr.e_machine == EM_ARM) {
-            arch = ObjectFile::Arm;
+            if (bits(ehdr.e_entry, 0)) {
+                arch = ObjectFile::Thumb;
+            } else {
+                arch = ObjectFile::Arm;
+            }
         } else if (ehdr.e_machine == EM_PPC &&
                 ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
           if (ehdr.e_ident[EI_DATA] == ELFDATA2MSB) {
index b08f1c633b810ab35988d38f7a2fb0be43d0089d..bffab0cc5aecaa2a927fa4486d14efd8064f7665 100644 (file)
@@ -53,6 +53,7 @@ class ObjectFile
         X86_64,
         I386,
         Arm,
+        Thumb,
         Power
     };
 
index 957c3cc3e0805b2df877adaa923b55e4d32fb8ff..18f33abdce152243ab0c7d43b8cb9fc3faaf3fd0 100644 (file)
@@ -755,14 +755,18 @@ LiveProcess::create(LiveProcessParams * params)
         fatal("Unknown/unsupported operating system.");
     }
 #elif THE_ISA == ARM_ISA
-    if (objFile->getArch() != ObjectFile::Arm)
+    if (objFile->getArch() != ObjectFile::Arm &&
+        objFile->getArch() != ObjectFile::Thumb)
         fatal("Object file architecture does not match compiled ISA (ARM).");
     switch (objFile->getOpSys()) {
       case ObjectFile::UnknownOpSys:
         warn("Unknown operating system; assuming Linux.");
         // fall through
       case ObjectFile::Linux:
-        process = new ArmLinuxProcess(params, objFile);
+        if (objFile->getArch() == ObjectFile::Thumb)
+            panic("Thumb processes not yet supported.\n");
+        else
+            process = new ArmLinuxProcess(params, objFile);
         break;
       case ObjectFile::LinuxArmOABI:
         fatal("M5 does not support ARM OABI binaries. Please recompile with an"