X86: Make the loader recognize 32 bit x86 processes.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 16 Feb 2009 07:43:39 +0000 (23:43 -0800)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 16 Feb 2009 07:43:39 +0000 (23:43 -0800)
src/base/loader/elf_object.cc
src/base/loader/object_file.hh
src/sim/process.cc

index edaf323c7be665f569585556229dc44eb978b259..16fc698ddc36f05b9ed4ff79eb10bb076d8eb954 100644 (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 &&
                 ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
-            //In the future, we might want to differentiate between 32 bit
-            //and 64 bit x86 processes in case there are differences in their
-            //initial stack frame.
-            arch = ObjectFile::X86;
+            arch = ObjectFile::X86_64;
+        } else if (ehdr.e_machine == EM_386 &&
+                ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
+            arch = ObjectFile::I386;
         } else if (ehdr.e_ident[EI_CLASS] == ELFCLASS64) {
             arch = ObjectFile::Alpha;
         } else if (ehdr.e_machine == EM_ARM) {
index cc806ca8108af1f5ad9db73b39dd6eeaaafbf64f..d363cde84f2a7b3fc8b0fda25c9af559f33b2bdc 100644 (file)
@@ -50,7 +50,8 @@ class ObjectFile
         SPARC64,
         SPARC32,
         Mips,
-        X86,
+        X86_64,
+        I386,
         Arm
     };
 
index b335d0cf2000d39012cd50edb70b433ef51951c5..7383611c0dbc991d61121b1a1460f4f30d372561 100644 (file)
@@ -708,14 +708,19 @@ LiveProcess::create(LiveProcessParams * params)
         fatal("Unknown/unsupported operating system.");
     }
 #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).");
     switch (objFile->getOpSys()) {
       case ObjectFile::UnknownOpSys:
         warn("Unknown operating system; assuming Linux.");
         // fall through
       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;
 
       default: