LLVM  6.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"
22 #include "llvm/ObjectYAML/YAML.h"
23 #include <cstdint>
24 #include <vector>
25 
26 namespace llvm {
27 
28 namespace COFF {
29 
31  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
32  return static_cast<Characteristics>(Ret);
33 }
34 
37  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
38  return static_cast<SectionCharacteristics>(Ret);
39 }
40 
43  uint16_t Ret = static_cast<uint16_t>(a) | static_cast<uint16_t>(b);
44  return static_cast<DLLCharacteristics>(Ret);
45 }
46 
47 } // end namespace COFF
48 
49 // The structure of the yaml files is not an exact 1:1 match to COFF. In order
50 // to use yaml::IO, we use these structures which are closer to the source.
51 namespace COFFYAML {
52 
56 
57 struct Relocation {
59  uint16_t Type;
61 };
62 
63 struct Section {
65  unsigned Alignment = 0;
67  std::vector<CodeViewYAML::YAMLDebugSubsection> DebugS;
68  std::vector<CodeViewYAML::LeafRecord> DebugT;
69  std::vector<Relocation> Relocations;
71 
72  Section();
73 };
74 
75 struct Symbol {
86 
87  Symbol();
88 };
89 
90 struct PEHeader {
93 };
94 
95 struct Object {
98  std::vector<Section> Sections;
99  std::vector<Symbol> Symbols;
100 
101  Object();
102 };
103 
104 } // end namespace COFFYAML
105 
106 } // end namespace llvm
107 
111 
112 namespace llvm {
113 namespace yaml {
114 
115 template <>
117  static void enumeration(IO &IO, COFFYAML::WeakExternalCharacteristics &Value);
118 };
119 
120 template <>
122  static void enumeration(IO &IO, COFFYAML::AuxSymbolType &Value);
123 };
124 
125 template <>
127  static void enumeration(IO &IO, COFFYAML::COMDATType &Value);
128 };
129 
130 template <>
132  static void enumeration(IO &IO, COFF::MachineTypes &Value);
133 };
134 
135 template <>
137  static void enumeration(IO &IO, COFF::SymbolBaseType &Value);
138 };
139 
140 template <>
142  static void enumeration(IO &IO, COFF::SymbolStorageClass &Value);
143 };
144 
145 template <>
147  static void enumeration(IO &IO, COFF::SymbolComplexType &Value);
148 };
149 
150 template <>
152  static void enumeration(IO &IO, COFF::RelocationTypeI386 &Value);
153 };
154 
155 template <>
157  static void enumeration(IO &IO, COFF::RelocationTypeAMD64 &Value);
158 };
159 
160 template <>
162  static void enumeration(IO &IO, COFF::RelocationTypesARM &Value);
163 };
164 
165 template <>
167  static void enumeration(IO &IO, COFF::RelocationTypesARM64 &Value);
168 };
169 
170 template <>
172  static void enumeration(IO &IO, COFF::WindowsSubsystem &Value);
173 };
174 
175 template <>
177  static void bitset(IO &IO, COFF::Characteristics &Value);
178 };
179 
180 template <>
182  static void bitset(IO &IO, COFF::SectionCharacteristics &Value);
183 };
184 
185 template <>
187  static void bitset(IO &IO, COFF::DLLCharacteristics &Value);
188 };
189 
190 template <>
191 struct MappingTraits<COFFYAML::Relocation> {
192  static void mapping(IO &IO, COFFYAML::Relocation &Rel);
193 };
194 
195 template <>
196 struct MappingTraits<COFFYAML::PEHeader> {
197  static void mapping(IO &IO, COFFYAML::PEHeader &PH);
198 };
199 
200 template <>
201 struct MappingTraits<COFF::DataDirectory> {
202  static void mapping(IO &IO, COFF::DataDirectory &DD);
203 };
204 
205 template <>
206 struct MappingTraits<COFF::header> {
207  static void mapping(IO &IO, COFF::header &H);
208 };
209 
210 template <> struct MappingTraits<COFF::AuxiliaryFunctionDefinition> {
211  static void mapping(IO &IO, COFF::AuxiliaryFunctionDefinition &AFD);
212 };
213 
214 template <> struct MappingTraits<COFF::AuxiliarybfAndefSymbol> {
215  static void mapping(IO &IO, COFF::AuxiliarybfAndefSymbol &AAS);
216 };
217 
218 template <> struct MappingTraits<COFF::AuxiliaryWeakExternal> {
219  static void mapping(IO &IO, COFF::AuxiliaryWeakExternal &AWE);
220 };
221 
222 template <> struct MappingTraits<COFF::AuxiliarySectionDefinition> {
223  static void mapping(IO &IO, COFF::AuxiliarySectionDefinition &ASD);
224 };
225 
226 template <> struct MappingTraits<COFF::AuxiliaryCLRToken> {
227  static void mapping(IO &IO, COFF::AuxiliaryCLRToken &ACT);
228 };
229 
230 template <>
231 struct MappingTraits<COFFYAML::Symbol> {
232  static void mapping(IO &IO, COFFYAML::Symbol &S);
233 };
234 
235 template <>
236 struct MappingTraits<COFFYAML::Section> {
237  static void mapping(IO &IO, COFFYAML::Section &Sec);
238 };
239 
240 template <>
241 struct MappingTraits<COFFYAML::Object> {
242  static void mapping(IO &IO, COFFYAML::Object &Obj);
243 };
244 
245 } // end namespace yaml
246 } // end namespace llvm
247 
248 #endif // LLVM_OBJECTYAML_COFFYAML_H
Characteristics
Definition: COFF.h:121
COFF::section Header
Definition: COFFYAML.h:64
COFF::PE32Header Header
Definition: COFFYAML.h:91
RelocationTypesARM64
Definition: COFF.h:380
RelocationTypesARM
Definition: COFF.h:362
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Optional< COFF::AuxiliarybfAndefSymbol > bfAndefSymbol
Definition: COFFYAML.h:80
COFF::symbol Header
Definition: COFFYAML.h:76
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:1643
Characteristics operator|(Characteristics a, Characteristics b)
Definition: COFFYAML.h:30
COFF::header Header
Definition: COFFYAML.h:97
SymbolComplexType
Definition: COFF.h:256
No complex type; simple scalar variable.
Definition: COFF.h:257
std::vector< Relocation > Relocations
Definition: COFFYAML.h:69
std::vector< Section > Sections
Definition: COFFYAML.h:98
SymbolBaseType
Definition: COFF.h:237
WindowsSubsystem
Definition: COFF.h:595
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
SectionCharacteristics
Definition: COFF.h:281
No type information or unknown base type.
Definition: COFF.h:238
#define H(x, y, z)
Definition: MD5.cpp:57
RelocationTypeI386
Definition: COFF.h:328
yaml::BinaryRef SectionData
Definition: COFFYAML.h:66
Optional< COFF::AuxiliaryFunctionDefinition > FunctionDefinition
Definition: COFFYAML.h:79
std::vector< CodeViewYAML::LeafRecord > DebugT
Definition: COFFYAML.h:68
This class should be specialized by any integral type that converts to/from a YAML scalar where there...
Definition: YAMLTraits.h:98
Optional< COFF::AuxiliaryCLRToken > CLRToken
Definition: COFFYAML.h:84
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types.
Definition: YAMLTraits.h:1346
RelocationTypeAMD64
Definition: COFF.h:342
SymbolStorageClass
Storage class tells where and what the symbol represents.
Definition: COFF.h:201
COMDATType
Definition: COFF.h:400
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:64
DLLCharacteristics
Definition: COFF.h:614
Optional< COFF::AuxiliaryWeakExternal > WeakExternal
Definition: COFFYAML.h:81
MachineTypes
Definition: COFF.h:94
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
Definition: YAMLTraits.h:115
std::vector< CodeViewYAML::YAMLDebugSubsection > DebugS
Definition: COFFYAML.h:67
LLVM Value Representation.
Definition: Value.h:73
std::vector< Symbol > Symbols
Definition: COFFYAML.h:99
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Optional< PEHeader > OptionalHeader
Definition: COFFYAML.h:96
WeakExternalCharacteristics
Definition: COFF.h:433
Optional< COFF::AuxiliarySectionDefinition > SectionDefinition
Definition: COFFYAML.h:83