1/*
2 * Copyright (c) 2003-2005 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;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Steve Reinhardt
29 */
30
31#include "base/loader/aout_object.hh"
32
33#include <string>
34
33#include "base/loader/aout_object.hh"
35#include "base/loader/exec_aout.h"
36#include "base/loader/symtab.hh"
37#include "base/trace.hh"
38#include "debug/Loader.hh"
39
40using namespace std;
41
42ObjectFile *
43AoutObject::tryFile(const string &fname, size_t len, uint8_t *data)
44{
45 if (!N_BADMAG(*(aout_exechdr *)data)) {
46 // right now this is only used for Alpha PAL code
47 return new AoutObject(fname, len, data,
48 ObjectFile::Alpha, ObjectFile::UnknownOpSys);
49 }
50 else {
51 return NULL;
52 }
53}
54
55
56AoutObject::AoutObject(const string &_filename,
57 size_t _len, uint8_t *_data,
58 Arch _arch, OpSys _opSys)
59 : ObjectFile(_filename, _len, _data, _arch, _opSys)
60{
61 execHdr = (aout_exechdr *)fileData;
62
63 entry = execHdr->entry;
64
65 text.baseAddr = N_TXTADDR(*execHdr);
66 text.size = execHdr->tsize;
67 text.fileImage = fileData + N_TXTOFF(*execHdr);
68
69 data.baseAddr = N_DATADDR(*execHdr);
70 data.size = execHdr->dsize;
71 data.fileImage = fileData + N_DATOFF(*execHdr);
72
73 bss.baseAddr = N_BSSADDR(*execHdr);
74 bss.size = execHdr->bsize;
75 bss.fileImage = NULL;
76
77 DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
78 text.baseAddr, text.size, data.baseAddr, data.size,
79 bss.baseAddr, bss.size);
80}
81
82
83bool
84AoutObject::loadAllSymbols(SymbolTable *symtab, Addr base, Addr offset,
85 Addr addr_mask)
86{
87 return false;
88}
89
90bool
91AoutObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset,
92 Addr addr_mask)
93{
94 // a.out symbols not supported yet
95 return false;
96}
97
98bool
99AoutObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset,
100 Addr addr_mask)
101{
102 // a.out symbols not supported yet
103 return false;
104}