gem5  v21.1.0.2
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 
34 #include "base/compiler.hh"
38 #include "base/loader/symtab.hh"
39 #include "base/logging.hh"
40 #include "base/types.hh"
41 #include "enums/ByteOrder.hh"
42 
43 namespace gem5
44 {
45 
46 GEM5_DEPRECATED_NAMESPACE(Loader, loader);
47 namespace loader
48 {
49 
50 enum Arch
51 {
59  Arm,
65 };
66 
67 const char *archToString(Arch arch);
68 
69 enum OpSys
70 {
79 };
80 
81 const char *opSysToString(OpSys op_sys);
82 
83 class SymbolTable;
84 
85 class ObjectFile : public ImageFile
86 {
87  protected:
90  ByteOrder byteOrder = ByteOrder::little;
91 
93 
95 
96  public:
97  virtual ~ObjectFile() {};
98 
99  virtual ObjectFile *getInterpreter() const { return nullptr; }
100  virtual bool relocatable() const { return false; }
101  virtual Addr
102  mapSize() const
103  {
104  panic("mapSize() should only be called on relocatable objects\n");
105  }
106  virtual void
107  updateBias(Addr bias_addr)
108  {
109  panic("updateBias() should only be called on relocatable objects\n");
110  }
111  virtual Addr bias() const { return 0; }
112 
113  virtual bool hasTLS() { return false; }
114 
115  Arch getArch() const { return arch; }
116  OpSys getOpSys() const { return opSys; }
117  ByteOrder getByteOrder() const { return byteOrder; }
118 
119  const SymbolTable &symtab() const { return _symtab; }
120 
121  protected:
122  Addr entry = 0;
123 
124  public:
125  Addr entryPoint() const { return entry; }
126 };
127 
129 {
130  protected:
132 
133  public:
134  ObjectFileFormat(const ObjectFileFormat &) = delete;
135  void operator=(const ObjectFileFormat &) = delete;
136 
137  virtual ObjectFile *load(ImageFileDataPtr data) = 0;
138 };
139 
140 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
141 
142 } // namespace loader
143 } // namespace gem5
144 
145 #endif // __BASE_LOADER_OBJECT_FILE_HH__
gem5::loader::ObjectFile::getByteOrder
ByteOrder getByteOrder() const
Definition: object_file.hh:117
gem5::loader::LinuxPower64ABIv1
@ LinuxPower64ABIv1
Definition: object_file.hh:76
gem5::loader::ObjectFile
Definition: object_file.hh:85
gem5::loader::ObjectFile::ObjectFile
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:43
gem5::loader::ObjectFile::updateBias
virtual void updateBias(Addr bias_addr)
Definition: object_file.hh:107
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::loader::ObjectFile::entryPoint
Addr entryPoint() const
Definition: object_file.hh:125
gem5::loader::ObjectFile::hasTLS
virtual bool hasTLS()
Definition: object_file.hh:113
gem5::loader::ObjectFile::getInterpreter
virtual ObjectFile * getInterpreter() const
Definition: object_file.hh:99
gem5::loader::SPARC64
@ SPARC64
Definition: object_file.hh:53
gem5::loader::X86_64
@ X86_64
Definition: object_file.hh:56
gem5::loader::ObjectFileFormat::load
virtual ObjectFile * load(ImageFileDataPtr data)=0
gem5::loader::Solaris
@ Solaris
Definition: object_file.hh:74
gem5::loader::SymbolTable
Definition: symtab.hh:65
gem5::loader::ObjectFile::entry
Addr entry
Definition: object_file.hh:122
gem5::loader::opSysToString
const char * opSysToString(OpSys op_sys)
Definition: object_file.cc:81
gem5::loader::ObjectFile::symtab
const SymbolTable & symtab() const
Definition: object_file.hh:119
image_file_data.hh
gem5::loader::Arm64
@ Arm64
Definition: object_file.hh:58
gem5::loader::UnknownOpSys
@ UnknownOpSys
Definition: object_file.hh:71
gem5::FreeBSD
This class encapsulates the types, structures, constants, functions, and syscall-number mappings spec...
Definition: freebsd.hh:52
gem5::loader::Power
@ Power
Definition: object_file.hh:61
gem5::loader::ObjectFile::arch
Arch arch
Definition: object_file.hh:88
gem5::loader::ObjectFileFormat::operator=
void operator=(const ObjectFileFormat &)=delete
gem5::loader::ObjectFile::mapSize
virtual Addr mapSize() const
Definition: object_file.hh:102
gem5::loader::Mips
@ Mips
Definition: object_file.hh:55
gem5::loader::Power64
@ Power64
Definition: object_file.hh:62
gem5::loader::ObjectFile::bias
virtual Addr bias() const
Definition: object_file.hh:111
gem5::loader::Arch
Arch
Definition: object_file.hh:50
gem5::loader::archToString
const char * archToString(Arch arch)
Definition: object_file.cc:46
gem5::loader::ObjectFile::byteOrder
ByteOrder byteOrder
Definition: object_file.hh:90
gem5::loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:115
compiler.hh
gem5::loader::Riscv32
@ Riscv32
Definition: object_file.hh:64
gem5::loader::ObjectFile::opSys
OpSys opSys
Definition: object_file.hh:89
gem5::loader::ObjectFile::getOpSys
OpSys getOpSys() const
Definition: object_file.hh:116
gem5::loader::Tru64
@ Tru64
Definition: object_file.hh:72
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::loader::LinuxPower64ABIv2
@ LinuxPower64ABIv2
Definition: object_file.hh:77
gem5::loader::createObjectFile
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:123
gem5::loader::Thumb
@ Thumb
Definition: object_file.hh:60
gem5::loader::ObjectFileFormat
Definition: object_file.hh:128
gem5::loader::UnknownArch
@ UnknownArch
Definition: object_file.hh:52
gem5::loader::SPARC32
@ SPARC32
Definition: object_file.hh:54
gem5::loader::ObjectFile::_symtab
SymbolTable _symtab
Definition: object_file.hh:92
types.hh
gem5::loader::ObjectFile::~ObjectFile
virtual ~ObjectFile()
Definition: object_file.hh:97
gem5::loader::ImageFileDataPtr
std::shared_ptr< ImageFileData > ImageFileDataPtr
Definition: image_file_data.hh:61
gem5::loader::OpSys
OpSys
Definition: object_file.hh:69
logging.hh
gem5::loader::ObjectFileFormat::ObjectFileFormat
ObjectFileFormat()
Definition: object_file.cc:117
gem5::loader::I386
@ I386
Definition: object_file.hh:57
gem5::loader::LinuxArmOABI
@ LinuxArmOABI
Definition: object_file.hh:75
symtab.hh
gem5::loader::ObjectFile::relocatable
virtual bool relocatable() const
Definition: object_file.hh:100
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::loader::Arm
@ Arm
Definition: object_file.hh:59
memory_image.hh
gem5::loader::Riscv64
@ Riscv64
Definition: object_file.hh:63
gem5::loader::Linux
@ Linux
Definition: object_file.hh:73
gem5::loader::ImageFile
Definition: image_file.hh:46
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
image_file.hh

Generated on Tue Sep 21 2021 12:24:57 for gem5 by doxygen 1.8.17