raw_object.cc revision 11392
13584Ssaidi@eecs.umich.edu/*
23584Ssaidi@eecs.umich.edu * Copyright (c) 2006 The Regents of The University of Michigan
33584Ssaidi@eecs.umich.edu * All rights reserved.
43584Ssaidi@eecs.umich.edu *
53584Ssaidi@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
63584Ssaidi@eecs.umich.edu * modification, are permitted provided that the following conditions are
73584Ssaidi@eecs.umich.edu * met: redistributions of source code must retain the above copyright
83584Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
93584Ssaidi@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
103584Ssaidi@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
113584Ssaidi@eecs.umich.edu * documentation and/or other materials provided with the distribution;
123584Ssaidi@eecs.umich.edu * neither the name of the copyright holders nor the names of its
133584Ssaidi@eecs.umich.edu * contributors may be used to endorse or promote products derived from
143584Ssaidi@eecs.umich.edu * this software without specific prior written permission.
153584Ssaidi@eecs.umich.edu *
163584Ssaidi@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
173584Ssaidi@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
183584Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
193584Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
203584Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
213584Ssaidi@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
223584Ssaidi@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
233584Ssaidi@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
243584Ssaidi@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
253584Ssaidi@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
263584Ssaidi@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273584Ssaidi@eecs.umich.edu *
283584Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt
293584Ssaidi@eecs.umich.edu */
303584Ssaidi@eecs.umich.edu
313584Ssaidi@eecs.umich.edu#include "base/loader/raw_object.hh"
323603Ssaidi@eecs.umich.edu#include "base/loader/symtab.hh"
333584Ssaidi@eecs.umich.edu#include "base/trace.hh"
348232Snate@binkert.org#include "debug/Loader.hh"
353584Ssaidi@eecs.umich.edu
363584Ssaidi@eecs.umich.eduObjectFile *
3710880SCurtis.Dunham@arm.comRawObject::tryFile(const std::string &fname, size_t len, uint8_t *data)
383584Ssaidi@eecs.umich.edu{
3910880SCurtis.Dunham@arm.com    return new RawObject(fname, len, data, ObjectFile::UnknownArch,
403584Ssaidi@eecs.umich.edu            ObjectFile::UnknownOpSys);
413584Ssaidi@eecs.umich.edu}
423584Ssaidi@eecs.umich.edu
4310880SCurtis.Dunham@arm.comRawObject::RawObject(const std::string &_filename, size_t _len,
443584Ssaidi@eecs.umich.edu        uint8_t *_data, Arch _arch, OpSys _opSys)
4510880SCurtis.Dunham@arm.com    : ObjectFile(_filename, _len, _data, _arch, _opSys)
463584Ssaidi@eecs.umich.edu{
473584Ssaidi@eecs.umich.edu    text.baseAddr = 0;
483584Ssaidi@eecs.umich.edu    text.size = len;
493584Ssaidi@eecs.umich.edu    text.fileImage = fileData;
503584Ssaidi@eecs.umich.edu
513584Ssaidi@eecs.umich.edu    data.baseAddr = 0;
523584Ssaidi@eecs.umich.edu    data.size = 0;
533584Ssaidi@eecs.umich.edu    data.fileImage = NULL;
543584Ssaidi@eecs.umich.edu
553584Ssaidi@eecs.umich.edu    bss.baseAddr = 0;
563584Ssaidi@eecs.umich.edu    bss.size = 0;
573584Ssaidi@eecs.umich.edu    bss.fileImage = NULL;
583584Ssaidi@eecs.umich.edu
593584Ssaidi@eecs.umich.edu    DPRINTFR(Loader, "text: 0x%x %d\ndata: 0x%x %d\nbss: 0x%x %d\n",
603584Ssaidi@eecs.umich.edu             text.baseAddr, text.size, data.baseAddr, data.size,
613584Ssaidi@eecs.umich.edu             bss.baseAddr, bss.size);
623584Ssaidi@eecs.umich.edu}
633584Ssaidi@eecs.umich.edu
643584Ssaidi@eecs.umich.edubool
6511392Sbrandon.potter@amd.comRawObject::loadAllSymbols(SymbolTable *symtab, Addr base, Addr offset,
6611392Sbrandon.potter@amd.com                          Addr addr_mask)
6711392Sbrandon.potter@amd.com{
6811392Sbrandon.potter@amd.com    return true;
6911392Sbrandon.potter@amd.com}
7011392Sbrandon.potter@amd.com
7111392Sbrandon.potter@amd.combool
7211392Sbrandon.potter@amd.comRawObject::loadGlobalSymbols(SymbolTable *symtab, Addr base, Addr offset,
7311392Sbrandon.potter@amd.com                             Addr addr_mask)
743584Ssaidi@eecs.umich.edu{
753904Ssaidi@eecs.umich.edu/*    int fnameStart = filename.rfind('/',filename.size()) + 1;
763603Ssaidi@eecs.umich.edu    int extStart = filename.rfind('.',filename.size());
7711392Sbrandon.potter@amd.com    symtab->insert(text.baseAddr & addr_mask, filename.substr(fnameStart,
783904Ssaidi@eecs.umich.edu                extStart-fnameStart) + "_start");*/
793584Ssaidi@eecs.umich.edu    return true;
803584Ssaidi@eecs.umich.edu}
813584Ssaidi@eecs.umich.edu
823584Ssaidi@eecs.umich.edubool
8311392Sbrandon.potter@amd.comRawObject::loadLocalSymbols(SymbolTable *symtab, Addr base, Addr offset,
8411392Sbrandon.potter@amd.com                            Addr addr_mask)
853584Ssaidi@eecs.umich.edu{
863904Ssaidi@eecs.umich.edu/*    int fnameStart = filename.rfind('/',filename.size()) + 1;
873603Ssaidi@eecs.umich.edu    int extStart = filename.rfind('.',filename.size());
8811392Sbrandon.potter@amd.com    symtab->insert(text.baseAddr & addr_mask, filename.substr(fnameStart,
893904Ssaidi@eecs.umich.edu                extStart-fnameStart) + "_start");*/
903584Ssaidi@eecs.umich.edu    return true;
913584Ssaidi@eecs.umich.edu}
92