object_file.hh (13634:748418e0ca3f) object_file.hh (13982:175e05a8ee6a)
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 25 unchanged lines hidden (view full) ---

34
35#include <limits>
36#include <string>
37
38#include "base/logging.hh"
39#include "base/types.hh"
40
41class PortProxy;
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 25 unchanged lines hidden (view full) ---

34
35#include <limits>
36#include <string>
37
38#include "base/logging.hh"
39#include "base/types.hh"
40
41class PortProxy;
42class Process;
43class ProcessParams;
42class SymbolTable;
43
44class ObjectFile
45{
46 public:
47
48 enum Arch {
49 UnknownArch,

--- 95 unchanged lines hidden (view full) ---

145 size_t bssSize() const { return bss.size; }
146
147 /* This function allows you to override the base address where
148 * a binary is going to be loaded or set it if the binary is just a
149 * blob that doesn't include an object header.
150 * @param a address to load the binary/text section at
151 */
152 void setTextBase(Addr a) { text.baseAddr = a; }
44class SymbolTable;
45
46class ObjectFile
47{
48 public:
49
50 enum Arch {
51 UnknownArch,

--- 95 unchanged lines hidden (view full) ---

147 size_t bssSize() const { return bss.size; }
148
149 /* This function allows you to override the base address where
150 * a binary is going to be loaded or set it if the binary is just a
151 * blob that doesn't include an object header.
152 * @param a address to load the binary/text section at
153 */
154 void setTextBase(Addr a) { text.baseAddr = a; }
155
156 /**
157 * Each instance of a Loader subclass will have a chance to try to load
158 * an object file when tryLoaders is called. If they can't because they
159 * aren't compatible with it (wrong arch, wrong OS, etc), then they
160 * silently fail by returning nullptr so other loaders can try.
161 */
162 class Loader
163 {
164 public:
165 Loader();
166
167 /* Loader instances are singletons. */
168 Loader(const Loader &) = delete;
169 void operator=(const Loader &) = delete;
170
171 virtual ~Loader() {}
172
173 /**
174 * Each subclass needs to implement this method. If the loader is
175 * compatible with the passed in object file, it should return the
176 * created Process object corresponding to it. If not, it should fail
177 * silently and return nullptr. If there's a non-compatibliity related
178 * error like file IO errors, etc., those should fail non-silently
179 * with a panic or fail as normal.
180 */
181 virtual Process *load(ProcessParams *params, ObjectFile *obj_file) = 0;
182 };
183
184 // Try all the Loader instance's "load" methods one by one until one is
185 // successful. If none are, complain and fail.
186 static Process *tryLoaders(ProcessParams *params, ObjectFile *obj_file);
153};
154
155ObjectFile *createObjectFile(const std::string &fname, bool raw = false);
156
157
158#endif // __OBJECT_FILE_HH__
187};
188
189ObjectFile *createObjectFile(const std::string &fname, bool raw = false);
190
191
192#endif // __OBJECT_FILE_HH__