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

index d12f130483636ccdb8df0b3145b635fc9df56dff..2fd9838084e69c39cbe9cbdac1edc18641edfd21 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "arch/sparc/isa_traits.hh"
 #include "arch/sparc/registers.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 SparcISA;
 
+namespace
+{
+
+class SparcLinuxObjectFileLoader : public ObjectFile::Loader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        auto arch = obj_file->getArch();
+        auto opsys = obj_file->getOpSys();
+
+        if (arch != ObjectFile::SPARC64 && arch != ObjectFile::SPARC32)
+            return nullptr;
+
+        if (opsys == ObjectFile::UnknownOpSys) {
+            warn("Unknown operating system; assuming Linux.");
+            opsys = ObjectFile::Linux;
+        }
+
+        if (opsys != ObjectFile::Linux)
+            return nullptr;
+
+        if (arch == ObjectFile::SPARC64)
+            return new Sparc64LinuxProcess(params, obj_file);
+        else
+            return new Sparc32LinuxProcess(params, obj_file);
+    }
+};
+
+SparcLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
 SyscallDesc*
 SparcLinuxProcess::getDesc(int callnum)
 {
index bcdd08814c442d1d1041226b570e72121c0267d3..70381c5d82ca9294a46c20b807d2c744884307fd 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "arch/sparc/isa_traits.hh"
 #include "arch/sparc/registers.hh"
+#include "base/loader/object_file.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/solaris/solaris.hh"
 using namespace std;
 using namespace SparcISA;
 
+namespace
+{
+
+class SparcSolarisObjectFileLoader : public ObjectFile::Loader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        auto arch = obj_file->getArch();
+        auto opsys = obj_file->getOpSys();
+
+        if (arch != ObjectFile::SPARC64 && arch != ObjectFile::SPARC32)
+            return nullptr;
+
+        if (opsys != ObjectFile::Solaris)
+            return nullptr;
+
+        return new SparcSolarisProcess(params, obj_file);
+    }
+};
+
+SparcSolarisObjectFileLoader loader;
+
+} // anonymous namespace
+
 
 /// Target uname() handler.
 static SyscallReturn