X86: Make the loader recognize 32 bit x86 processes.

This commit is contained in:
Gabe Black 2009-02-15 23:43:39 -08:00
parent e0f425bb94
commit 6923282fb5
3 changed files with 13 additions and 7 deletions

View file

@ -89,10 +89,10 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
} }
} else if (ehdr.e_machine == EM_X86_64 && } else if (ehdr.e_machine == EM_X86_64 &&
ehdr.e_ident[EI_CLASS] == ELFCLASS64) { ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
//In the future, we might want to differentiate between 32 bit arch = ObjectFile::X86_64;
//and 64 bit x86 processes in case there are differences in their } else if (ehdr.e_machine == EM_386 &&
//initial stack frame. ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
arch = ObjectFile::X86; arch = ObjectFile::I386;
} else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) { } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
arch = ObjectFile::Alpha; arch = ObjectFile::Alpha;
} else if (ehdr.e_machine == EM_ARM) { } else if (ehdr.e_machine == EM_ARM) {

View file

@ -50,7 +50,8 @@ class ObjectFile
SPARC64, SPARC64,
SPARC32, SPARC32,
Mips, Mips,
X86, X86_64,
I386,
Arm Arm
}; };

View file

@ -708,14 +708,19 @@ LiveProcess::create(LiveProcessParams * params)
fatal("Unknown/unsupported operating system."); fatal("Unknown/unsupported operating system.");
} }
#elif THE_ISA == X86_ISA #elif THE_ISA == X86_ISA
if (objFile->getArch() != ObjectFile::X86) if (objFile->getArch() != ObjectFile::X86_64 &&
objFile->getArch() != ObjectFile::I386)
fatal("Object file architecture does not match compiled ISA (x86)."); fatal("Object file architecture does not match compiled ISA (x86).");
switch (objFile->getOpSys()) { switch (objFile->getOpSys()) {
case ObjectFile::UnknownOpSys: case ObjectFile::UnknownOpSys:
warn("Unknown operating system; assuming Linux."); warn("Unknown operating system; assuming Linux.");
// fall through // fall through
case ObjectFile::Linux: case ObjectFile::Linux:
process = new X86LinuxProcess(params, objFile); if (objFile->getArch() == ObjectFile::X86_64) {
process = new X86LinuxProcess(params, objFile);
} else {
panic("32 bit x86 Linux process aren't implemented.\n");
}
break; break;
default: default: