summaryrefslogtreecommitdiff
path: root/src/arch/sparc
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-05-02 22:53:55 -0700
committerGabe Black <gabeblack@google.com>2019-05-20 06:08:24 +0000
commit8110bd95bf112a5d2f9d2850062e08e5d4b6baab (patch)
tree3c91421b4433d6d57e7b17aa83d6869e9af77189 /src/arch/sparc
parent45518cc26e02ed217c9a46c6978fe2fa64d4d7f2 (diff)
downloadgem5-8110bd95bf112a5d2f9d2850062e08e5d4b6baab.tar.xz
sparc: Add an object file loader for linux and solaris.
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>
Diffstat (limited to 'src/arch/sparc')
-rw-r--r--src/arch/sparc/linux/process.cc35
-rw-r--r--src/arch/sparc/solaris/process.cc27
2 files changed, 62 insertions, 0 deletions
diff --git a/src/arch/sparc/linux/process.cc b/src/arch/sparc/linux/process.cc
index d12f13048..2fd983808 100644
--- a/src/arch/sparc/linux/process.cc
+++ b/src/arch/sparc/linux/process.cc
@@ -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"
@@ -44,6 +45,40 @@
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)
{
diff --git a/src/arch/sparc/solaris/process.cc b/src/arch/sparc/solaris/process.cc
index bcdd08814..70381c5d8 100644
--- a/src/arch/sparc/solaris/process.cc
+++ b/src/arch/sparc/solaris/process.cc
@@ -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"
@@ -42,6 +43,32 @@
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