gem5  v19.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  * Authors: Nathan Binkert
29  * Steve Reinhardt
30  */
31 
32 #ifndef __BASE_LOADER_OBJECT_FILE_HH__
33 #define __BASE_LOADER_OBJECT_FILE_HH__
34 
35 #include <string>
36 
40 #include "base/logging.hh"
41 #include "base/types.hh"
42 
43 class SymbolTable;
44 
45 class ObjectFile : public ImageFile
46 {
47  public:
48 
49  enum Arch {
58  Arm,
63  };
64 
65  enum OpSys {
72  };
73 
74  protected:
77 
79 
80  public:
81  virtual ~ObjectFile() {};
82 
83  virtual bool
86  {
87  return true;
88  };
89  virtual bool
92  {
93  return true;
94  }
95  virtual bool
98  {
99  return true;
100  }
101  virtual bool
104  {
105  return true;
106  }
107 
108  virtual ObjectFile *getInterpreter() const { return nullptr; }
109  virtual bool relocatable() const { return false; }
110  virtual Addr
111  mapSize() const
112  {
113  panic("mapSize() should only be called on relocatable objects\n");
114  }
115  virtual void
116  updateBias(Addr bias_addr)
117  {
118  panic("updateBias() should only be called on relocatable objects\n");
119  }
120  virtual Addr bias() const { return 0; }
121 
122  virtual bool hasTLS() { return false; }
123 
124  Arch getArch() const { return arch; }
125  OpSys getOpSys() const { return opSys; }
126 
127  protected:
128  Addr entry = 0;
129 
130  public:
131  Addr entryPoint() const { return entry; }
132 };
133 
135 {
136  protected:
138 
139  public:
140  ObjectFileFormat(const ObjectFileFormat &) = delete;
141  void operator=(const ObjectFileFormat &) = delete;
142 
143  virtual ObjectFile *load(ImageFileDataPtr data) = 0;
144 };
145 
146 ObjectFile *createObjectFile(const std::string &fname, bool raw=false);
147 
148 #endif // __BASE_LOADER_OBJECT_FILE_HH__
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
virtual bool relocatable() const
Definition: object_file.hh:109
Arch getArch() const
Definition: object_file.hh:124
const Addr MaxAddr
Definition: types.hh:166
virtual ~ObjectFile()
Definition: object_file.hh:81
virtual ObjectFile * getInterpreter() const
Definition: object_file.hh:108
virtual Addr mapSize() const
Definition: object_file.hh:111
Bitfield< 23, 0 > offset
Definition: types.hh:154
ObjectFile * createObjectFile(const std::string &fname, bool raw=false)
Definition: object_file.cc:64
virtual void updateBias(Addr bias_addr)
Definition: object_file.hh:116
OpSys opSys
Definition: object_file.hh:76
Bitfield< 51, 12 > base
Definition: pagetable.hh:142
virtual bool hasTLS()
Definition: object_file.hh:122
virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:96
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:142
virtual Addr bias() const
Definition: object_file.hh:120
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:43
virtual bool loadWeakSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:102
OpSys getOpSys() const
Definition: object_file.hh:125
Addr entryPoint() const
Definition: object_file.hh:131
Bitfield< 3, 0 > mask
Definition: types.hh:64
std::shared_ptr< ImageFileData > ImageFileDataPtr
const char data[]
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:90
virtual bool loadAllSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:84

Generated on Fri Feb 28 2020 16:26:58 for gem5 by doxygen 1.8.13