1 : // Copyright 2012 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // This header is an extension to the cvinfo.h file from the CCI project.
16 :
17 : #ifndef SYZYGY_PE_CVINFO_EXT_H_
18 : #define SYZYGY_PE_CVINFO_EXT_H_
19 :
20 : #include <stdint.h>
21 : #include <windows.h>
22 :
23 : #include "syzygy/common/assertions.h"
24 : #include "third_party/cci/files/cvinfo.h"
25 :
26 : // TODO(siggi): Replace this with the bona-fide Microsoft file.
27 : #include "third_party/microsoft-pdb-copy/files/cvinfo.h"
28 :
29 m : namespace Microsoft_Cci_Pdb {
30 :
31 : // CodeView2 symbols. These are superseded in CodeView4 symbol streams.
32 : // Taken from the Visual C++ 5.0 Symbolic Debug Information Specification.
33 m : const uint16_t S_COMPILE_CV2 = 0x0001; // Compile flags symbol.
34 m : const uint16_t S_SSEARCH = 0x0005; // Start search.
35 m : const uint16_t S_SKIP = 0x0007; // Skip - Reserve symbol space.
36 m : const uint16_t S_CVRESERVE = 0x0008; // Reserved for CodeView internal use.
37 m : const uint16_t S_OBJNAME_CV2 = 0x0009; // Name of object file.
38 m : const uint16_t S_ENDARG = 0x000A; // End of arguments in function symbols.
39 m : const uint16_t S_COBOLUDT_CV2 = 0x000B; // Microfocus COBOL user-defined type.
40 m : const uint16_t S_MANYREG_CV2 = 0x000C; // Many register symbol.
41 m : const uint16_t S_RETURN = 0x000D; // Function return description.
42 m : const uint16_t S_ENTRYTHIS = 0x000E; // Description of this pointer at entry.
43 :
44 : // Symbols that are not in the enum in the cv_info file.
45 m : const uint16_t S_COMPILE3 = 0x113C; // Replacement for S_COMPILE2.
46 m : const uint16_t S_MSTOOLENV_V3 = 0x113D; // Environment block split off from
47 : // S_COMPILE2.
48 m : const uint16_t S_LOCAL_VS2013 = 0x113E; // Defines a local symbol in optimized
49 : // code.
50 :
51 : // Since VS2013 it seems that the compiler isn't emitting the same value as
52 : // those in cvinfo.h for the S_GPROC32 and S_LPROC32 types, the following 2
53 : // values should be used instead.
54 m : const uint16_t S_LPROC32_VS2013 = 0x1146;
55 m : const uint16_t S_GPROC32_VS2013 = 0x1147;
56 :
57 m : } // namespace Microsoft_Cci_Pdb
58 :
59 : // This macro enables the easy construction of switch statements over the
60 : // symbol type enum. It defines the case table, the first parameter of each
61 : // entry is the type of the symbol and the second one is the type of structure
62 : // used to represent this symbol.
63 : // NOTE: All _ST suffixed symbols are identical to those symbols without the
64 : // _ST suffix. However, the trailing string they contain is encoded as
65 : // uint16_t length prefixed string, versus a zero-terminated string.
66 : // NOTE: This overrides the association from S_FRAMECOOKIE to the FrameCookie
67 : // struct (associating FrameCookieSym instead) as observed data does not
68 : // match the cvinfo struct.
69 : #define SYM_TYPE_CASE_TABLE(decl) \
70 m : decl(S_COMPILE_CV2, CompileSymCV2) \
71 m : decl(S_SSEARCH, SearchSym) \
72 m : decl(S_SKIP, Unknown) \
73 m : decl(S_CVRESERVE, Unknown) \
74 m : decl(S_OBJNAME_CV2, ObjNameSym) \
75 m : decl(S_ENDARG, EndArgSym) \
76 m : decl(S_COBOLUDT_CV2, UdtSym) \
77 m : decl(S_MANYREG_CV2, ManyRegSym) \
78 m : decl(S_RETURN, ReturnSym) \
79 m : decl(S_ENTRYTHIS, EntryThisSym) \
80 m : decl(S_END, Unknown) \
81 m : decl(S_OEM, OemSymbol) \
82 m : decl(S_REGISTER_ST, Unknown) \
83 m : decl(S_CONSTANT_ST, Unknown) \
84 m : decl(S_UDT_ST, UdtSym) \
85 m : decl(S_COBOLUDT_ST, Unknown) \
86 m : decl(S_MANYREG_ST, Unknown) \
87 m : decl(S_BPREL32_ST, BpRelSym32) \
88 m : decl(S_LDATA32_ST, DatasSym32) \
89 m : decl(S_GDATA32_ST, DatasSym32) \
90 m : decl(S_PUB32_ST, DatasSym32) \
91 m : decl(S_LPROC32_ST, ProcSym32) \
92 m : decl(S_GPROC32_ST, ProcSym32) \
93 m : decl(S_VFTABLE32, VpathSym32) \
94 m : decl(S_REGREL32_ST, Unknown) \
95 m : decl(S_LTHREAD32_ST, Unknown) \
96 m : decl(S_GTHREAD32_ST, Unknown) \
97 m : decl(S_LPROCMIPS_ST, Unknown) \
98 m : decl(S_GPROCMIPS_ST, Unknown) \
99 m : decl(S_FRAMEPROC, FrameProcSym) \
100 m : decl(S_COMPILE2_ST, Unknown) \
101 m : decl(S_MANYREG2_ST, Unknown) \
102 m : decl(S_LPROCIA64_ST, Unknown) \
103 m : decl(S_GPROCIA64_ST, Unknown) \
104 m : decl(S_LOCALSLOT_ST, Unknown) \
105 m : decl(S_PARAMSLOT_ST, Unknown) \
106 m : decl(S_ANNOTATION, AnnotationSym) \
107 m : decl(S_GMANPROC_ST, Unknown) \
108 m : decl(S_LMANPROC_ST, Unknown) \
109 m : decl(S_RESERVED1, Unknown) \
110 m : decl(S_RESERVED2, Unknown) \
111 m : decl(S_RESERVED3, Unknown) \
112 m : decl(S_RESERVED4, Unknown) \
113 m : decl(S_LMANDATA_ST, Unknown) \
114 m : decl(S_GMANDATA_ST, Unknown) \
115 m : decl(S_MANFRAMEREL_ST, Unknown) \
116 m : decl(S_MANREGISTER_ST, Unknown) \
117 m : decl(S_MANSLOT_ST, Unknown) \
118 m : decl(S_MANMANYREG_ST, Unknown) \
119 m : decl(S_MANREGREL_ST, Unknown) \
120 m : decl(S_MANMANYREG2_ST, Unknown) \
121 m : decl(S_MANTYPREF, ManyTypRef) \
122 m : decl(S_UNAMESPACE_ST, Unknown) \
123 m : decl(S_ST_MAX, Unknown) \
124 m : decl(S_OBJNAME, ObjNameSym) \
125 m : decl(S_THUNK32, ThunkSym32) \
126 m : decl(S_BLOCK32, BlockSym32) \
127 m : decl(S_WITH32, WithSym32) \
128 m : decl(S_LABEL32, LabelSym32) \
129 m : decl(S_REGISTER, RegSym) \
130 m : decl(S_CONSTANT, ConstSym) \
131 m : decl(S_UDT, UdtSym) \
132 m : decl(S_COBOLUDT, UdtSym) \
133 m : decl(S_MANYREG, ManyRegSym) \
134 m : decl(S_BPREL32, BpRelSym32) \
135 m : decl(S_LDATA32, DatasSym32) \
136 m : decl(S_GDATA32, DatasSym32) \
137 m : decl(S_PUB32, PubSym32) \
138 m : decl(S_LPROC32, ProcSym32) \
139 m : decl(S_GPROC32, ProcSym32) \
140 m : decl(S_REGREL32, RegRel32) \
141 m : decl(S_LTHREAD32, ThreadSym32) \
142 m : decl(S_GTHREAD32, ThreadSym32) \
143 m : decl(S_LPROCMIPS, ProcSymMips) \
144 m : decl(S_GPROCMIPS, ProcSymMips) \
145 m : decl(S_COMPILE2, CompileSym) \
146 m : decl(S_MANYREG2, ManyRegSym2) \
147 m : decl(S_LPROCIA64, ProcSymIa64) \
148 m : decl(S_GPROCIA64, ProcSymIa64) \
149 m : decl(S_LOCALSLOT, SlotSym32) \
150 m : decl(S_PARAMSLOT, SlotSym32) \
151 m : decl(S_LMANDATA, DatasSym32) \
152 m : decl(S_GMANDATA, DatasSym32) \
153 m : decl(S_MANFRAMEREL, FrameRelSym) \
154 m : decl(S_MANREGISTER, AttrRegSym) \
155 m : decl(S_MANSLOT, AttrSlotSym) \
156 m : decl(S_MANMANYREG, AttrManyRegSym) \
157 m : decl(S_MANREGREL, AttrRegRel) \
158 m : decl(S_MANMANYREG2, AttrManyRegSym2) \
159 m : decl(S_UNAMESPACE, UnamespaceSym) \
160 m : decl(S_PROCREF, RefSym2) \
161 m : decl(S_DATAREF, RefSym2) \
162 m : decl(S_LPROCREF, RefSym2) \
163 m : decl(S_ANNOTATIONREF, Unknown) \
164 m : decl(S_TOKENREF, Unknown) \
165 m : decl(S_GMANPROC, ManProcSym) \
166 m : decl(S_LMANPROC, ManProcSym) \
167 m : decl(S_TRAMPOLINE, TrampolineSym) \
168 m : decl(S_MANCONSTANT, ConstSym) \
169 m : decl(S_ATTR_FRAMEREL, FrameRelSym) \
170 m : decl(S_ATTR_REGISTER, AttrRegSym) \
171 m : decl(S_ATTR_REGREL, AttrRegRel) \
172 m : decl(S_ATTR_MANYREG, AttrManyRegSym2) \
173 m : decl(S_SEPCODE, SepCodSym) \
174 m : decl(S_LOCAL, LocalSym) \
175 m : decl(S_DEFRANGE, DefRangeSym) \
176 m : decl(S_DEFRANGE2, DefRangeSym2) \
177 m : decl(S_SECTION, SectionSym) \
178 m : decl(S_COFFGROUP, CoffGroupSym) \
179 m : decl(S_EXPORT, ExportSym) \
180 m : decl(S_CALLSITEINFO, CallsiteInfo) \
181 m : decl(S_FRAMECOOKIE, FrameCookieSym) \
182 m : decl(S_DISCARDED, DiscardedSym) \
183 m : decl(S_COMPILE3, CompileSym2) \
184 m : decl(S_MSTOOLENV_V3, MSToolEnvV3) \
185 m : decl(S_LOCAL_VS2013, LocalSym2013) \
186 m : decl(S_DEFRANGE_REGISTER, DefrangeSymRegister) \
187 m : decl(S_DEFRANGE_FRAMEPOINTER_REL, DefRangeSymFramePointerRel) \
188 m : decl(S_DEFRANGE_SUBFIELD_REGISTER, DefRangeSymSubfieldRegister) \
189 m : decl(S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE, FPOffs2013) \
190 m : decl(S_DEFRANGE_REGISTER_REL, DefRangeSymRegisterRel) \
191 m : decl(S_LPROC32_VS2013, ProcSym32) \
192 m : decl(S_GPROC32_VS2013, ProcSym32) \
193 m : decl(S_INLINESITE, InlineSiteSym) \
194 m : decl(S_INLINESITE_END, Unknown)
195 :
196 : // This macro allows the easy construction of switch statements over the
197 : // numeric leaves types.
198 : #define NUMERIC_LEAVES_CASE_TABLE(decl) \
199 m : decl(LF_CHAR, LeafChar) \
200 m : decl(LF_SHORT, LeafShort) \
201 m : decl(LF_USHORT, LeafUShort) \
202 m : decl(LF_LONG, LeafLong) \
203 m : decl(LF_ULONG, LeafULong) \
204 m : decl(LF_REAL32, LeafReal32) \
205 m : decl(LF_REAL64, LeafReal64) \
206 m : decl(LF_REAL80, LeafReal80) \
207 m : decl(LF_REAL128, LeafReal128) \
208 m : decl(LF_QUADWORD, LeafQuad) \
209 m : decl(LF_UQUADWORD, LeafUQuad) \
210 m : decl(LF_COMPLEX32, LeafCmplx32) \
211 m : decl(LF_COMPLEX64, LeafCmplx64) \
212 m : decl(LF_COMPLEX80, LeafCmplx80) \
213 m : decl(LF_COMPLEX128, LeafCmplx128)
214 :
215 : // This macro allow the easy construction of switch statements over the leaf
216 : // enum. It define the case table, the first parameter of each entry is the type
217 : // of the leaf record and the second one is the type of structure used to
218 : // represent this leaf.
219 : #define LEAF_CASE_TABLE(decl) \
220 m : decl(LF_VTSHAPE, LeafVTShape) \
221 m : decl(LF_COBOL1, LeafCobol1) \
222 m : decl(LF_LABEL, LeafLabel) \
223 m : decl(LF_NULL, UnknownLeaf) \
224 m : decl(LF_NOTTRAN, UnknownLeaf) \
225 m : decl(LF_ENDPRECOMP, LeafEndPreComp) \
226 m : decl(LF_TYPESERVER_ST, UnknownLeaf) \
227 m : decl(LF_LIST, LeafList) \
228 m : decl(LF_REFSYM, LeafRefSym) \
229 m : decl(LF_ENUMERATE_ST, UnknownLeaf) \
230 m : decl(LF_TI16_MAX, UnknownLeaf) \
231 m : decl(LF_MODIFIER, LeafModifier) \
232 m : decl(LF_POINTER, LeafPointer) \
233 m : decl(LF_ARRAY_ST, UnknownLeaf) \
234 m : decl(LF_CLASS_ST, UnknownLeaf) \
235 m : decl(LF_STRUCTURE_ST, UnknownLeaf) \
236 m : decl(LF_UNION_ST, UnknownLeaf) \
237 m : decl(LF_ENUM_ST, UnknownLeaf) \
238 m : decl(LF_PROCEDURE, LeafProc) \
239 m : decl(LF_MFUNCTION, LeafMFunc) \
240 m : decl(LF_COBOL0, LeafCobol0) \
241 m : decl(LF_BARRAY, LeafBArray) \
242 m : decl(LF_DIMARRAY_ST, UnknownLeaf) \
243 m : decl(LF_VFTPATH, LeafVFTPath) \
244 m : decl(LF_PRECOMP_ST, UnknownLeaf) \
245 m : decl(LF_OEM, LeafOEM) \
246 m : decl(LF_ALIAS_ST, UnknownLeaf) \
247 m : decl(LF_OEM2, LeafOEM2) \
248 m : decl(LF_SKIP, LeafSkip) \
249 m : decl(LF_ARGLIST, LeafArgList) \
250 m : decl(LF_DEFARG_ST, UnknownLeaf) \
251 m : decl(LF_FIELDLIST, LeafFieldList) \
252 m : decl(LF_DERIVED, LeafDerived) \
253 m : decl(LF_BITFIELD, LeafBitfield) \
254 m : decl(LF_METHODLIST, LeafMethodList) \
255 m : decl(LF_DIMCONU, LeafDimCon) \
256 m : decl(LF_DIMCONLU, LeafDimCon) \
257 m : decl(LF_DIMVARU, LeafDimVar) \
258 m : decl(LF_DIMVARLU, LeafDimVar) \
259 m : decl(LF_BCLASS, LeafBClass) \
260 m : decl(LF_VBCLASS, LeafVBClass) \
261 m : decl(LF_IVBCLASS, LeafVBClass) \
262 m : decl(LF_FRIENDFCN_ST, UnknownLeaf) \
263 m : decl(LF_INDEX, LeafIndex) \
264 m : decl(LF_MEMBER_ST, UnknownLeaf) \
265 m : decl(LF_STMEMBER_ST, UnknownLeaf) \
266 m : decl(LF_METHOD_ST, UnknownLeaf) \
267 m : decl(LF_NESTTYPE_ST, UnknownLeaf) \
268 m : decl(LF_VFUNCTAB, LeafVFuncTab) \
269 m : decl(LF_FRIENDCLS, UnknownLeaf) \
270 m : decl(LF_ONEMETHOD_ST, UnknownLeaf) \
271 m : decl(LF_VFUNCOFF, LeafVFuncOff) \
272 m : decl(LF_NESTTYPEEX_ST, UnknownLeaf) \
273 m : decl(LF_MEMBERMODIFY_ST, UnknownLeaf) \
274 m : decl(LF_MANAGED_ST, UnknownLeaf) \
275 m : decl(LF_TYPESERVER, LeafTypeServer) \
276 m : decl(LF_ENUMERATE, LeafEnumerate) \
277 m : decl(LF_ARRAY, LeafArray) \
278 m : decl(LF_CLASS, LeafClass) \
279 m : decl(LF_STRUCTURE, LeafClass) \
280 m : decl(LF_UNION, LeafUnion) \
281 m : decl(LF_ENUM, LeafEnum) \
282 m : decl(LF_DIMARRAY, LeafDimArray) \
283 m : decl(LF_PRECOMP, LeafPreComp) \
284 m : decl(LF_ALIAS, LeafAlias) \
285 m : decl(LF_DEFARG, LeafDefArg) \
286 m : decl(LF_FRIENDFCN, LeafFriendFcn) \
287 m : decl(LF_MEMBER, LeafMember) \
288 m : decl(LF_STMEMBER, LeafSTMember) \
289 m : decl(LF_METHOD, LeafMethod) \
290 m : decl(LF_NESTTYPE, LeafNestType) \
291 m : decl(LF_ONEMETHOD, LeafOneMethod) \
292 m : decl(LF_NESTTYPEEX, LeafNestTypeEx) \
293 m : decl(LF_MEMBERMODIFY, LeafMemberModify) \
294 m : decl(LF_MANAGED, LeafManaged) \
295 m : decl(LF_TYPESERVER2, LeafTypeServer2) \
296 m : decl(LF_VARSTRING, LeafVarString) \
297 m : decl(LF_FUNC_ID, LeafFunctionId) \
298 m : decl(LF_MFUNC_ID, LeafMemberFunctionId) \
299 m : decl(LF_BUILDINFO, LeafBuildInfo) \
300 m : decl(LF_SUBSTR_LIST, LeafArgList) \
301 m : decl(LF_STRING_ID, LeafStringId) \
302 m : decl(LF_UDT_SRC_LINE, LeafUdtSourceLine) \
303 m : decl(LF_UDT_MOD_SRC_LINE, LeafUdtModuleSourceLine)
304 :
305 : // This macro allow the easy construction of switch statements over the special
306 : // types enum. It define the case table, the parameter of each entry is the type
307 : // of the special type record.
308 : #define SPECIAL_TYPE_CASE_TABLE(decl) \
309 m : decl(T_NOTYPE) \
310 m : decl(T_ABS) \
311 m : decl(T_SEGMENT) \
312 m : decl(T_VOID) \
313 m : decl(T_HRESULT) \
314 m : decl(T_32PHRESULT) \
315 m : decl(T_64PHRESULT) \
316 m : decl(T_PVOID) \
317 m : decl(T_PFVOID) \
318 m : decl(T_PHVOID) \
319 m : decl(T_32PVOID) \
320 m : decl(T_64PVOID) \
321 m : decl(T_CURRENCY) \
322 m : decl(T_NOTTRANS) \
323 m : decl(T_BIT) \
324 m : decl(T_PASCHAR) \
325 m : decl(T_CHAR) \
326 m : decl(T_32PCHAR) \
327 m : decl(T_64PCHAR) \
328 m : decl(T_UCHAR) \
329 m : decl(T_32PUCHAR) \
330 m : decl(T_64PUCHAR) \
331 m : decl(T_RCHAR) \
332 m : decl(T_32PRCHAR) \
333 m : decl(T_64PRCHAR) \
334 m : decl(T_WCHAR) \
335 m : decl(T_32PWCHAR) \
336 m : decl(T_64PWCHAR) \
337 m : decl(T_INT1) \
338 m : decl(T_32PINT1) \
339 m : decl(T_64PINT1) \
340 m : decl(T_UINT1) \
341 m : decl(T_32PUINT1) \
342 m : decl(T_64PUINT1) \
343 m : decl(T_SHORT) \
344 m : decl(T_32PSHORT) \
345 m : decl(T_64PSHORT) \
346 m : decl(T_USHORT) \
347 m : decl(T_32PUSHORT) \
348 m : decl(T_64PUSHORT) \
349 m : decl(T_INT2) \
350 m : decl(T_32PINT2) \
351 m : decl(T_64PINT2) \
352 m : decl(T_UINT2) \
353 m : decl(T_32PUINT2) \
354 m : decl(T_64PUINT2) \
355 m : decl(T_LONG) \
356 m : decl(T_ULONG) \
357 m : decl(T_32PLONG) \
358 m : decl(T_32PULONG) \
359 m : decl(T_64PLONG) \
360 m : decl(T_64PULONG) \
361 m : decl(T_INT4) \
362 m : decl(T_32PINT4) \
363 m : decl(T_64PINT4) \
364 m : decl(T_UINT4) \
365 m : decl(T_32PUINT4) \
366 m : decl(T_64PUINT4) \
367 m : decl(T_QUAD) \
368 m : decl(T_32PQUAD) \
369 m : decl(T_64PQUAD) \
370 m : decl(T_UQUAD) \
371 m : decl(T_32PUQUAD) \
372 m : decl(T_64PUQUAD) \
373 m : decl(T_INT8) \
374 m : decl(T_32PINT8) \
375 m : decl(T_64PINT8) \
376 m : decl(T_UINT8) \
377 m : decl(T_32PUINT8) \
378 m : decl(T_64PUINT8) \
379 m : decl(T_OCT) \
380 m : decl(T_32POCT) \
381 m : decl(T_64POCT) \
382 m : decl(T_UOCT) \
383 m : decl(T_32PUOCT) \
384 m : decl(T_64PUOCT) \
385 m : decl(T_INT16) \
386 m : decl(T_32PINT16) \
387 m : decl(T_64PINT16) \
388 m : decl(T_UINT16) \
389 m : decl(T_32PUINT16) \
390 m : decl(T_64PUINT16) \
391 m : decl(T_REAL32) \
392 m : decl(T_32PREAL32) \
393 m : decl(T_64PREAL32) \
394 m : decl(T_REAL64) \
395 m : decl(T_32PREAL64) \
396 m : decl(T_64PREAL64) \
397 m : decl(T_REAL80) \
398 m : decl(T_32PREAL80) \
399 m : decl(T_64PREAL80) \
400 m : decl(T_REAL128) \
401 m : decl(T_32PREAL128) \
402 m : decl(T_64PREAL128) \
403 m : decl(T_CPLX32) \
404 m : decl(T_32PCPLX32) \
405 m : decl(T_64PCPLX32) \
406 m : decl(T_CPLX64) \
407 m : decl(T_32PCPLX64) \
408 m : decl(T_64PCPLX64) \
409 m : decl(T_CPLX80) \
410 m : decl(T_32PCPLX80) \
411 m : decl(T_64PCPLX80) \
412 m : decl(T_CPLX128) \
413 m : decl(T_32PCPLX128) \
414 m : decl(T_64PCPLX128) \
415 m : decl(T_BOOL08) \
416 m : decl(T_32PBOOL08) \
417 m : decl(T_64PBOOL08) \
418 m : decl(T_BOOL16) \
419 m : decl(T_32PBOOL16) \
420 m : decl(T_64PBOOL16) \
421 m : decl(T_BOOL32) \
422 m : decl(T_32PBOOL32) \
423 m : decl(T_64PBOOL32) \
424 m : decl(T_BOOL64) \
425 m : decl(T_32PBOOL64) \
426 m : decl(T_64PBOOL64)
427 :
428 : // This macro allow the easy construction of switch statements over the special
429 : // types enum when constructing their names and sizes.
430 : #define SPECIAL_TYPE_NAME_CASE_TABLE(decl) \
431 m : decl(T_NOTYPE, NoType, 0) \
432 m : decl(T_ABS, Abs, 0) \
433 m : decl(T_SEGMENT, Segment, 0) \
434 m : decl(T_VOID, void, 0) \
435 m : decl(T_PVOID, nullptr_t, 0) \
436 m : decl(T_HRESULT, HRESULT, 4) \
437 m : decl(T_CURRENCY, Currency, 8) \
438 m : decl(T_NOTTRANS, NotTransposed, 0) \
439 m : decl(T_BIT, Bit, 0) \
440 m : decl(T_PASCHAR, char, 1) \
441 m : decl(T_CHAR, int8_t, 1) \
442 m : decl(T_UCHAR, uint8_t, 1) \
443 m : decl(T_RCHAR, char, 1) \
444 m : decl(T_WCHAR, wchar_t, 2) \
445 m : decl(T_INT1, int8_t, 1) \
446 m : decl(T_UINT1, uint8_t, 1) \
447 m : decl(T_SHORT, int16_t, 2) \
448 m : decl(T_USHORT, uint16_t, 2) \
449 m : decl(T_INT2, int16_t, 2) \
450 m : decl(T_UINT2, uint16_t, 2) \
451 m : decl(T_LONG, int32_t, 4) \
452 m : decl(T_ULONG, uint32_t, 4) \
453 m : decl(T_INT4, int32_t, 4) \
454 m : decl(T_UINT4, uint32_t, 4) \
455 m : decl(T_QUAD, int64_t, 8) \
456 m : decl(T_UQUAD, uint64_t, 8) \
457 m : decl(T_INT8, int64_t, 8) \
458 m : decl(T_UINT8, uint64_t, 8) \
459 m : decl(T_OCT, int128_t, 16) \
460 m : decl(T_UOCT, uint128_t, 16) \
461 m : decl(T_INT16, int128_t, 16) \
462 m : decl(T_UINT16, uint128_t, 16) \
463 m : decl(T_REAL32, float, 4) \
464 m : decl(T_REAL64, double, 8) \
465 m : decl(T_REAL80, double80, 10) \
466 m : decl(T_REAL128, double128, 16) \
467 m : decl(T_CPLX32, Complex32, 8) \
468 m : decl(T_CPLX64, Complex64, 16) \
469 m : decl(T_CPLX80, Complex80, 20) \
470 m : decl(T_CPLX128, Complex128, 32) \
471 m : decl(T_BOOL08, bool, 1) \
472 m : decl(T_BOOL16, Bool16, 2) \
473 m : decl(T_BOOL32, Bool32, 4) \
474 m : decl(T_BOOL64, Bool64, 8)
475 :
476 : // All of the data structures below need to have tight alignment so that they
477 : // can be overlaid directly onto byte streams.
478 : #pragma pack(push, 1)
479 :
480 : // This structure represent a bitfields for a leaf member attribute field as
481 : // it is describet in the document "Microsoft Symbol and Type Information". Here
482 : // is the bit format:
483 : // mprop :3 Specifies the properties for methods
484 : // 0 Vanilla method
485 : // 1 Virtual method
486 : // 2 Static method
487 : // 3 Friend method
488 : // 4 Introducing virtual method
489 : // 5 Pure virtual method
490 : // 6 Pure introducing virtual method
491 : // 7 Reserved
492 : // pseudo :1 True if the method is never instantiated by the compiler
493 : // noinherit :1 True if the class cannot be inherited
494 : // noconstruct :1 True if the class cannot be constructed
495 : // compgenx :1 True if compiler generated fcn and does exist.
496 : // sealed :1 True if method cannot be overridden.
497 : // unused :6
498 m : union LeafMemberAttributeField {
499 : // This is effectively the same as CV_access_e in cvconst.h, but with a value
500 : // defined for 0.
501 m : enum AccessProtection {
502 m : no_access_protection = 0,
503 m : private_access = 1,
504 m : protected_access = 2,
505 m : public_access = 3,
506 m : };
507 m : uint16_t raw;
508 m : struct {
509 m : uint16_t access : 2; // Of type AccessProtection.
510 m : uint16_t mprop : 3; // Of type CV_methodprop.
511 m : uint16_t pseudo : 1;
512 m : uint16_t noinherit : 1;
513 m : uint16_t noconstruct : 1;
514 m : uint16_t compgenx : 1;
515 m : uint16_t sealed : 1;
516 m : uint16_t unused : 6;
517 m : };
518 m : };
519 : // We coerce a stream of bytes to this structure, so we require it to be
520 : // exactly 2 bytes in size.
521 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LeafMemberAttributeField, 2);
522 :
523 : // This structure represent a bitfield for a leaf property field.
524 m : union LeafPropertyField {
525 m : uint16_t raw;
526 m : struct {
527 m : uint16_t packed : 1;
528 m : uint16_t ctor : 1;
529 m : uint16_t ovlops : 1;
530 m : uint16_t isnested : 1;
531 m : uint16_t cnested : 1;
532 m : uint16_t opassign : 1;
533 m : uint16_t opcast : 1;
534 m : uint16_t fwdref : 1;
535 m : uint16_t scoped : 1;
536 m : uint16_t decorated_name_present : 1;
537 m : uint16_t reserved : 6;
538 m : };
539 m : };
540 : // We coerce a stream of bytes to this structure, so we require it to be
541 : // exactly 2 bytes in size.
542 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LeafPropertyField, 2);
543 :
544 : // This structure represent a bitfield for a leaf pointer attribute.
545 m : union LeafPointerAttribute {
546 m : uint32_t raw;
547 m : struct {
548 m : uint32_t ptrtype : 5; // Of type CV_ptrtype.
549 m : uint32_t ptrmode : 3; // Of type CV_ptrmode.
550 m : uint32_t isflat32 : 1;
551 m : uint32_t isvolatile : 1;
552 m : uint32_t isconst : 1;
553 m : uint32_t isunaligned : 1;
554 m : uint32_t isrestrict : 1;
555 m : uint32_t reserved : 19;
556 m : };
557 m : };
558 : // We coerce a stream of bytes to this structure, so we require it to be
559 : // exactly 4 bytes in size.
560 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LeafPointerAttribute, 4);
561 :
562 : // This structure represent a bitfield for a leaf modifier attribute.
563 m : union LeafModifierAttribute {
564 m : uint16_t raw;
565 m : struct {
566 m : uint16_t mod_const : 1;
567 m : uint16_t mod_volatile : 1;
568 m : uint16_t mod_unaligned : 1;
569 m : uint16_t reserved : 13;
570 m : };
571 m : };
572 : // We coerce a stream of bytes to this structure, so we require it to be
573 : // exactly 2 bytes in size.
574 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LeafModifierAttribute, 2);
575 :
576 : // This defines flags used in compiland details. See COMPILANDSYM_FLAGS for
577 : // detail.
578 m : union CompileSymFlags {
579 m : uint32_t raw;
580 m : struct {
581 : // Language index. See CV_CFL_LANG.
582 m : uint16_t iLanguage : 8;
583 : // Compiled with edit and continue support.
584 m : uint16_t fEC : 1;
585 : // Not compiled with debug info.
586 m : uint16_t fNoDbgInfo : 1;
587 : // Compiled with LTCG.
588 m : uint16_t fLTCG : 1;
589 : // Compiled with -Bzalign.
590 m : uint16_t fNoDataAlign : 1;
591 : // Managed code/data present.
592 m : uint16_t fManagedPresent : 1;
593 : // Compiled with /GS.
594 m : uint16_t fSecurityChecks : 1;
595 : // Compiled with /hotpatch.
596 m : uint16_t fHotPatch : 1;
597 : // Converted with CVTCIL.
598 m : uint16_t fCVTCIL : 1;
599 : // MSIL netmodule
600 m : uint16_t fMSILModule : 1;
601 m : uint16_t reserved : 15;
602 m : };
603 m : };
604 : // We coerce a stream of bytes to this structure, so we require it to be
605 : // exactly 4 bytes in size.
606 m : COMPILE_ASSERT_IS_POD_OF_SIZE(CompileSymFlags, 4);
607 :
608 : // Altough S_FRAMECOOKIE is supposed to use the cvinfo FrameCookie struct, in
609 : // practice we observe a different struct.
610 m : struct FrameCookieSym {
611 m : uint32_t off;
612 m : uint16_t reg;
613 m : uint16_t cookietype;
614 m : };
615 m : COMPILE_ASSERT_IS_POD_OF_SIZE(FrameCookieSym, 8);
616 :
617 : // This is a new compiland details symbol type seen in MSVS 2010 and later.
618 m : struct CompileSym2 {
619 : // uint16_t reclen; // Record length.
620 : // uint16_t rectyp; // S_COMPILE3.
621 m : CompileSymFlags flags;
622 : // Target processor. See CV_CPU_TYPE_e enum.
623 m : uint16_t machine;
624 : // Front-end major version number.
625 m : uint16_t verFEMajor;
626 : // Front-end minor version number.
627 m : uint16_t verFEMinor;
628 : // Front-end build version number.
629 m : uint16_t verFEBuild;
630 : // Front-end revision number.
631 m : uint16_t verFERevision;
632 : // Back-end major version number.
633 m : uint16_t verMajor;
634 : // Back-end minor version number.
635 m : uint16_t verMinor;
636 : // Back-end build version number.
637 m : uint16_t verBuild;
638 : // Back-end revision number.
639 m : uint16_t verRevision;
640 : // Zero-terminated compiler version string. This is followed by zero or more
641 : // zero-terminated strings 'verArgs'. The whole list is terminated by an
642 : // empty verArg string (a double-zero).
643 m : char verSt[1];
644 m : };
645 m : COMPILE_ASSERT_IS_POD_OF_SIZE(CompileSym2, 23);
646 :
647 : // This is a new compiland details symbol type seen in MSVS 2010 and later.
648 m : struct MSToolEnvV3 {
649 : // uint16_t reclen; // Record length.
650 : // uint16_t rectyp; // S_MSTOOLENV_V3.
651 m : char leading_zero;
652 : // An array of key-value pairs, encoded as null terminated strings.
653 m : char key_values[1];
654 m : };
655 m : COMPILE_ASSERT_IS_POD_OF_SIZE(MSToolEnvV3, 2);
656 :
657 : // Length prefixed string.
658 m : struct LPString {
659 m : uint8_t length;
660 m : uint8_t string[1];
661 m : };
662 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LPString, 2);
663 :
664 : // Symbols seen in CodeView2 symbol streams.
665 m : struct CompileSymCV2 {
666 : // Machine type. See CV_CPU_TYPE_e enum.
667 m : uint8_t machine;
668 m : union {
669 : // Raw flags.
670 m : uint8_t flags[3];
671 : // Parsed flags.
672 m : struct {
673 : // Language index. See CV_CFL_LANG.
674 m : uint8_t language : 8;
675 m : uint8_t pcode_present : 1;
676 : // 0: ???
677 : // 1: ANSI C floating point rules.
678 : // 2-3: Reserved.
679 m : uint8_t float_precision : 2;
680 : // 0: Hardware processor.
681 : // 1: Emulator.
682 : // 2: Altmath.
683 : // 3: Reserved.
684 m : uint8_t float_package : 2;
685 : // 0: Near.
686 : // 1: Far.
687 : // 2: Huge.
688 : // 3-7: Reserved.
689 m : uint8_t ambient_data : 3;
690 m : uint8_t ambient_code : 3;
691 : // Compiled for 32-bit addresses.
692 m : uint8_t mode32 : 1;
693 m : uint8_t reserved : 4;
694 m : };
695 m : };
696 : // Length-prefixed version string.
697 m : LPString version;
698 m : };
699 m : COMPILE_ASSERT_IS_POD_OF_SIZE(CompileSymCV2, 6);
700 :
701 : // This defines flags used for local variables. See CV_LVARFLAGS for detail.
702 m : union LocalVarFlags {
703 m : uint16_t raw;
704 m : struct {
705 m : uint16_t fIsParam : 1;
706 m : uint16_t fAddrTaken : 1;
707 m : uint16_t fCompGenx : 1;
708 m : uint16_t fIsAggregate : 1;
709 m : uint16_t fIsAggregated : 1;
710 m : uint16_t fIsAliased : 1;
711 m : uint16_t fIsAlias : 1;
712 m : uint16_t fIsRetValue : 1; // represents a function return value
713 m : uint16_t fIsOptimizedOut : 1; // variable has no lifetimes
714 m : uint16_t fIsEnregGlob : 1; // variable is an enregistered global
715 m : uint16_t fIsEnregStat : 1; // variable is an enregistered static
716 m : uint16_t reserved : 5;
717 m : };
718 m : };
719 : // We coerce a stream of bytes to this structure, so we require it to be
720 : // exactly 2 bytes in size.
721 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LocalVarFlags, 2);
722 :
723 : // New symbol used for local symbols.
724 m : struct LocalSym2013 {
725 m : uint32_t typind; // (type index) type index
726 m : LocalVarFlags flags; // local var flags
727 m : uint8_t name[1]; // Name of this symbol.
728 m : };
729 m : COMPILE_ASSERT_IS_POD_OF_SIZE(LocalSym2013, 7);
730 :
731 : // Frame pointer offset for LocalSym2013 variable.
732 m : struct FPOffs2013 {
733 m : int offs;
734 m : };
735 m : COMPILE_ASSERT_IS_POD_OF_SIZE(FPOffs2013, 4);
736 :
737 : // Range for symbol address as register + offset.
738 m : struct DefRangeSymRegisterRel {
739 m : uint16_t baseReg; // Register to hold the base pointer of the symbol.
740 m : uint16_t spilledUdtMember : 1; // Spilled member for s.i.
741 m : uint16_t padding : 3; // Padding for future use.
742 m : uint16_t offsetParent : 12; // Offset in parent variable.
743 m : int32_t offBasePointer; // Offset to register.
744 m : CvLvarAddrRange range; // Range of addresses where this program is valid.
745 m : CvLvarAddrGap gaps[1]; // The value is not available in following gaps.
746 m : };
747 m : COMPILE_ASSERT_IS_POD_OF_SIZE(DefRangeSymRegisterRel, 20);
748 :
749 : // Defines flags used for export symbols, see EXPORTSYM_FLAGS.
750 m : union ExportVarFlags {
751 m : uint16_t raw;
752 m : struct {
753 m : uint16_t fConstant : 1;
754 m : uint16_t fData : 1;
755 m : uint16_t fPrivate : 1;
756 m : uint16_t fNoName : 1;
757 m : uint16_t fOrdinal : 1;
758 m : uint16_t fForwarder : 1;
759 m : uint16_t reserved : 10;
760 m : };
761 m : };
762 : // We coerce a stream of bytes to this structure, so we require it to be
763 : // exactly 2 bytes in size.
764 m : COMPILE_ASSERT_IS_POD_OF_SIZE(ExportVarFlags, 2);
765 :
766 : // Defines flags used for fram proc symbols, see FRAMEPROCSYM_FLAGS.
767 m : union FrameProcSymFlags {
768 m : uint16_t raw;
769 m : struct {
770 m : uint16_t fHasAlloca : 1;
771 m : uint16_t fHasSetJmp : 1;
772 m : uint16_t fHasLongJmp : 1;
773 m : uint16_t fHasInlAsm : 1;
774 m : uint16_t fHasEH : 1;
775 m : uint16_t fInlSpec : 1;
776 m : uint16_t fHasSEH : 1;
777 m : uint16_t fNaked : 1;
778 m : uint16_t fSecurityChecks : 1;
779 m : uint16_t fAsyncEH : 1;
780 m : uint16_t fGSNoStackOrdering : 1;
781 m : uint16_t fWasInlined : 1;
782 m : uint16_t reserved : 4;
783 m : };
784 m : };
785 : // We coerce a stream of bytes to this structure, so we require it to be
786 : // exactly 2 bytes in size.
787 m : COMPILE_ASSERT_IS_POD_OF_SIZE(FrameProcSymFlags, 2);
788 :
789 : #pragma pack(pop)
790 :
791 : #endif // SYZYGY_PE_CVINFO_EXT_H_
|