aout_object.cc revision 8229
17008Snate@binkert.org/* 27008Snate@binkert.org * Copyright (c) 2003-2005 The Regents of The University of Michigan 37008Snate@binkert.org * All rights reserved. 47008Snate@binkert.org * 57008Snate@binkert.org * Redistribution and use in source and binary forms, with or without 67008Snate@binkert.org * modification, are permitted provided that the following conditions are 77008Snate@binkert.org * met: redistributions of source code must retain the above copyright 87008Snate@binkert.org * notice, this list of conditions and the following disclaimer; 97008Snate@binkert.org * redistributions in binary form must reproduce the above copyright 107008Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 117008Snate@binkert.org * documentation and/or other materials provided with the distribution; 127008Snate@binkert.org * neither the name of the copyright holders nor the names of its 137008Snate@binkert.org * contributors may be used to endorse or promote products derived from 147008Snate@binkert.org * this software without specific prior written permission. 157008Snate@binkert.org * 167008Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 177008Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 187008Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 197008Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 207008Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 217008Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 227008Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 237008Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 247008Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 257008Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 267008Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 277008Snate@binkert.org * 286285Snate@binkert.org * Authors: Steve Reinhardt 297039Snate@binkert.org */ 307039Snate@binkert.org 316285Snate@binkert.org#include <string> 327055Snate@binkert.org 337055Snate@binkert.org#include "base/loader/aout_object.hh" 346876Ssteve.reinhardt@amd.com#include "base/loader/exec_aout.h" 359302Snilay@cs.wisc.edu#include "base/loader/symtab.hh" 368341Snilay@cs.wisc.edu#include "base/trace.hh" 376506Spdudnik@gmail.com 387055Snate@binkert.orgusing namespace std; 398436SBrad.Beckmann@amd.com 406881SBrad.Beckmann@amd.comObjectFile * 418683Snilay@cs.wisc.eduAoutObject::tryFile(const string &fname, int fd, size_t len, uint8_t *data) 427055Snate@binkert.org{ 437055Snate@binkert.org if (!N_BADMAG(*(aout_exechdr *)data)) { 446285Snate@binkert.org // right now this is only used for Alpha PAL code 456285Snate@binkert.org return new AoutObject(fname, fd, len, data, 466285Snate@binkert.org ObjectFile::Alpha, ObjectFile::UnknownOpSys); 476285Snate@binkert.org } 487039Snate@binkert.org else { 497039Snate@binkert.org return NULL; 507039Snate@binkert.org } 516876Ssteve.reinhardt@amd.com} 528436SBrad.Beckmann@amd.com 538257SBrad.Beckmann@amd.com 547039Snate@binkert.orgAoutObject::AoutObject(const string &_filename, int _fd, 557039Snate@binkert.org size_t _len, uint8_t *_data, 567055Snate@binkert.org Arch _arch, OpSys _opSys) 577055Snate@binkert.org : ObjectFile(_filename, _fd, _len, _data, _arch, _opSys) 587055Snate@binkert.org{ 597039Snate@binkert.org execHdr = (aout_exechdr *)fileData; 607039Snate@binkert.org 617039Snate@binkert.org entry = execHdr->entry; 628531Snilay@cs.wisc.edu 638531Snilay@cs.wisc.edu text.baseAddr = N_TXTADDR(*execHdr); 646285Snate@binkert.org text.size = execHdr->tsize; 657055Snate@binkert.org text.fileImage = fileData + N_TXTOFF(*execHdr); 667055Snate@binkert.org 677039Snate@binkert.org data.baseAddr = N_DATADDR(*execHdr); 687055Snate@binkert.org data.size = execHdr->dsize; 697039Snate@binkert.org data.fileImage = fileData + N_DATOFF(*execHdr); 708683Snilay@cs.wisc.edu 718683Snilay@cs.wisc.edu bss.baseAddr = N_BSSADDR(*execHdr); 729302Snilay@cs.wisc.edu bss.size = execHdr->bsize; 739302Snilay@cs.wisc.edu bss.fileImage = NULL; 749302Snilay@cs.wisc.edu 759302Snilay@cs.wisc.edu DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n", 769302Snilay@cs.wisc.edu text.baseAddr, text.size, data.baseAddr, data.size, 779302Snilay@cs.wisc.edu bss.baseAddr, bss.size); 789302Snilay@cs.wisc.edu} 799302Snilay@cs.wisc.edu 809302Snilay@cs.wisc.edu 816285Snate@binkert.orgbool 826285Snate@binkert.orgAoutObject::loadGlobalSymbols(SymbolTable *symtab, Addr addrMask) 837039Snate@binkert.org{ 84 // a.out symbols not supported yet 85 return false; 86} 87 88bool 89AoutObject::loadLocalSymbols(SymbolTable *symtab, Addr addrMask) 90{ 91 // a.out symbols not supported yet 92 return false; 93} 94