gem5  v20.1.0.0
object_file.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2004 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 
29 #ifndef __BASE_LOADER_OBJECT_FILE_HH__
30 #define __BASE_LOADER_OBJECT_FILE_HH__
31 
32 #include <string>
33 
37 #include "base/loader/symtab.hh"
38 #include "base/logging.hh"
39 #include "base/types.hh"
40 
41 namespace Loader
42 {
43 
44 enum Arch {
52  Arm,
57 };
58 
59 enum OpSys {
66 };
67 
68 class SymbolTable;
69 
70 class ObjectFile : public ImageFile
71 {
72  protected:
75 
77 
79 
80  public:
81  virtual ~ObjectFile() {};
82 
83  virtual ObjectFile *getInterpreter() const { return nullptr; }
84  virtual bool relocatable() const { return false; }
85  virtual Addr
86  mapSize() const
87  {
88  panic("mapSize() should only be called on relocatable objects\n");
89  }
90  virtual void
91  updateBias(Addr bias_addr)
92  {
93  panic("updateBias() should only be called on relocatable objects\n");
94  }
95  virtual Addr bias() const { return 0; }
96 
97  virtual bool hasTLS() { return false; }
98 
99  Arch getArch() const { return arch; }
100  OpSys getOpSys() const { return opSys; }
101 
102  const SymbolTable &symtab() const { return _symtab; }
103 
104  protected:
105  Addr entry = 0;
106 
107  public:
108  Addr entryPoint() const { return entry; }
109 };
110 
112 {
113  protected:
115 
116  public:
117  ObjectFileFormat(const ObjectFileFormat &) = delete;
118  void operator=(const ObjectFileFormat &) = delete;
119 
120  virtual ObjectFile *load(ImageFileDataPtr data) = 0;
121 };
122 
123 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
124 
125 } // namespace Loader
126 
127 #endif // __BASE_LOADER_OBJECT_FILE_HH__
Loader::ObjectFile::relocatable
virtual bool relocatable() const
Definition: object_file.hh:84
Loader::Linux
@ Linux
Definition: object_file.hh:62
Loader::SPARC32
@ SPARC32
Definition: object_file.hh:47
data
const char data[]
Definition: circlebuf.test.cc:42
Loader::ObjectFile::bias
virtual Addr bias() const
Definition: object_file.hh:95
Loader::Riscv32
@ Riscv32
Definition: object_file.hh:56
Loader::Thumb
@ Thumb
Definition: object_file.hh:53
Loader::ObjectFile::arch
Arch arch
Definition: object_file.hh:73
Loader::Arm
@ Arm
Definition: object_file.hh:52
Loader::OpSys
OpSys
Definition: object_file.hh:59
Loader::Power
@ Power
Definition: object_file.hh:54
Loader::SymbolTable
Definition: symtab.hh:59
Loader::createObjectFile
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:61
Loader::ObjectFileFormat::operator=
void operator=(const ObjectFileFormat &)=delete
Loader::ObjectFileFormat::ObjectFileFormat
ObjectFileFormat()
Definition: object_file.cc:55
Loader::ImageFile
Definition: image_file.hh:41
Loader::Solaris
@ Solaris
Definition: object_file.hh:63
Loader::SPARC64
@ SPARC64
Definition: object_file.hh:46
Loader::ImageFileDataPtr
std::shared_ptr< ImageFileData > ImageFileDataPtr
Definition: image_file_data.hh:55
image_file_data.hh
Loader::Riscv64
@ Riscv64
Definition: object_file.hh:55
Loader
Definition: process.hh:39
Loader::ObjectFile
Definition: object_file.hh:70
Loader::ObjectFile::entryPoint
Addr entryPoint() const
Definition: object_file.hh:108
Loader::ObjectFile::symtab
const SymbolTable & symtab() const
Definition: object_file.hh:102
Loader::ObjectFile::hasTLS
virtual bool hasTLS()
Definition: object_file.hh:97
Loader::ObjectFile::opSys
OpSys opSys
Definition: object_file.hh:74
Loader::UnknownOpSys
@ UnknownOpSys
Definition: object_file.hh:60
Loader::I386
@ I386
Definition: object_file.hh:50
Loader::ObjectFile::mapSize
virtual Addr mapSize() const
Definition: object_file.hh:86
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Loader::Mips
@ Mips
Definition: object_file.hh:48
Loader::ObjectFile::getInterpreter
virtual ObjectFile * getInterpreter() const
Definition: object_file.hh:83
Loader::Arch
Arch
Definition: object_file.hh:44
Loader::ObjectFile::_symtab
SymbolTable _symtab
Definition: object_file.hh:76
Loader::ObjectFile::~ObjectFile
virtual ~ObjectFile()
Definition: object_file.hh:81
Loader::ObjectFile::updateBias
virtual void updateBias(Addr bias_addr)
Definition: object_file.hh:91
Loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:99
Loader::X86_64
@ X86_64
Definition: object_file.hh:49
Loader::Tru64
@ Tru64
Definition: object_file.hh:61
types.hh
Loader::LinuxArmOABI
@ LinuxArmOABI
Definition: object_file.hh:64
Loader::ObjectFileFormat::load
virtual ObjectFile * load(ImageFileDataPtr data)=0
logging.hh
Loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition: object_file.hh:100
Loader::Arm64
@ Arm64
Definition: object_file.hh:51
Loader::ObjectFileFormat
Definition: object_file.hh:111
FreeBSD
Definition: threadinfo.hh:39
symtab.hh
Loader::ObjectFile::entry
Addr entry
Definition: object_file.hh:105
Loader::ObjectFile::ObjectFile
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:39
Loader::UnknownArch
@ UnknownArch
Definition: object_file.hh:45
memory_image.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:171
image_file.hh

Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17