MIPS: Check endianness of binaries in SE mode.
authorGabe Black <gblack@eecs.umich.edu>
Thu, 20 Mar 2008 06:10:21 +0000 (02:10 -0400)
committerGabe Black <gblack@eecs.umich.edu>
Thu, 20 Mar 2008 06:10:21 +0000 (02:10 -0400)
--HG--
extra : convert_revision : e6c4bda6078eb68a26f8834411f744078c6bf5a9

src/base/loader/elf_object.cc

index 8e41ffd16f0f7f3def84b6b73fd4913fb5bfce6f..4c3f694e53b3587379c908b80d27057ca1d1d9ca 100644 (file)
@@ -79,7 +79,13 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
             arch = ObjectFile::SPARC32;
         } else if (ehdr.e_machine == EM_MIPS
                 && ehdr.e_ident[EI_CLASS] == ELFCLASS32) {
-            arch = ObjectFile::Mips;
+            if (ehdr.e_ident[EI_DATA] == ELFDATA2LSB) {
+                arch = ObjectFile::Mips;
+            } else {
+                fatal("The binary you're trying to load is compiled for big "
+                        "endian MIPS. M5\nonly supports little endian MIPS. "
+                        "Please recompile your binary.\n");
+            }
         } 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