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

index 664b93bde78f49f6f0c3f11f88d559064f4bb72e..ea0fc90212c97e62b4ce0da13651b2ec5c7263e4 100644 (file)
@@ -36,6 +36,7 @@
 
 #include "arch/power/isa_traits.hh"
 #include "arch/power/linux/linux.hh"
+#include "base/loader/object_file.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
 using namespace std;
 using namespace PowerISA;
 
+namespace
+{
+
+class PowerLinuxObjectFileLoader : public ObjectFile::Loader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        if (obj_file->getArch() != ObjectFile::Power)
+            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 PowerLinuxProcess(params, obj_file);
+    }
+};
+
+PowerLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
 /// Target uname() handler.
 static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, Process *process,