gem5  v20.0.0.3
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/logging.hh"
38 #include "base/types.hh"
39 
40 namespace Loader
41 {
42 
43 enum Arch {
51  Arm,
56 };
57 
58 enum OpSys {
65 };
66 
67 class SymbolTable;
68 
69 class ObjectFile : public ImageFile
70 {
71  protected:
74 
76 
77  public:
78  virtual ~ObjectFile() {};
79 
80  virtual bool
83  {
84  return true;
85  };
86  virtual bool
89  {
90  return true;
91  }
92  virtual bool
95  {
96  return true;
97  }
98  virtual bool
101  {
102  return true;
103  }
104 
105  virtual ObjectFile *getInterpreter() const { return nullptr; }
106  virtual bool relocatable() const { return false; }
107  virtual Addr
108  mapSize() const
109  {
110  panic("mapSize() should only be called on relocatable objects\n");
111  }
112  virtual void
113  updateBias(Addr bias_addr)
114  {
115  panic("updateBias() should only be called on relocatable objects\n");
116  }
117  virtual Addr bias() const { return 0; }
118 
119  virtual bool hasTLS() { return false; }
120 
121  Arch getArch() const { return arch; }
122  OpSys getOpSys() const { return opSys; }
123 
124  protected:
125  Addr entry = 0;
126 
127  public:
128  Addr entryPoint() const { return entry; }
129 };
130 
132 {
133  protected:
135 
136  public:
137  ObjectFileFormat(const ObjectFileFormat &) = delete;
138  void operator=(const ObjectFileFormat &) = delete;
139 
140  virtual ObjectFile *load(ImageFileDataPtr data) = 0;
141 };
142 
143 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
144 
145 } // namespace Loader
146 
147 #endif // __BASE_LOADER_OBJECT_FILE_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:163
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:87
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:61
const Addr MaxAddr
Definition: types.hh:164
virtual ~ObjectFile()
Definition: object_file.hh:78
virtual void updateBias(Addr bias_addr)
Definition: object_file.hh:113
std::shared_ptr< ImageFileData > ImageFileDataPtr
Bitfield< 23, 0 > offset
Definition: types.hh:152
virtual bool hasTLS()
Definition: object_file.hh:119
virtual bool loadAllSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:81
Bitfield< 51, 12 > base
Definition: pagetable.hh:141
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
Arch getArch() const
Definition: object_file.hh:121
virtual ObjectFile * getInterpreter() const
Definition: object_file.hh:105
virtual bool relocatable() const
Definition: object_file.hh:106
Addr entryPoint() const
Definition: object_file.hh:128
virtual Addr mapSize() const
Definition: object_file.hh:108
virtual Addr bias() const
Definition: object_file.hh:117
Bitfield< 3, 0 > mask
Definition: types.hh:62
const char data[]
virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:93
virtual bool loadWeakSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:99
OpSys getOpSys() const
Definition: object_file.hh:122
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:39

Generated on Fri Jul 3 2020 15:52:59 for gem5 by doxygen 1.8.13