LLVM  7.0.0svn
COFFYAML.h
Go to the documentation of this file.
1 //===- COFFYAML.h - COFF YAMLIO implementation ------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares classes for handling the YAML representation of COFF.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_OBJECTYAML_COFFYAML_H
15 #define LLVM_OBJECTYAML_COFFYAML_H
16 
17 #include "llvm/ADT/Optional.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/BinaryFormat/COFF.h"
23 #include "llvm/ObjectYAML/YAML.h"
24 #include <cstdint>
25 #include <vector>
26 
27 namespace llvm {
28 
29 namespace COFF {
30 
32  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
33  return static_cast<Characteristics>(Ret);
34 }
35 
38  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
39  return static_cast<SectionCharacteristics>(Ret);
40 }
41 
44  uint16_t Ret = static_cast<uint16_t>(a) | static_cast<uint16_t>(b);
45  return static_cast<DLLCharacteristics>(Ret);
46 }
47 
48 } // end namespace COFF
49 
50 // The structure of the yaml files is not an exact 1:1 match to COFF. In order
51 // to use yaml::IO, we use these structures which are closer to the source.
52 namespace COFFYAML {
53 
57 
58 struct Relocation {
60  uint16_t Type;
62 };
63 
64 struct Section {
66  unsigned Alignment = 0;
68  std::vector<CodeViewYAML::YAMLDebugSubsection> DebugS;
69  std::vector<CodeViewYAML::LeafRecord> DebugT;
71  std::vector<Relocation> Relocations;
73 
74  Section();
75 };
76 
77 struct Symbol {
88 
89  Symbol();
90 };
91 
92 struct PEHeader {
95 };
96 
97 struct Object {
100  std::vector<Section> Sections;
101  std::vector<Symbol> Symbols;
102 
103  Object();
104 };
105 
106 } // end namespace COFFYAML
107 
108 } // end namespace llvm
109 
113 
114 namespace llvm {
115 namespace yaml {
116 
117 template <>
119  static void enumeration(IO &IO, COFFYAML::WeakExternalCharacteristics &Value);
120 };
121 
122 template <>
124  static void enumeration(IO &IO, COFFYAML::AuxSymbolType &Value);
125 };
126 
127 template <>
129  static void enumeration(IO &IO, COFFYAML::COMDATType &Value);
130 };
131 
132 template <>
134  static void enumeration(IO &IO, COFF::MachineTypes &Value);
135 };
136 
137 template <>
139  static void enumeration(IO &IO, COFF::SymbolBaseType &Value);
140 };
141 
142 template <>
144  static void enumeration(IO &IO, COFF::SymbolStorageClass &Value);
145 };
146 
147 template <>
149  static void enumeration(IO &IO, COFF::SymbolComplexType &Value);
150 };
151 
152 template <>
154  static void enumeration(IO &IO, COFF::RelocationTypeI386 &Value);
155 };
156 
157 template <>
159  static void enumeration(IO &IO, COFF::RelocationTypeAMD64 &Value);
160 };
161 
162 template <>
164  static void enumeration(IO &IO, COFF::RelocationTypesARM &Value);
165 };
166 
167 template <>
169  static void enumeration(IO &IO, COFF::RelocationTypesARM64 &Value);
170 };
171 
172 template <>
174  static void enumeration(IO &IO, COFF::WindowsSubsystem &Value);
175 };
176 
177 template <>
179  static void bitset(IO &IO, COFF::Characteristics &Value);
180 };
181 
182 template <>
184  static void bitset(IO &IO, COFF::SectionCharacteristics &Value);
185 };
186 
187 template <>
189  static void bitset(IO &IO, COFF::DLLCharacteristics &Value);
190 };
191 
192 template <>
193 struct MappingTraits<COFFYAML::Relocation> {
194  static void mapping(IO &IO, COFFYAML::Relocation &Rel);
195 };
196 
197 template <>
198 struct MappingTraits<COFFYAML::PEHeader> {
199  static void mapping(IO &IO, COFFYAML::PEHeader &PH);
200 };
201 
202 template <>
203 struct MappingTraits<COFF::DataDirectory> {
204  static void mapping(IO &IO, COFF::DataDirectory &DD);
205 };
206 
207 template <>
208 struct MappingTraits<COFF::header> {
209  static void mapping(IO &IO, COFF::header &H);
210 };
211 
212 template <> struct MappingTraits<COFF::AuxiliaryFunctionDefinition> {
213  static void mapping(IO &IO, COFF::AuxiliaryFunctionDefinition &AFD);
214 };
215 
216 template <> struct MappingTraits<COFF::AuxiliarybfAndefSymbol> {
217  static void mapping(IO &IO, COFF::AuxiliarybfAndefSymbol &AAS);
218 };
219 
220 template <> struct MappingTraits<COFF::AuxiliaryWeakExternal> {
221  static void mapping(IO &IO, COFF::AuxiliaryWeakExternal &AWE);
222 };
223 
224 template <> struct MappingTraits<COFF::AuxiliarySectionDefinition> {
225  static void mapping(IO &IO, COFF::AuxiliarySectionDefinition &ASD);
226 };
227 
228 template <> struct MappingTraits<COFF::AuxiliaryCLRToken> {
229  static void mapping(IO &IO, COFF::AuxiliaryCLRToken &ACT);
230 };
231 
232 template <>
233 struct MappingTraits<COFFYAML::Symbol> {
234  static void mapping(IO &IO, COFFYAML::Symbol &S);
235 };
236 
237 template <>
238 struct MappingTraits<COFFYAML::Section> {
239  static void mapping(IO &IO, COFFYAML::Section &Sec);
240 };
241 
242 template <>
243 struct MappingTraits<COFFYAML::Object> {
244  static void mapping(IO &IO, COFFYAML::Object &Obj);
245 };
246 
247 } // end namespace yaml
248 } // end namespace llvm
249 
250 #endif // LLVM_OBJECTYAML_COFFYAML_H
COFF::section Header
Definition: COFFYAML.h:65
SymbolBaseType
Definition: COFF.h:237
COFF::PE32Header Header
Definition: COFFYAML.h:93
WeakExternalCharacteristics
Definition: COFF.h:433
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Optional< COFF::AuxiliarybfAndefSymbol > bfAndefSymbol
Definition: COFFYAML.h:82
RelocationTypeI386
Definition: COFF.h:328
COFF::symbol Header
Definition: COFFYAML.h:78
AuxSymbolType
Definition: COFF.h:266
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence...
Definition: YAMLTraits.h:1687
No complex type; simple scalar variable.
Definition: COFF.h:257
WindowsSubsystem
Definition: COFF.h:595
Characteristics operator|(Characteristics a, Characteristics b)
Definition: COFFYAML.h:31
COFF::header Header
Definition: COFFYAML.h:99
MachineTypes
Definition: COFF.h:94
std::vector< Relocation > Relocations
Definition: COFFYAML.h:71
DLLCharacteristics
Definition: COFF.h:614
RelocationTypesARM64
Definition: COFF.h:380
std::vector< Section > Sections
Definition: COFFYAML.h:100
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
SectionCharacteristics
Definition: COFF.h:281
RelocationTypeAMD64
Definition: COFF.h:342
#define H(x, y, z)
Definition: MD5.cpp:57
No type information or unknown base type.
Definition: COFF.h:238
Characteristics
Definition: COFF.h:121
yaml::BinaryRef SectionData
Definition: COFFYAML.h:67
Optional< COFF::AuxiliaryFunctionDefinition > FunctionDefinition
Definition: COFFYAML.h:81
std::vector< CodeViewYAML::LeafRecord > DebugT
Definition: COFFYAML.h:69
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
Definition: YAMLTraits.h:99
Optional< COFF::AuxiliaryCLRToken > CLRToken
Definition: COFFYAML.h:86
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types.
Definition: YAMLTraits.h:1390
SymbolStorageClass
Storage class tells where and what the symbol represents.
Definition: COFF.h:201
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:64
Optional< COFF::AuxiliaryWeakExternal > WeakExternal
Definition: COFFYAML.h:83
RelocationTypesARM
Definition: COFF.h:362
COMDATType
Definition: COFF.h:400
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
Definition: YAMLTraits.h:116
std::vector< CodeViewYAML::YAMLDebugSubsection > DebugS
Definition: COFFYAML.h:68
LLVM Value Representation.
Definition: Value.h:73
std::vector< Symbol > Symbols
Definition: COFFYAML.h:101
SymbolComplexType
Definition: COFF.h:256
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Optional< CodeViewYAML::DebugHSection > DebugH
Definition: COFFYAML.h:70
Optional< PEHeader > OptionalHeader
Definition: COFFYAML.h:98
Optional< COFF::AuxiliarySectionDefinition > SectionDefinition
Definition: COFFYAML.h:85