diff options
author | Gabe Black <gabeblack@google.com> | 2019-05-02 22:54:08 -0700 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2019-05-20 06:08:24 +0000 |
commit | 50f85394b36fb7fd186d0137f11bf416f65d080f (patch) | |
tree | 6539ec1d79a8a9544354005ff7efb8fd9e4e431a /src/arch | |
parent | 8110bd95bf112a5d2f9d2850062e08e5d4b6baab (diff) | |
download | gem5-50f85394b36fb7fd186d0137f11bf416f65d080f.tar.xz |
x86: Add an object file loader for linux.
Change-Id: I283dd1f52fd020ad3c226eb00fc9216ee034c67f
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18630
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')
-rw-r--r-- | src/arch/x86/linux/process.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/arch/x86/linux/process.cc b/src/arch/x86/linux/process.cc index f19dce358..95f4ee91d 100644 --- a/src/arch/x86/linux/process.cc +++ b/src/arch/x86/linux/process.cc @@ -44,6 +44,7 @@ #include "arch/x86/isa_traits.hh" #include "arch/x86/linux/linux.hh" #include "arch/x86/registers.hh" +#include "base/loader/object_file.hh" #include "base/trace.hh" #include "cpu/thread_context.hh" #include "kern/linux/linux.hh" @@ -54,6 +55,40 @@ using namespace std; using namespace X86ISA; +namespace +{ + +class X86LinuxObjectFileLoader : 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::X86_64 && arch != ObjectFile::I386) + return nullptr; + + if (opsys == ObjectFile::UnknownOpSys) { + warn("Unknown operating system; assuming Linux."); + opsys = ObjectFile::Linux; + } + + if (opsys != ObjectFile::Linux) + return nullptr; + + if (arch == ObjectFile::X86_64) + return new X86_64LinuxProcess(params, obj_file); + else + return new I386LinuxProcess(params, obj_file); + } +}; + +X86LinuxObjectFileLoader loader; + +} // anonymous namespace + /// Target uname() handler. static SyscallReturn unameFunc(SyscallDesc *desc, int callnum, Process *process, |