LLVM  4.0.0
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/ObjectYAML/YAML.h"
19 #include "llvm/Support/COFF.h"
20 
21 namespace llvm {
22 
23 namespace COFF {
25  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
26  return static_cast<Characteristics>(Ret);
27 }
28 
31  uint32_t Ret = static_cast<uint32_t>(a) | static_cast<uint32_t>(b);
32  return static_cast<SectionCharacteristics>(Ret);
33 }
34 
37  uint16_t Ret = static_cast<uint16_t>(a) | static_cast<uint16_t>(b);
38  return static_cast<DLLCharacteristics>(Ret);
39 }
40 }
41 
42 // The structure of the yaml files is not an exact 1:1 match to COFF. In order
43 // to use yaml::IO, we use these structures which are closer to the source.
44 namespace COFFYAML {
48 
49  struct Relocation {
51  uint16_t Type;
53  };
54 
55  struct Section {
57  unsigned Alignment = 0;
59  std::vector<Relocation> Relocations;
61  Section();
62  };
63 
64  struct Symbol {
75  Symbol();
76  };
77 
78  struct PEHeader {
81  };
82 
83  struct Object {
86  std::vector<Section> Sections;
87  std::vector<Symbol> Symbols;
88  Object();
89  };
90 }
91 }
92 
95 LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Relocation)
96 
97 namespace llvm {
98 namespace yaml {
99 
100 template <>
102  static void enumeration(IO &IO, COFFYAML::WeakExternalCharacteristics &Value);
103 };
104 
105 template <>
107  static void enumeration(IO &IO, COFFYAML::AuxSymbolType &Value);
108 };
109 
110 template <>
112  static void enumeration(IO &IO, COFFYAML::COMDATType &Value);
113 };
114 
115 template <>
117  static void enumeration(IO &IO, COFF::MachineTypes &Value);
118 };
119 
120 template <>
122  static void enumeration(IO &IO, COFF::SymbolBaseType &Value);
123 };
124 
125 template <>
127  static void enumeration(IO &IO, COFF::SymbolStorageClass &Value);
128 };
129 
130 template <>
132  static void enumeration(IO &IO, COFF::SymbolComplexType &Value);
133 };
134 
135 template <>
137  static void enumeration(IO &IO, COFF::RelocationTypeI386 &Value);
138 };
139 
140 template <>
142  static void enumeration(IO &IO, COFF::RelocationTypeAMD64 &Value);
143 };
144 
145 template <>
147  static void enumeration(IO &IO, COFF::WindowsSubsystem &Value);
148 };
149 
150 template <>
152  static void bitset(IO &IO, COFF::Characteristics &Value);
153 };
154 
155 template <>
157  static void bitset(IO &IO, COFF::SectionCharacteristics &Value);
158 };
159 
160 template <>
162  static void bitset(IO &IO, COFF::DLLCharacteristics &Value);
163 };
164 
165 template <>
166 struct MappingTraits<COFFYAML::Relocation> {
167  static void mapping(IO &IO, COFFYAML::Relocation &Rel);
168 };
169 
170 template <>
171 struct MappingTraits<COFFYAML::PEHeader> {
172  static void mapping(IO &IO, COFFYAML::PEHeader &PH);
173 };
174 
175 template <>
176 struct MappingTraits<COFF::DataDirectory> {
177  static void mapping(IO &IO, COFF::DataDirectory &DD);
178 };
179 
180 template <>
181 struct MappingTraits<COFF::header> {
182  static void mapping(IO &IO, COFF::header &H);
183 };
184 
185 template <> struct MappingTraits<COFF::AuxiliaryFunctionDefinition> {
186  static void mapping(IO &IO, COFF::AuxiliaryFunctionDefinition &AFD);
187 };
188 
189 template <> struct MappingTraits<COFF::AuxiliarybfAndefSymbol> {
190  static void mapping(IO &IO, COFF::AuxiliarybfAndefSymbol &AAS);
191 };
192 
193 template <> struct MappingTraits<COFF::AuxiliaryWeakExternal> {
194  static void mapping(IO &IO, COFF::AuxiliaryWeakExternal &AWE);
195 };
196 
197 template <> struct MappingTraits<COFF::AuxiliarySectionDefinition> {
198  static void mapping(IO &IO, COFF::AuxiliarySectionDefinition &ASD);
199 };
200 
201 template <> struct MappingTraits<COFF::AuxiliaryCLRToken> {
202  static void mapping(IO &IO, COFF::AuxiliaryCLRToken &ACT);
203 };
204 
205 template <>
206 struct MappingTraits<COFFYAML::Symbol> {
207  static void mapping(IO &IO, COFFYAML::Symbol &S);
208 };
209 
210 template <>
211 struct MappingTraits<COFFYAML::Section> {
212  static void mapping(IO &IO, COFFYAML::Section &Sec);
213 };
214 
215 template <>
216 struct MappingTraits<COFFYAML::Object> {
217  static void mapping(IO &IO, COFFYAML::Object &Obj);
218 };
219 
220 } // end namespace yaml
221 } // end namespace llvm
222 
223 #endif
COFF::section Header
Definition: COFFYAML.h:56
COFF::PE32Header Header
Definition: COFFYAML.h:79
COFF::SymbolBaseType SimpleType
Definition: COFFYAML.h:66
Optional< COFF::AuxiliarybfAndefSymbol > bfAndefSymbol
Definition: COFFYAML.h:69
COFF::symbol Header
Definition: COFFYAML.h:65
#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:1565
Characteristics operator|(Characteristics a, Characteristics b)
Definition: COFFYAML.h:24
COFF::header Header
Definition: COFFYAML.h:85
No complex type; simple scalar variable.
Definition: Support/COFF.h:227
std::vector< Relocation > Relocations
Definition: COFFYAML.h:59
std::vector< Section > Sections
Definition: COFFYAML.h:86
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
No type information or unknown base type.
Definition: Support/COFF.h:208
#define H(x, y, z)
Definition: MD5.cpp:53
yaml::BinaryRef SectionData
Definition: COFFYAML.h:58
Optional< COFF::AuxiliaryFunctionDefinition > FunctionDefinition
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:97
Optional< COFF::AuxiliaryCLRToken > CLRToken
Definition: COFFYAML.h:73
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types.
Definition: YAMLTraits.h:1327
SymbolStorageClass
Storage class tells where and what the symbol represents.
Definition: Support/COFF.h:171
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:57
Optional< COFF::DataDirectory > DataDirectories[COFF::NUM_DATA_DIRECTORIES]
Definition: COFFYAML.h:80
Optional< COFF::AuxiliaryWeakExternal > WeakExternal
Definition: COFFYAML.h:70
COFFYAML::WeakExternalCharacteristics Characteristics
Definition: COFFYAML.cpp:270
This class should be specialized by any integer type that is a union of bit values and the YAML repre...
Definition: YAMLTraits.h:114
LLVM Value Representation.
Definition: Value.h:71
std::vector< Symbol > Symbols
Definition: COFFYAML.h:87
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
COFF::SymbolComplexType ComplexType
Definition: COFFYAML.h:67
Optional< PEHeader > OptionalHeader
Definition: COFFYAML.h:84
WeakExternalCharacteristics
Definition: Support/COFF.h:385
Optional< COFF::AuxiliarySectionDefinition > SectionDefinition
Definition: COFFYAML.h:72