gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 const char *archToString(Arch arch);
60 
61 enum OpSys {
68 };
69 
70 const char *opSysToString(OpSys op_sys);
71 
72 class SymbolTable;
73 
74 class ObjectFile : public ImageFile
75 {
76  protected:
79 
81 
83 
84  public:
85  virtual ~ObjectFile() {};
86 
87  virtual ObjectFile *getInterpreter() const { return nullptr; }
88  virtual bool relocatable() const { return false; }
89  virtual Addr
90  mapSize() const
91  {
92  panic("mapSize() should only be called on relocatable objects\n");
93  }
94  virtual void
95  updateBias(Addr bias_addr)
96  {
97  panic("updateBias() should only be called on relocatable objects\n");
98  }
99  virtual Addr bias() const { return 0; }
100 
101  virtual bool hasTLS() { return false; }
102 
103  Arch getArch() const { return arch; }
104  OpSys getOpSys() const { return opSys; }
105 
106  const SymbolTable &symtab() const { return _symtab; }
107 
108  protected:
109  Addr entry = 0;
110 
111  public:
112  Addr entryPoint() const { return entry; }
113 };
114 
116 {
117  protected:
119 
120  public:
121  ObjectFileFormat(const ObjectFileFormat &) = delete;
122  void operator=(const ObjectFileFormat &) = delete;
123 
124  virtual ObjectFile *load(ImageFileDataPtr data) = 0;
125 };
126 
127 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
128 
129 } // namespace Loader
130 
131 #endif // __BASE_LOADER_OBJECT_FILE_HH__
Loader::ObjectFile::relocatable
virtual bool relocatable() const
Definition: object_file.hh:88
Loader::Linux
@ Linux
Definition: object_file.hh:64
Loader::SPARC32
@ SPARC32
Definition: object_file.hh:47
data
const char data[]
Definition: circlebuf.test.cc:47
Loader::ObjectFile::bias
virtual Addr bias() const
Definition: object_file.hh:99
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:77
Loader::Arm
@ Arm
Definition: object_file.hh:52
Loader::OpSys
OpSys
Definition: object_file.hh:61
Loader::Power
@ Power
Definition: object_file.hh:54
Loader::SymbolTable
Definition: symtab.hh:58
Loader::createObjectFile
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:115
Loader::ObjectFileFormat::operator=
void operator=(const ObjectFileFormat &)=delete
Loader::ObjectFileFormat::ObjectFileFormat
ObjectFileFormat()
Definition: object_file.cc:109
Loader::ImageFile
Definition: image_file.hh:41
Loader::Solaris
@ Solaris
Definition: object_file.hh:65
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:34
Loader::ObjectFile
Definition: object_file.hh:74
Loader::ObjectFile::entryPoint
Addr entryPoint() const
Definition: object_file.hh:112
Loader::ObjectFile::symtab
const SymbolTable & symtab() const
Definition: object_file.hh:106
Loader::ObjectFile::hasTLS
virtual bool hasTLS()
Definition: object_file.hh:101
Loader::opSysToString
const char * opSysToString(OpSys op_sys)
Definition: object_file.cc:75
Loader::ObjectFile::opSys
OpSys opSys
Definition: object_file.hh:78
Loader::UnknownOpSys
@ UnknownOpSys
Definition: object_file.hh:62
Loader::I386
@ I386
Definition: object_file.hh:50
Loader::ObjectFile::mapSize
virtual Addr mapSize() const
Definition: object_file.hh:90
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:148
Loader::Mips
@ Mips
Definition: object_file.hh:48
Loader::ObjectFile::getInterpreter
virtual ObjectFile * getInterpreter() const
Definition: object_file.hh:87
Loader::Arch
Arch
Definition: object_file.hh:44
Loader::ObjectFile::_symtab
SymbolTable _symtab
Definition: object_file.hh:80
Loader::ObjectFile::~ObjectFile
virtual ~ObjectFile()
Definition: object_file.hh:85
Loader::ObjectFile::updateBias
virtual void updateBias(Addr bias_addr)
Definition: object_file.hh:95
Loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:103
Loader::X86_64
@ X86_64
Definition: object_file.hh:49
Loader::Tru64
@ Tru64
Definition: object_file.hh:63
types.hh
Loader::LinuxArmOABI
@ LinuxArmOABI
Definition: object_file.hh:66
Loader::ObjectFileFormat::load
virtual ObjectFile * load(ImageFileDataPtr data)=0
logging.hh
Loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition: object_file.hh:104
Loader::Arm64
@ Arm64
Definition: object_file.hh:51
Loader::ObjectFileFormat
Definition: object_file.hh:115
FreeBSD
Definition: threadinfo.hh:39
symtab.hh
Loader::ObjectFile::entry
Addr entry
Definition: object_file.hh:109
Loader::ObjectFile::ObjectFile
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:39
Loader::archToString
const char * archToString(Arch arch)
Definition: object_file.cc:42
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 Tue Mar 23 2021 19:41:24 for gem5 by doxygen 1.8.17