summaryrefslogtreecommitdiff
path: root/base/object_file.hh
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-10-07 23:13:01 -0700
committerSteve Reinhardt <stever@eecs.umich.edu>2003-10-07 23:13:01 -0700
commite475dba424d70e99646f897fae832f87b1cf15cf (patch)
tree04acc02acfc77419aaf80a26e03b4ccf742838cc /base/object_file.hh
parent998d2914db377d5236d6241e3c839af1728c36e7 (diff)
downloadgem5-e475dba424d70e99646f897fae832f87b1cf15cf.tar.xz
New loader structure. Expand Nate's ObjectFile to automatically detect file formats
and generate an appropriate child object, which knows how to load its text & data into memory (and symbols, for ecoff only at this point). Ecoff format supports Tru64 binaries, kernel, and console. A.out format is used by PAL code. Elf support is there and appears to work for Alpha/Linux binaries, but awaits a Linux syscall emulation layer before further testing. arch/alpha/ecoff_machdep.h: base/coff_sym.h: base/coff_symconst.h: base/exec_ecoff.h: Add Id string & provenance comment, clean up types base/object_file.cc: base/object_file.hh: Add auto format detection and text/data loading. sim/prog.cc: Moved binary loading & stack setup here (was in arch/alpha/loader.cc). Some of this is platform-dependent, but I think most of it is not. We'll factor out the platform-dependent parts when the need arises. sim/prog.hh: Get rid of unused environ_base field. sim/system.cc: Use new ObjectFile loader structure for console, kernel, & palcode. --HG-- extra : convert_revision : 8eae509bf71cf204bc3ec78c68699cfd01baed97
Diffstat (limited to 'base/object_file.hh')
-rw-r--r--base/object_file.hh66
1 files changed, 31 insertions, 35 deletions
diff --git a/base/object_file.hh b/base/object_file.hh
index c100efc94..1e37b7b70 100644
--- a/base/object_file.hh
+++ b/base/object_file.hh
@@ -29,64 +29,60 @@
#ifndef __OBJECT_FILE_HH__
#define __OBJECT_FILE_HH__
-#include "ecoff.hh"
#include "isa_traits.hh" // for Addr
+class FunctionalMemory;
class SymbolTable;
class ObjectFile
{
protected:
- std::string name;
+ const std::string filename;
int descriptor;
- uint8_t *data;
+ uint8_t *fileData;
size_t len;
+ ObjectFile(const std::string &_filename, int _fd,
+ size_t _len, uint8_t *_data);
+
public:
- ObjectFile();
- explicit ObjectFile(std::string file);
virtual ~ObjectFile();
- bool open(std::string file);
void close();
- virtual bool loadGlobals(SymbolTable *symtab) = 0;
- virtual bool loadLocals(SymbolTable *symtab) = 0;
- virtual void postOpen() = 0;
+ virtual bool loadSections(FunctionalMemory *mem,
+ bool loadPhys = false) = 0;
+ virtual bool loadGlobalSymbols(SymbolTable *symtab) = 0;
+ virtual bool loadLocalSymbols(SymbolTable *symtab) = 0;
protected:
- Addr text_off;
- Addr data_off;
- Addr bss_off;
- size_t text_size;
- size_t data_size;
- size_t bss_size;
+ struct Section {
+ Addr baseAddr;
+ size_t size;
+ };
- public:
- Addr textOffset() const { return text_off; }
- Addr dataOffset() const { return data_off; }
- Addr bssOffset() const { return bss_off; }
+ Addr entry;
+ Addr globalPtr;
- size_t textSize() const { return text_size; }
- size_t dataSize() const { return data_size; }
- size_t bssSize() const { return bss_size; }
-};
-
-class EcoffObject : public ObjectFile
-{
- protected:
- EcoffFileHeader *exec;
- EcoffAOutHeader *aout;
+ Section text;
+ Section data;
+ Section bss;
public:
- EcoffObject() {}
- explicit EcoffObject(std::string file) { open(file); }
- virtual ~EcoffObject() {}
+ Addr entryPoint() const { return entry; }
+ Addr globalPointer() const { return globalPtr; }
+
+ Addr textBase() const { return text.baseAddr; }
+ Addr dataBase() const { return data.baseAddr; }
+ Addr bssBase() const { return bss.baseAddr; }
- virtual bool loadGlobals(SymbolTable *symtab);
- virtual bool loadLocals(SymbolTable *symtab);
- virtual void postOpen();
+ size_t textSize() const { return text.size; }
+ size_t dataSize() const { return data.size; }
+ size_t bssSize() const { return bss.size; }
};
+ObjectFile *createObjectFile(const std::string &fname);
+
+
#endif // __OBJECT_FILE_HH__