summaryrefslogtreecommitdiff
path: root/src/base/loader
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2019-10-04 01:21:24 -0700
committerGabe Black <gabeblack@google.com>2019-10-16 01:36:33 +0000
commite35b491c464f8961f5f3fff56478f12716f5a424 (patch)
treef3748c86e0d5b844fd6e8babc41c8d8175f853c7 /src/base/loader
parent245422102c049cc744d695103ead1caa9d9870ca (diff)
downloadgem5-e35b491c464f8961f5f3fff56478f12716f5a424.tar.xz
arch,base,sim: Move Process loader hooks into the Process class.
This code was originally in the ObjectFile class, but not all object files will become Processes. All Processes will ultimately come from ObjectFiles though, so it makes more sense to put that class there. Change-Id: Ie73e4cdecbb51ce53d24cf68911a6cfc0685d771 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21468 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Gabe Black <gabeblack@google.com>
Diffstat (limited to 'src/base/loader')
-rw-r--r--src/base/loader/object_file.cc31
-rw-r--r--src/base/loader/object_file.hh34
2 files changed, 0 insertions, 65 deletions
diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc
index b7e05428c..10c927125 100644
--- a/src/base/loader/object_file.cc
+++ b/src/base/loader/object_file.cc
@@ -42,37 +42,6 @@ using namespace std;
ObjectFile::ObjectFile(ImageFileDataPtr ifd) : ImageFile(ifd) {}
-namespace
-{
-
-typedef std::vector<ObjectFile::Loader *> LoaderList;
-
-LoaderList &
-object_file_loaders()
-{
- static LoaderList loaders;
- return loaders;
-}
-
-} // anonymous namespace
-
-ObjectFile::Loader::Loader()
-{
- object_file_loaders().emplace_back(this);
-}
-
-Process *
-ObjectFile::tryLoaders(ProcessParams *params, ObjectFile *obj_file)
-{
- for (auto &loader: object_file_loaders()) {
- Process *p = loader->load(params, obj_file);
- if (p)
- return p;
- }
-
- return nullptr;
-}
-
namespace {
typedef std::vector<ObjectFileFormat *> ObjectFileFormatList;
diff --git a/src/base/loader/object_file.hh b/src/base/loader/object_file.hh
index da35db148..0c279c933 100644
--- a/src/base/loader/object_file.hh
+++ b/src/base/loader/object_file.hh
@@ -40,8 +40,6 @@
#include "base/logging.hh"
#include "base/types.hh"
-class Process;
-class ProcessParams;
class SymbolTable;
class ObjectFile : public ImageFile
@@ -131,38 +129,6 @@ class ObjectFile : public ImageFile
public:
Addr entryPoint() const { return entry; }
-
- /**
- * Each instance of a Loader subclass will have a chance to try to load
- * an object file when tryLoaders is called. If they can't because they
- * aren't compatible with it (wrong arch, wrong OS, etc), then they
- * silently fail by returning nullptr so other loaders can try.
- */
- class Loader
- {
- public:
- Loader();
-
- /* Loader instances are singletons. */
- Loader(const Loader &) = delete;
- void operator=(const Loader &) = delete;
-
- virtual ~Loader() {}
-
- /**
- * Each subclass needs to implement this method. If the loader is
- * compatible with the passed in object file, it should return the
- * created Process object corresponding to it. If not, it should fail
- * silently and return nullptr. If there's a non-compatibliity related
- * error like file IO errors, etc., those should fail non-silently
- * with a panic or fail as normal.
- */
- virtual Process *load(ProcessParams *params, ObjectFile *obj_file) = 0;
- };
-
- // Try all the Loader instance's "load" methods one by one until one is
- // successful. If none are, complain and fail.
- static Process *tryLoaders(ProcessParams *params, ObjectFile *obj_file);
};
class ObjectFileFormat