Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/18585

Change subject: arm: Add an object file loader for linux and freebsd.
......................................................................

arm: Add an object file loader for linux and freebsd.

Change-Id: Ie5fd187a4897aa608ffc12278b23d3ee8c0f323c
---
M src/arch/arm/freebsd/process.cc
M src/arch/arm/linux/process.cc
2 files changed, 74 insertions(+), 0 deletions(-)



diff --git a/src/arch/arm/freebsd/process.cc b/src/arch/arm/freebsd/process.cc
index e6aa740..bf765a8 100644
--- a/src/arch/arm/freebsd/process.cc
+++ b/src/arch/arm/freebsd/process.cc
@@ -41,6 +41,7 @@

 #include "arch/arm/freebsd/freebsd.hh"
 #include "arch/arm/isa_traits.hh"
+#include "base/loader/loader.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/freebsd/freebsd.hh"
@@ -52,6 +53,37 @@
 using namespace std;
 using namespace ArmISA;

+namespace
+{
+
+class ArmFreebsdObjectFileLoader : public ObjectFileLoader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        auto arch = obj_file->getArch();
+        auto opsys = obj_file->getOpSys();
+
+        if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
+                arch != ObjectFile::Arm64) {
+            return nullptr;
+        }
+
+        if (opsys != ObjectFile::FreeBSD)
+            return nullptr;
+
+        if (arch == ObjectFile::Arm64)
+            return new ArmFreebsdProcess64(params, obj_file, arch);
+        else
+            return new ArmFreebsdProcess32(params, obj_file, arch);
+    }
+};
+
+ArmFreebsdObjectFileLoader loader;
+
+} // anonymous namespace
+
 static SyscallReturn
 issetugidFunc(SyscallDesc *desc, int callnum, Process *process,
               ThreadContext *tc)
diff --git a/src/arch/arm/linux/process.cc b/src/arch/arm/linux/process.cc
index 99f4b2c..0641b11 100644
--- a/src/arch/arm/linux/process.cc
+++ b/src/arch/arm/linux/process.cc
@@ -50,6 +50,7 @@

 #include "arch/arm/isa_traits.hh"
 #include "arch/arm/linux/linux.hh"
+#include "base/loader/loader.hh"
 #include "base/trace.hh"
 #include "cpu/thread_context.hh"
 #include "kern/linux/linux.hh"
@@ -61,6 +62,47 @@
 using namespace std;
 using namespace ArmISA;

+namespace
+{
+
+class ArmLinuxObjectFileLoader : public ObjectFileLoader
+{
+  public:
+    Process *
+    load(ProcessParams *params, ObjectFile *obj_file) override
+    {
+        auto arch = obj_file->getArch();
+        auto opsys = obj_file->getOpSys();
+
+        if (arch != ObjectFile::Arm && arch != ObjectFile::Thumb &&
+                arch != ObjectFile::Arm64) {
+            return nullptr;
+        }
+
+        if (opsys == ObjectFile::UnknownOpSys) {
+            warn("Unknown operating system; assuming Linux.");
+            opsys = ObjectFile::Linux;
+        }
+
+        if (opsys == ObjectFile::LinuxArmOABI) {
+ fatal("gem5 does not support ARM OABI binaries. Please recompile "
+                    "with an EABI compiler.");
+        }
+
+        if (opsys != ObjectFile::Linux)
+            return nullptr;
+
+        if (arch == ObjectFile::Arm64)
+            return new ArmLinuxProcess64(params, obj_file, arch);
+        else
+            return new ArmLinuxProcess32(params, obj_file, arch);
+    }
+};
+
+ArmLinuxObjectFileLoader loader;
+
+} // anonymous namespace
+
 /// Target uname() handler.
 static SyscallReturn
 unameFunc32(SyscallDesc *desc, int callnum, Process *process,

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/18585
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: Ie5fd187a4897aa608ffc12278b23d3ee8c0f323c
Gerrit-Change-Number: 18585
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to