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>
This commit is contained in:
Gabe Black
2019-05-02 22:53:55 -07:00
parent 45518cc26e
commit 8110bd95bf
2 changed files with 62 additions and 0 deletions

View 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"
@@ -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)
{

View 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"
@@ -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