gem5  v21.1.0.2
object_file.cc
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 
30 
31 #include <string>
32 #include <vector>
33 
34 #include "base/loader/raw_image.hh"
35 
36 namespace gem5
37 {
38 
39 GEM5_DEPRECATED_NAMESPACE(Loader, loader);
40 namespace loader
41 {
42 
44 
45 const char *
47 {
48  switch (arch) {
49  case UnknownArch:
50  return "unknown";
51  case SPARC64:
52  return "sparc64";
53  case SPARC32:
54  return "sparc32";
55  case Mips:
56  return "mips";
57  case X86_64:
58  return "x86_64";
59  case I386:
60  return "i386";
61  case Arm64:
62  return "arm64";
63  case Arm:
64  return "arm";
65  case Thumb:
66  return "thumb";
67  case Power:
68  return "power";
69  case Power64:
70  return "power64";
71  case Riscv64:
72  return "riscv64";
73  case Riscv32:
74  return "riscv32";
75  default:
76  panic("Unrecognized arch %d.", arch);
77  }
78 }
79 
80 const char *
82 {
83  switch (op_sys) {
84  case UnknownOpSys:
85  return "unknown";
86  case Tru64:
87  return "tru64";
88  case Linux:
89  case LinuxPower64ABIv1:
90  case LinuxPower64ABIv2:
91  return "linux";
92  case Solaris:
93  return "solaris";
94  case LinuxArmOABI:
95  return "linux_arm_OABI";
96  case FreeBSD:
97  return "freebsd";
98  default:
99  panic("Unrecognized operating system %d.", op_sys);
100  }
101 }
102 
103 namespace
104 {
105 
106 typedef std::vector<ObjectFileFormat *> ObjectFileFormatList;
107 
108 ObjectFileFormatList &
109 object_file_formats()
110 {
111  static ObjectFileFormatList formats;
112  return formats;
113 }
114 
115 } // anonymous namespace
116 
118 {
119  object_file_formats().emplace_back(this);
120 }
121 
122 ObjectFile *
123 createObjectFile(const std::string &fname, bool raw)
124 {
125  ImageFileDataPtr ifd(new ImageFileData(fname));
126 
127  for (auto &format: object_file_formats()) {
128  ObjectFile *file_obj = format->load(ifd);
129  if (file_obj)
130  return file_obj;
131  }
132 
133  if (raw)
134  return new RawImage(ifd);
135 
136  return nullptr;
137 }
138 
139 } // namespace loader
140 } // namespace gem5
gem5::loader::LinuxPower64ABIv1
@ LinuxPower64ABIv1
Definition: object_file.hh:76
gem5::loader::ObjectFile
Definition: object_file.hh:85
gem5::ArmISA::format
Bitfield< 31, 29 > format
Definition: misc_types.hh:646
gem5::loader::ObjectFile::ObjectFile
ObjectFile(ImageFileDataPtr ifd)
Definition: object_file.cc:43
gem5::loader::SPARC64
@ SPARC64
Definition: object_file.hh:53
gem5::loader::X86_64
@ X86_64
Definition: object_file.hh:56
gem5::loader::Solaris
@ Solaris
Definition: object_file.hh:74
std::vector
STL vector class.
Definition: stl.hh:37
gem5::loader::opSysToString
const char * opSysToString(OpSys op_sys)
Definition: object_file.cc:81
gem5::loader::Arm64
@ Arm64
Definition: object_file.hh:58
gem5::loader::FreeBSD
@ FreeBSD
Definition: object_file.hh:78
gem5::loader::UnknownOpSys
@ UnknownOpSys
Definition: object_file.hh:71
gem5::loader::Power
@ Power
Definition: object_file.hh:61
gem5::loader::ImageFileData
Definition: image_file_data.hh:45
gem5::loader::Mips
@ Mips
Definition: object_file.hh:55
gem5::loader::Power64
@ Power64
Definition: object_file.hh:62
gem5::loader::Arch
Arch
Definition: object_file.hh:50
gem5::loader::archToString
const char * archToString(Arch arch)
Definition: object_file.cc:46
gem5::loader::Riscv32
@ Riscv32
Definition: object_file.hh:64
gem5::loader::RawImage
Definition: raw_image.hh:42
gem5::loader::Tru64
@ Tru64
Definition: object_file.hh:72
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::UnknownArch
@ UnknownArch
Definition: object_file.hh:52
gem5::loader::SPARC32
@ SPARC32
Definition: object_file.hh:54
raw_image.hh
gem5::loader::ImageFileDataPtr
std::shared_ptr< ImageFileData > ImageFileDataPtr
Definition: image_file_data.hh:61
gem5::loader::OpSys
OpSys
Definition: object_file.hh:69
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
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
object_file.hh
gem5::loader::Arm
@ Arm
Definition: object_file.hh:59
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

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