From 8110bd95bf112a5d2f9d2850062e08e5d4b6baab Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 2 May 2019 22:53:55 -0700 Subject: 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 Maintainer: Gabe Black Tested-by: kokoro --- src/arch/sparc/linux/process.cc | 35 +++++++++++++++++++++++++++++++++++ src/arch/sparc/solaris/process.cc | 27 +++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'src/arch/sparc') 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 -- cgit v1.2.3