mips: Add an object file loader for linux.
authorGabe Black <gabeblack@google.com>
Fri, 3 May 2019 05:53:03 +0000 (22:53 -0700)
committerGabe Black <gabeblack@google.com>
Mon, 20 May 2019 06:08:24 +0000 (06:08 +0000)
Change-Id: Icae6430a210076117cf2ceadce52d6efbe58a5f3
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18586
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/mips/linux/process.cc

index b1c09a5f1cbea4b29b1f65f3821c6c8e6697439c..71d20eaaec577675f547554fc16243c102532533 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "arch/mips/isa_traits.hh"
 #include "arch/mips/linux/linux.hh"
+#include "base/loader/object_file.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "debug/SyscallVerbose.hh"
 using namespace std;
 using namespace MipsISA;
 
+namespace
+{
+
+class MipsLinuxObjectFileLoader : public ObjectFile::Loader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        if (obj_file->getArch() != ObjectFile::Mips)
+            return nullptr;
+
+        auto opsys = obj_file->getOpSys();
+
+        if (opsys == ObjectFile::UnknownOpSys) {
+            warn("Unknown operating system; assuming Linux.");
+            opsys = ObjectFile::Linux;
+        }
+
+        if (opsys != ObjectFile::Linux)
+            return nullptr;
+
+        return new MipsLinuxProcess(params, obj_file);
+    }
+};
+
+MipsLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
 /// Target uname() handler.
 static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, Process *process,