ARM: Detect thumb mode elf images.

This commit is contained in:
Gabe Black
2010-06-02 12:58:00 -05:00
parent ebb273bb7b
commit 3951afd2fa
3 changed files with 13 additions and 3 deletions

View 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) {

View File

@@ -53,6 +53,7 @@ class ObjectFile
X86_64,
I386,
Arm,
Thumb,
Power
};

View 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"