summaryrefslogtreecommitdiff
path: root/src/base/loader/aout_object.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/loader/aout_object.cc')
-rw-r--r--src/base/loader/aout_object.cc63
1 files changed, 22 insertions, 41 deletions
diff --git a/src/base/loader/aout_object.cc b/src/base/loader/aout_object.cc
index eb633c1ce..47f3021b7 100644
--- a/src/base/loader/aout_object.cc
+++ b/src/base/loader/aout_object.cc
@@ -40,63 +40,44 @@
using namespace std;
ObjectFile *
-AoutObject::tryFile(const string &fname, size_t len, uint8_t *data)
+AoutObjectFileFormat::load(ImageFileDataPtr ifd)
{
- if (!N_BADMAG(*(aout_exechdr *)data)) {
- // right now this is only used for Alpha PAL code
- return new AoutObject(fname, len, data,
- ObjectFile::Alpha, ObjectFile::UnknownOpSys);
- } else {
+ if (!N_BADMAG(*(const aout_exechdr *)ifd->data()))
+ return new AoutObject(ifd);
+ else
return nullptr;
- }
}
+namespace
+{
+
+AoutObjectFileFormat aoutObjectFileFormat;
+
+} // anonymous namespace
+
-AoutObject::AoutObject(const string &_filename,
- size_t _len, uint8_t *_data,
- Arch _arch, OpSys _opSys)
- : ObjectFile(_filename, _len, _data, _arch, _opSys)
+AoutObject::AoutObject(ImageFileDataPtr ifd) : ObjectFile(ifd)
{
- execHdr = (aout_exechdr *)fileData;
+ execHdr = (const aout_exechdr *)imageData->data();
entry = execHdr->entry;
+
+ // Right now this is only used for Alpha PAL code.
+ arch = Alpha;
}
MemoryImage
AoutObject::buildImage() const
{
MemoryImage image({
- { "text", N_TXTADDR(*execHdr),
- fileData + N_TXTOFF(*execHdr), execHdr->tsize },
- { "data", N_DATADDR(*execHdr),
- fileData + N_DATOFF(*execHdr), execHdr->dsize },
- { "bss", N_BSSADDR(*execHdr), nullptr, execHdr->bsize}
+ MemoryImage::Segment{ "text", N_TXTADDR(*execHdr), imageData,
+ N_TXTOFF(*execHdr), execHdr->tsize },
+ MemoryImage::Segment{ "data", N_DATADDR(*execHdr), imageData,
+ N_DATOFF(*execHdr), execHdr->dsize },
+ MemoryImage::Segment{ "bss", N_BSSADDR(*execHdr), execHdr->bsize}
});
for (auto &seg: image.segments())
DPRINTFR(Loader, "%s\n", seg);
- return image;
-}
-
-bool
-AoutObject::loadAllSymbols(SymbolTable *symtab, Addr base, Addr offset,
- Addr addr_mask)
-{
- return false;
-}
-
-bool
-AoutObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset,
- Addr addr_mask)
-{
- // a.out symbols not supported yet
- return false;
-}
-
-bool
-AoutObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset,
- Addr addr_mask)
-{
- // a.out symbols not supported yet
- return false;
+ return image;
}