elf_object.hh revision 56
12568SN/A/* 22568SN/A * Copyright (c) 2003 The Regents of The University of Michigan 32568SN/A * All rights reserved. 42568SN/A * 52568SN/A * Redistribution and use in source and binary forms, with or without 62568SN/A * modification, are permitted provided that the following conditions are 72568SN/A * met: redistributions of source code must retain the above copyright 82568SN/A * notice, this list of conditions and the following disclaimer; 92568SN/A * redistributions in binary form must reproduce the above copyright 102568SN/A * notice, this list of conditions and the following disclaimer in the 112568SN/A * documentation and/or other materials provided with the distribution; 122568SN/A * neither the name of the copyright holders nor the names of its 132568SN/A * contributors may be used to endorse or promote products derived from 142568SN/A * this software without specific prior written permission. 152568SN/A * 162568SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172568SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182568SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192568SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202568SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212568SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222568SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232568SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242568SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252568SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262568SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272568SN/A */ 282665Ssaidi@eecs.umich.edu 292665Ssaidi@eecs.umich.edu#ifndef __ELF_OBJECT_HH__ 302665Ssaidi@eecs.umich.edu#define __ELF_OBJECT_HH__ 312568SN/A 322568SN/A#include "base/loader/object_file.hh" 332568SN/A 342982Sstever@eecs.umich.edu// forward decls: avoid including exec_elf.hh here 352982Sstever@eecs.umich.edustruct Elf64_Ehdr; 362568SN/Astruct Elf64_Phdr; 372568SN/A 382643Sstever@eecs.umich.educlass ElfObject : public ObjectFile 392568SN/A{ 402568SN/A protected: 412568SN/A Elf64_Ehdr *ehdr; 422568SN/A Elf64_Phdr *phdr; 432568SN/A 442643Sstever@eecs.umich.edu int textPhdrIdx; 452643Sstever@eecs.umich.edu int dataPhdrIdx; 462643Sstever@eecs.umich.edu 472643Sstever@eecs.umich.edu ElfObject(const std::string &_filename, int _fd, 482643Sstever@eecs.umich.edu size_t _len, uint8_t *_data); 492643Sstever@eecs.umich.edu 502643Sstever@eecs.umich.edu public: 512643Sstever@eecs.umich.edu virtual ~ElfObject() {} 522643Sstever@eecs.umich.edu 532643Sstever@eecs.umich.edu virtual bool loadSections(FunctionalMemory *mem, 542643Sstever@eecs.umich.edu bool loadPhys = false); 552643Sstever@eecs.umich.edu virtual bool loadGlobalSymbols(SymbolTable *symtab); 562643Sstever@eecs.umich.edu virtual bool loadLocalSymbols(SymbolTable *symtab); 572643Sstever@eecs.umich.edu 582643Sstever@eecs.umich.edu static ObjectFile *tryFile(const std::string &fname, int fd, 592643Sstever@eecs.umich.edu size_t len, uint8_t *data); 602643Sstever@eecs.umich.edu}; 612643Sstever@eecs.umich.edu 622643Sstever@eecs.umich.edu#endif // __ELF_OBJECT_HH__ 632738Sstever@eecs.umich.edu