LLVM  8.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 
54 LLVM_YAML_STRONG_TYPEDEF(uint8_t, COMDATType)
55 LLVM_YAML_STRONG_TYPEDEF(uint32_t, WeakExternalCharacteristics)
56 LLVM_YAML_STRONG_TYPEDEF(uint8_t, AuxSymbolType)
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;
70  std::vector<CodeViewYAML::LeafRecord> DebugP;
72  std::vector<Relocation> Relocations;
74 
75  Section();
76 };
77 
78 struct Symbol {
89 
90  Symbol();
91 };
92 
93 struct PEHeader {
96 };
97 
98 struct Object {
101  std::vector<Section> Sections;
102  std::vector<Symbol> Symbols;
103 
104  Object();
105 };
106 
107 } // end namespace COFFYAML
108 
109 } // end namespace llvm
110 
111 LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Section)
112 LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Symbol)
113 LLVM_YAML_IS_SEQUENCE_VECTOR(COFFYAML::Relocation)
114 
115 namespace llvm {
116 namespace yaml {
117 
118 template <>
119 struct ScalarEnumerationTraits<COFFYAML::WeakExternalCharacteristics> {
120  static void enumeration(IO &IO, COFFYAML::WeakExternalCharacteristics &Value);
121 };
122 
123 template <>
124 struct ScalarEnumerationTraits<COFFYAML::AuxSymbolType> {
125  static void enumeration(IO &IO, COFFYAML::AuxSymbolType &Value);
126 };
127 
128 template <>
129 struct ScalarEnumerationTraits<COFFYAML::COMDATType> {
130  static void enumeration(IO &IO, COFFYAML::COMDATType &Value);
131 };
132 
133 template <>
134 struct ScalarEnumerationTraits<COFF::MachineTypes> {
135  static void enumeration(IO &IO, COFF::MachineTypes &Value);
136 };
137 
138 template <>
139 struct ScalarEnumerationTraits<COFF::SymbolBaseType> {
140  static void enumeration(IO &IO, COFF::SymbolBaseType &Value);
141 };
142 
143 template <>
144 struct ScalarEnumerationTraits<COFF::SymbolStorageClass> {
145  static void enumeration(IO &IO, COFF::SymbolStorageClass &Value);
146 };
147 
148 template <>
149 struct ScalarEnumerationTraits<COFF::SymbolComplexType> {
150  static void enumeration(IO &IO, COFF::SymbolComplexType &Value);
151 };
152 
153 template <>
154 struct ScalarEnumerationTraits<COFF::RelocationTypeI386> {
155  static void enumeration(IO &IO, COFF::RelocationTypeI386 &Value);
156 };
157 
158 template <>
159 struct ScalarEnumerationTraits<COFF::RelocationTypeAMD64> {
160  static void enumeration(IO &IO, COFF::RelocationTypeAMD64 &Value);
161 };
162 
163 template <>
164 struct ScalarEnumerationTraits<COFF::RelocationTypesARM> {
165  static void enumeration(IO &IO, COFF::RelocationTypesARM &Value);
166 };
167 
168 template <>
169 struct ScalarEnumerationTraits<COFF::RelocationTypesARM64> {
170  static void enumeration(IO &IO, COFF::RelocationTypesARM64 &Value);
171 };
172 
173 template <>
174 struct ScalarEnumerationTraits<COFF::WindowsSubsystem> {
175  static void enumeration(IO &IO, COFF::WindowsSubsystem &Value);
176 };
177 
178 template <>
179 struct ScalarBitSetTraits<COFF::Characteristics> {
180  static void bitset(IO &IO, COFF::Characteristics &Value);
181 };
182 
183 template <>
184 struct ScalarBitSetTraits<COFF::SectionCharacteristics> {
185  static void bitset(IO &IO, COFF::SectionCharacteristics &Value);
186 };
187 
188 template <>
189 struct ScalarBitSetTraits<COFF::DLLCharacteristics> {
190  static void bitset(IO &IO, COFF::DLLCharacteristics &Value);
191 };
192 
193 template <>
194 struct MappingTraits<COFFYAML::Relocation> {
195  static void mapping(IO &IO, COFFYAML::Relocation &Rel);
196 };
197 
198 template <>
199 struct MappingTraits<COFFYAML::PEHeader> {
200  static void mapping(IO &IO, COFFYAML::PEHeader &PH);
201 };
202 
203 template <>
204 struct MappingTraits<COFF::DataDirectory> {
205  static void mapping(IO &IO, COFF::DataDirectory &DD);
206 };
207 
208 template <>
209 struct MappingTraits<COFF::header> {
210  static void mapping(IO &IO, COFF::header &H);
211 };
212 
213 template <> struct MappingTraits<COFF::AuxiliaryFunctionDefinition> {
214  static void mapping(IO &IO, COFF::AuxiliaryFunctionDefinition &AFD);
215 };
216 
217 template <> struct MappingTraits<COFF::AuxiliarybfAndefSymbol> {
218  static void mapping(IO &IO, COFF::AuxiliarybfAndefSymbol &AAS);
219 };
220 
221 template <> struct MappingTraits<COFF::AuxiliaryWeakExternal> {
222  static void mapping(IO &IO, COFF::AuxiliaryWeakExternal &AWE);
223 };
224 
225 template <> struct MappingTraits<COFF::AuxiliarySectionDefinition> {
226  static void mapping(IO &IO, COFF::AuxiliarySectionDefinition &ASD);
227 };
228 
229 template <> struct MappingTraits<COFF::AuxiliaryCLRToken> {
230  static void mapping(IO &IO, COFF::AuxiliaryCLRToken &ACT);
231 };
232 
233 template <>
234 struct MappingTraits<COFFYAML::Symbol> {
235  static void mapping(IO &IO, COFFYAML::Symbol &S);
236 };
237 
238 template <>
239 struct MappingTraits<COFFYAML::Section> {
240  static void mapping(IO &IO, COFFYAML::Section &Sec);
241 };
242 
243 template <>
244 struct MappingTraits<COFFYAML::Object> {
245  static void mapping(IO &IO, COFFYAML::Object &Obj);
246 };
247 
248 } // end namespace yaml
249 } // end namespace llvm
250 
251 #endif // LLVM_OBJECTYAML_COFFYAML_H
COFF::section Header
Definition: COFFYAML.h:65
SymbolBaseType
Definition: COFF.h:240
COFF::PE32Header Header
Definition: COFFYAML.h:94
WeakExternalCharacteristics
Definition: COFF.h:436
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Optional< COFF::AuxiliarybfAndefSymbol > bfAndefSymbol
Definition: COFFYAML.h:83
RelocationTypeI386
Definition: COFF.h:331
COFF::symbol Header
Definition: COFFYAML.h:79
AuxSymbolType
Definition: COFF.h:269
No complex type; simple scalar variable.
Definition: COFF.h:260
WindowsSubsystem
Definition: COFF.h:598
Characteristics operator|(Characteristics a, Characteristics b)
Definition: COFFYAML.h:31
COFF::header Header
Definition: COFFYAML.h:100
MachineTypes
Definition: COFF.h:94
std::vector< Relocation > Relocations
Definition: COFFYAML.h:72
DLLCharacteristics
Definition: COFF.h:617
RelocationTypesARM64
Definition: COFF.h:383
std::vector< Section > Sections
Definition: COFFYAML.h:101
SectionCharacteristics
Definition: COFF.h:284
RelocationTypeAMD64
Definition: COFF.h:345
std::vector< CodeViewYAML::LeafRecord > DebugP
Definition: COFFYAML.h:70
#define H(x, y, z)
Definition: MD5.cpp:57
No type information or unknown base type.
Definition: COFF.h:241
Characteristics
Definition: COFF.h:124
yaml::BinaryRef SectionData
Definition: COFFYAML.h:67
Optional< COFF::AuxiliaryFunctionDefinition > FunctionDefinition
Definition: COFFYAML.h:82
std::vector< CodeViewYAML::LeafRecord > DebugT
Definition: COFFYAML.h:69
Optional< COFF::AuxiliaryCLRToken > CLRToken
Definition: COFFYAML.h:87
SymbolStorageClass
Storage class tells where and what the symbol represents.
Definition: COFF.h:204
Specialized YAMLIO scalar type for representing a binary blob.
Definition: YAML.h:64
Optional< COFF::AuxiliaryWeakExternal > WeakExternal
Definition: COFFYAML.h:84
RelocationTypesARM
Definition: COFF.h:365
COMDATType
Definition: COFF.h:403
std::vector< CodeViewYAML::YAMLDebugSubsection > DebugS
Definition: COFFYAML.h:68
LLVM Value Representation.
Definition: Value.h:73
std::vector< Symbol > Symbols
Definition: COFFYAML.h:102
SymbolComplexType
Definition: COFF.h:259
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Optional< CodeViewYAML::DebugHSection > DebugH
Definition: COFFYAML.h:71
Optional< PEHeader > OptionalHeader
Definition: COFFYAML.h:99
Optional< COFF::AuxiliarySectionDefinition > SectionDefinition
Definition: COFFYAML.h:86