diff options
Diffstat (limited to 'src/base/loader/object_file.cc')
-rw-r--r-- | src/base/loader/object_file.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/base/loader/object_file.cc b/src/base/loader/object_file.cc index a82314e68..86278e44f 100644 --- a/src/base/loader/object_file.cc +++ b/src/base/loader/object_file.cc @@ -40,6 +40,7 @@ #include <cstdio> #include <list> #include <string> +#include <vector> #include "base/cprintf.hh" #include "base/loader/aout_object.hh" @@ -97,6 +98,37 @@ ObjectFile::loadSections(PortProxy& mem_proxy, Addr addr_mask, Addr offset) && loadSection(&bss, mem_proxy, addr_mask, offset)); } +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; +} + static bool hasGzipMagic(int fd) { |