diff options
author | Gabe Black <gabeblack@google.com> | 2019-05-02 22:53:41 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-05-20 06:08:24 +0000 |
commit | 45518cc26e02ed217c9a46c6978fe2fa64d4d7f2 (patch) | |
tree | 8b6d4780f712bc163c7686d9a9f1d30dfc712e45 | |
parent | 5ab2ffd3816887b92ecb369e8e42cc03ea43d7be (diff) | |
download | gem5-45518cc26e02ed217c9a46c6978fe2fa64d4d7f2.tar.xz |
riscv: Add an object file loader for linux.
Change-Id: I3accca91cc4e02fa8e3a1169590cbe6696cf05e2
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18628
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alec Roelke <alec.roelke@gmail.com>
Maintainer: Alec Roelke <alec.roelke@gmail.com>
-rw-r--r-- | src/arch/riscv/linux/process.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/arch/riscv/linux/process.cc b/src/arch/riscv/linux/process.cc index 72399201e..b2d030523 100644 --- a/src/arch/riscv/linux/process.cc +++ b/src/arch/riscv/linux/process.cc @@ -38,6 +38,7 @@ #include "arch/riscv/isa_traits.hh" #include "arch/riscv/linux/linux.hh" +#include "base/loader/object_file.hh" #include "base/trace.hh" #include "cpu/thread_context.hh" #include "debug/SyscallVerbose.hh" @@ -51,6 +52,40 @@ using namespace std; using namespace RiscvISA; +namespace +{ + +class RiscvLinuxObjectFileLoader : 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::Riscv64 && arch != ObjectFile::Riscv32) + return nullptr; + + if (opsys == ObjectFile::UnknownOpSys) { + warn("Unknown operating system; assuming Linux."); + opsys = ObjectFile::Linux; + } + + if (opsys != ObjectFile::Linux) + return nullptr; + + if (arch == ObjectFile::Riscv64) + return new RiscvLinuxProcess64(params, obj_file); + else + return new RiscvLinuxProcess32(params, obj_file); + } +}; + +RiscvLinuxObjectFileLoader loader; + +} // anonymous namespace + /// Target uname() handler. static SyscallReturn unameFunc64(SyscallDesc *desc, int callnum, Process *process, |