namespace
{
-class AlphaLinuxObjectFileLoader : public ObjectFile::Loader
+class AlphaLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class ArmFreebsdObjectFileLoader : public ObjectFile::Loader
+class ArmFreebsdObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class ArmLinuxObjectFileLoader : public ObjectFile::Loader
+class ArmLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class MipsLinuxObjectFileLoader : public ObjectFile::Loader
+class MipsLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class PowerLinuxObjectFileLoader : public ObjectFile::Loader
+class PowerLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class RiscvLinuxObjectFileLoader : public ObjectFile::Loader
+class RiscvLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class SparcLinuxObjectFileLoader : public ObjectFile::Loader
+class SparcLinuxObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class SparcSolarisObjectFileLoader : public ObjectFile::Loader
+class SparcSolarisObjectFileLoader : public Process::Loader
{
public:
Process *
namespace
{
-class X86LinuxObjectFileLoader : public ObjectFile::Loader
+class X86LinuxObjectFileLoader : public Process::Loader
{
public:
Process *
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;
#include "base/logging.hh"
#include "base/types.hh"
-class Process;
-class ProcessParams;
class SymbolTable;
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
using namespace std;
using namespace TheISA;
+namespace
+{
+
+typedef std::vector<Process::Loader *> LoaderList;
+
+LoaderList &
+process_loaders()
+{
+ static LoaderList loaders;
+ return loaders;
+}
+
+} // anonymous namespace
+
+Process::Loader::Loader()
+{
+ process_loaders().emplace_back(this);
+}
+
+Process *
+Process::tryLoaders(ProcessParams *params, ObjectFile *obj_file)
+{
+ for (auto &loader: process_loaders()) {
+ Process *p = loader->load(params, obj_file);
+ if (p)
+ return p;
+ }
+
+ return nullptr;
+}
+
static std::string
normalize(std::string& directory)
{
ObjectFile *obj_file = createObjectFile(executable);
fatal_if(!obj_file, "Cannot load object file %s.", executable);
- Process *process = ObjectFile::tryLoaders(this, obj_file);
+ Process *process = Process::tryLoaders(this, obj_file);
fatal_if(!process, "Unknown error creating process object.");
return process;
SETranslatingPortProxy initVirtMem; // memory proxy for initial image load
+ /**
+ * 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);
+
ObjectFile *objFile;
MemoryImage image;
MemoryImage interpImage;