alpha: Add an object file loader for linux.
authorGabe Black <gabeblack@google.com>
Fri, 3 May 2019 05:52:23 +0000 (22:52 -0700)
committerGabe Black <gabeblack@google.com>
Sat, 18 May 2019 18:28:12 +0000 (18:28 +0000)
Change-Id: I91c4019567bdf74b2517fda597121a6ad107cb86
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18584
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/arch/alpha/linux/process.cc

index c1162bad0d810c6a842e2c79602747d13d7e60d7..cbf45f16ceec78128206466c490bf4fba56c7846 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "arch/alpha/isa_traits.hh"
 #include "arch/alpha/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 AlphaISA;
 
+namespace
+{
+
+class AlphaLinuxObjectFileLoader : public ObjectFile::Loader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        if (obj_file->getArch() != ObjectFile::Alpha)
+            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 AlphaLinuxProcess(params, obj_file);
+    }
+};
+
+AlphaLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
 /// Target uname() handler.
 static SyscallReturn
 unameFunc(SyscallDesc *desc, int callnum, Process *process,