summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-05-02 22:53:03 -0700
committerGabe Black <gabeblack@google.com>2019-05-20 06:08:24 +0000
commit1e0bb9bcde3eeb5e02dadbef4000498727277cfe (patch)
treea996779bfcea1edc0234a1d23508add85cdb44c6 /src
parentb2b67729f9f6e8bf46bb627b34620f79bf575dca (diff)
downloadgem5-1e0bb9bcde3eeb5e02dadbef4000498727277cfe.tar.xz
mips: Add an object file loader for linux.
Change-Id: Icae6430a210076117cf2ceadce52d6efbe58a5f3 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18586 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/arch/mips/linux/process.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/arch/mips/linux/process.cc b/src/arch/mips/linux/process.cc
index b1c09a5f1..71d20eaae 100644
--- a/src/arch/mips/linux/process.cc
+++ b/src/arch/mips/linux/process.cc
@@ -34,6 +34,7 @@
#include "arch/mips/isa_traits.hh"
#include "arch/mips/linux/linux.hh"
+#include "base/loader/object_file.hh"
#include "base/trace.hh"
#include "cpu/thread_context.hh"
#include "debug/SyscallVerbose.hh"
@@ -47,6 +48,36 @@
using namespace std;
using namespace MipsISA;
+namespace
+{
+
+class MipsLinuxObjectFileLoader : public ObjectFile::Loader
+{
+ public:
+ Process *
+ load(ProcessParams *params, ObjectFile *obj_file) override
+ {
+ if (obj_file->getArch() != ObjectFile::Mips)
+ 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 MipsLinuxProcess(params, obj_file);
+ }
+};
+
+MipsLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
/// Target uname() handler.
static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, Process *process,