summaryrefslogtreecommitdiff
path: root/base/loader
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2003-12-01 19:34:38 -0800
committerSteve Reinhardt <stever@eecs.umich.edu>2003-12-01 19:34:38 -0800
commit7976794aadd7f308010f88aa3a8a6e3469e37ba7 (patch)
tree48a163fc53913623e0d11cb1e44188fdaa2e8112 /base/loader
parent94f98b43b3eaf86b22ca29bab5e0a1d3a1c60512 (diff)
downloadgem5-7976794aadd7f308010f88aa3a8a6e3469e37ba7.tar.xz
Restructuring of LiveProcess etc. to support multiple emulated OS syscall
interfaces, and specific support for Alpha Linux. Split syscall emulation functions into several groups, based on whether they depend on the specific OS and/or architecture (and all combinations of above), including the use of template functions to support syscalls with slightly different constants or interface structs. arch/alpha/alpha_tru64_process.cc: Incorporate full Tru64 object definition here, including structure and constant definitions. This way we can wrap all of the functions inside the object, and not worry about namespace conflicts because no one outside this file will ever see it. base/loader/aout_object.cc: base/loader/aout_object.hh: base/loader/ecoff_object.cc: base/loader/ecoff_object.hh: base/loader/elf_object.cc: base/loader/elf_object.hh: base/loader/object_file.cc: base/loader/object_file.hh: Add enums to ObjectFile to indicate the object's architecture and operating system. cpu/exec_context.cc: prog.hh is now process.hh cpu/exec_context.hh: prog.hh is now process.hh move architecture-specific syscall arg accessors into ExecContext cpu/simple_cpu/simple_cpu.cc: No need to include prog.hh (which has been renamed) sim/process.cc: sim/process.hh: LiveProcess is now effectively an abstract base class. New LiveProcess::create() function takes an object file and dynamically picks the appropriate subclass of LiveProcess to handle the syscall interface that file expects (currently Tru64 or Linux). --HG-- rename : arch/alpha/fake_syscall.cc => arch/alpha/alpha_tru64_process.cc rename : sim/prog.cc => sim/process.cc rename : sim/prog.hh => sim/process.hh extra : convert_revision : 4a03ca7d94a34177cb672931f8aae83a6bad179a
Diffstat (limited to 'base/loader')
-rw-r--r--base/loader/aout_object.cc9
-rw-r--r--base/loader/aout_object.hh3
-rw-r--r--base/loader/ecoff_object.cc8
-rw-r--r--base/loader/ecoff_object.hh3
-rw-r--r--base/loader/elf_object.cc10
-rw-r--r--base/loader/elf_object.hh3
-rw-r--r--base/loader/object_file.cc6
-rw-r--r--base/loader/object_file.hh22
8 files changed, 48 insertions, 16 deletions
diff --git a/base/loader/aout_object.cc b/base/loader/aout_object.cc
index 0270e02a3..42a376ed1 100644
--- a/base/loader/aout_object.cc
+++ b/base/loader/aout_object.cc
@@ -43,7 +43,9 @@ ObjectFile *
AoutObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
{
if (!N_BADMAG(*(aout_exechdr *)data)) {
- return new AoutObject(fname, fd, len, data);
+ // right now this is only used for Alpha PAL code
+ return new AoutObject(fname, fd, len, data,
+ ObjectFile::Alpha, ObjectFile::UnknownOpSys);
}
else {
return NULL;
@@ -52,8 +54,9 @@ AoutObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
AoutObject::AoutObject(const string &_filename, int _fd,
- size_t _len, uint8_t *_data)
- : ObjectFile(_filename, _fd, _len, _data)
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys)
+ : ObjectFile(_filename, _fd, _len, _data, _arch, _opSys)
{
execHdr = (aout_exechdr *)fileData;
diff --git a/base/loader/aout_object.hh b/base/loader/aout_object.hh
index 77c59aef6..9fb8cb3e8 100644
--- a/base/loader/aout_object.hh
+++ b/base/loader/aout_object.hh
@@ -40,7 +40,8 @@ class AoutObject : public ObjectFile
aout_exechdr *execHdr;
AoutObject(const std::string &_filename, int _fd,
- size_t _len, uint8_t *_data);
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys);
public:
virtual ~AoutObject() {}
diff --git a/base/loader/ecoff_object.cc b/base/loader/ecoff_object.cc
index 5e726a1c5..bab75944d 100644
--- a/base/loader/ecoff_object.cc
+++ b/base/loader/ecoff_object.cc
@@ -46,7 +46,8 @@ EcoffObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
{
if (((ecoff_filehdr *)data)->f_magic == ECOFF_MAGIC_ALPHA) {
// it's Alpha ECOFF
- return new EcoffObject(fname, fd, len, data);
+ return new EcoffObject(fname, fd, len, data,
+ ObjectFile::Alpha, ObjectFile::Tru64);
}
else {
return NULL;
@@ -55,8 +56,9 @@ EcoffObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
EcoffObject::EcoffObject(const string &_filename, int _fd,
- size_t _len, uint8_t *_data)
- : ObjectFile(_filename, _fd, _len, _data)
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys)
+ : ObjectFile(_filename, _fd, _len, _data, _arch, _opSys)
{
execHdr = (ecoff_exechdr *)fileData;
fileHdr = &(execHdr->f);
diff --git a/base/loader/ecoff_object.hh b/base/loader/ecoff_object.hh
index 94b11c720..05d026d00 100644
--- a/base/loader/ecoff_object.hh
+++ b/base/loader/ecoff_object.hh
@@ -44,7 +44,8 @@ class EcoffObject : public ObjectFile
ecoff_aouthdr *aoutHdr;
EcoffObject(const std::string &_filename, int _fd,
- size_t _len, uint8_t *_data);
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys);
public:
virtual ~EcoffObject() {}
diff --git a/base/loader/elf_object.cc b/base/loader/elf_object.cc
index 605895c9c..30dec4c91 100644
--- a/base/loader/elf_object.cc
+++ b/base/loader/elf_object.cc
@@ -43,8 +43,9 @@ ObjectFile *
ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
{
if (memcmp(((Elf64_Ehdr *)data)->e_ident, ELFMAG, SELFMAG) == 0) {
- // for now we'll assume it's a 64-bit Alpha binary
- return new ElfObject(fname, fd, len, data);
+ // for now we'll assume it's a 64-bit Alpha Linux binary
+ return new ElfObject(fname, fd, len, data,
+ ObjectFile::Alpha, ObjectFile::Linux);
}
else {
return NULL;
@@ -53,8 +54,9 @@ ElfObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data)
ElfObject::ElfObject(const string &_filename, int _fd,
- size_t _len, uint8_t *_data)
- : ObjectFile(_filename, _fd, _len, _data)
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys)
+ : ObjectFile(_filename, _fd, _len, _data, _arch, _opSys)
{
ehdr = (Elf64_Ehdr *)fileData;
diff --git a/base/loader/elf_object.hh b/base/loader/elf_object.hh
index 28f6bb243..10d97d089 100644
--- a/base/loader/elf_object.hh
+++ b/base/loader/elf_object.hh
@@ -45,7 +45,8 @@ class ElfObject : public ObjectFile
int dataPhdrIdx;
ElfObject(const std::string &_filename, int _fd,
- size_t _len, uint8_t *_data);
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys);
public:
virtual ~ElfObject() {}
diff --git a/base/loader/object_file.cc b/base/loader/object_file.cc
index 5a13d180c..25e9b2d19 100644
--- a/base/loader/object_file.cc
+++ b/base/loader/object_file.cc
@@ -46,8 +46,10 @@
using namespace std;
ObjectFile::ObjectFile(const string &_filename, int _fd,
- size_t _len, uint8_t *_data)
- : filename(_filename), descriptor(_fd), fileData(_data), len(_len)
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys)
+ : filename(_filename), descriptor(_fd), fileData(_data), len(_len),
+ arch(_arch), opSys(_opSys)
{
}
diff --git a/base/loader/object_file.hh b/base/loader/object_file.hh
index 5950ea326..a29bdc153 100644
--- a/base/loader/object_file.hh
+++ b/base/loader/object_file.hh
@@ -36,14 +36,31 @@ class SymbolTable;
class ObjectFile
{
+ public:
+
+ enum Arch {
+ UnknownArch,
+ Alpha
+ };
+
+ enum OpSys {
+ UnknownOpSys,
+ Tru64,
+ Linux
+ };
+
protected:
const std::string filename;
int descriptor;
uint8_t *fileData;
size_t len;
+ Arch arch;
+ OpSys opSys;
+
ObjectFile(const std::string &_filename, int _fd,
- size_t _len, uint8_t *_data);
+ size_t _len, uint8_t *_data,
+ Arch _arch, OpSys _opSys);
public:
virtual ~ObjectFile();
@@ -55,6 +72,9 @@ class ObjectFile
virtual bool loadGlobalSymbols(SymbolTable *symtab) = 0;
virtual bool loadLocalSymbols(SymbolTable *symtab) = 0;
+ Arch getArch() const { return arch; }
+ OpSys getOpSys() const { return opSys; }
+
protected:
struct Section {