112SN/A/*
21762SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
312SN/A * All rights reserved.
412SN/A *
512SN/A * Redistribution and use in source and binary forms, with or without
612SN/A * modification, are permitted provided that the following conditions are
712SN/A * met: redistributions of source code must retain the above copyright
812SN/A * notice, this list of conditions and the following disclaimer;
912SN/A * redistributions in binary form must reproduce the above copyright
1012SN/A * notice, this list of conditions and the following disclaimer in the
1112SN/A * documentation and/or other materials provided with the distribution;
1212SN/A * neither the name of the copyright holders nor the names of its
1312SN/A * contributors may be used to endorse or promote products derived from
1412SN/A * this software without specific prior written permission.
1512SN/A *
1612SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
2912SN/A */
3012SN/A
3111793Sbrandon.potter@amd.com#include "base/loader/aout_object.hh"
3211793Sbrandon.potter@amd.com
3312SN/A#include <string>
3412SN/A
358229Snate@binkert.org#include "base/loader/exec_aout.h"
3656SN/A#include "base/loader/symtab.hh"
377676Snate@binkert.org#include "base/trace.hh"
388232Snate@binkert.org#include "debug/Loader.hh"
3912SN/A
4012SN/Ausing namespace std;
4112SN/A
4212SN/AObjectFile *
4310880SCurtis.Dunham@arm.comAoutObject::tryFile(const string &fname, size_t len, uint8_t *data)
4412SN/A{
4512SN/A    if (!N_BADMAG(*(aout_exechdr *)data)) {
46360SN/A        // right now this is only used for Alpha PAL code
4710880SCurtis.Dunham@arm.com        return new AoutObject(fname, len, data,
48360SN/A                              ObjectFile::Alpha, ObjectFile::UnknownOpSys);
4912SN/A    }
5012SN/A    else {
5112SN/A        return NULL;
5212SN/A    }
5312SN/A}
5412SN/A
5512SN/A
5610880SCurtis.Dunham@arm.comAoutObject::AoutObject(const string &_filename,
57360SN/A                       size_t _len, uint8_t *_data,
58360SN/A                       Arch _arch, OpSys _opSys)
5910880SCurtis.Dunham@arm.com    : ObjectFile(_filename, _len, _data, _arch, _opSys)
6012SN/A{
6112SN/A    execHdr = (aout_exechdr *)fileData;
6212SN/A
6312SN/A    entry = execHdr->entry;
6412SN/A
6512SN/A    text.baseAddr = N_TXTADDR(*execHdr);
6612SN/A    text.size = execHdr->tsize;
672420SN/A    text.fileImage = fileData + N_TXTOFF(*execHdr);
6812SN/A
6912SN/A    data.baseAddr = N_DATADDR(*execHdr);
7012SN/A    data.size = execHdr->dsize;
712420SN/A    data.fileImage = fileData + N_DATOFF(*execHdr);
7212SN/A
7312SN/A    bss.baseAddr = N_BSSADDR(*execHdr);
7412SN/A    bss.size = execHdr->bsize;
752420SN/A    bss.fileImage = NULL;
7612SN/A
7712SN/A    DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
7812SN/A             text.baseAddr, text.size, data.baseAddr, data.size,
7912SN/A             bss.baseAddr, bss.size);
8012SN/A}
8112SN/A
8212SN/A
8312SN/Abool
8411392Sbrandon.potter@amd.comAoutObject::loadAllSymbols(SymbolTable *symtab, Addr base, Addr offset,
8511392Sbrandon.potter@amd.com                           Addr addr_mask)
8611392Sbrandon.potter@amd.com{
8711392Sbrandon.potter@amd.com    return false;
8811392Sbrandon.potter@amd.com}
8911392Sbrandon.potter@amd.com
9011392Sbrandon.potter@amd.combool
9111392Sbrandon.potter@amd.comAoutObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset,
9211392Sbrandon.potter@amd.com                              Addr addr_mask)
9312SN/A{
9412SN/A    // a.out symbols not supported yet
9512SN/A    return false;
9612SN/A}
9712SN/A
9812SN/Abool
9911392Sbrandon.potter@amd.comAoutObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset,
10011392Sbrandon.potter@amd.com                             Addr addr_mask)
10112SN/A{
10212SN/A    // a.out symbols not supported yet
10312SN/A    return false;
10412SN/A}
105