LLVM  9.0.0svn
RawTypes.h
Go to the documentation of this file.
1 //===- RawTypes.h -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
10 #define LLVM_DEBUGINFO_PDB_RAW_RAWTYPES_H
11 
14 #include "llvm/Support/Endian.h"
15 
16 namespace llvm {
17 namespace pdb {
18 // This struct is defined as "SO" in langapi/include/pdb.h.
19 struct SectionOffset {
22  char Padding[2];
23 };
24 
25 /// Header of the hash tables found in the globals and publics sections.
26 /// Based on GSIHashHdr in
27 /// https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
28 struct GSIHashHeader {
29  enum : unsigned {
30  HdrSignature = ~0U,
31  HdrVersion = 0xeffe0000 + 19990810,
32  };
37 };
38 
39 // This is HRFile.
40 struct PSHashRecord {
41  support::ulittle32_t Off; // Offset in the symbol record stream
43 };
44 
45 // This struct is defined as `SC` in include/dbicommon.h
48  char Padding[2];
53  char Padding2[2];
56 };
57 
58 // This struct is defined as `SC2` in include/dbicommon.h
60  // To guarantee SectionContrib2 is standard layout, we cannot use inheritance.
63 };
64 
65 // This corresponds to the `OMFSegMap` structure.
66 struct SecMapHeader {
67  support::ulittle16_t SecCount; // Number of segment descriptors in table
68  support::ulittle16_t SecCountLog; // Number of logical segment descriptors
69 };
70 
71 // This corresponds to the `OMFSegMapDesc` structure. The definition is not
72 // present in the reference implementation, but the layout is derived from
73 // code that accesses the fields.
74 struct SecMapEntry {
75  support::ulittle16_t Flags; // Descriptor flags. See OMFSegDescFlags
76  support::ulittle16_t Ovl; // Logical overlay number.
77  support::ulittle16_t Group; // Group index into descriptor array.
79  support::ulittle16_t SecName; // Byte index of the segment or group name
80  // in the sstSegName table, or 0xFFFF.
81  support::ulittle16_t ClassName; // Byte index of the class name in the
82  // sstSegName table, or 0xFFFF.
83  support::ulittle32_t Offset; // Byte offset of the logical segment
84  // within the specified physical segment.
85  // If group is set in flags, offset is the
86  // offset of the group.
87  support::ulittle32_t SecByteLength; // Byte count of the segment or group.
88 };
89 
90 /// Some of the values are stored in bitfields. Since this needs to be portable
91 /// across compilers and architectures (big / little endian in particular) we
92 /// can't use the actual structures below, but must instead do the shifting
93 /// and masking ourselves. The struct definitions are provided for reference.
94 struct DbiFlags {
95  /// uint16_t IncrementalLinking : 1; // True if linked incrementally
96  /// uint16_t IsStripped : 1; // True if private symbols were
97  /// stripped.
98  /// uint16_t HasCTypes : 1; // True if linked with /debug:ctypes.
99  /// uint16_t Reserved : 13;
100  static const uint16_t FlagIncrementalMask = 0x0001;
101  static const uint16_t FlagStrippedMask = 0x0002;
102  static const uint16_t FlagHasCTypesMask = 0x0004;
103 };
104 
105 struct DbiBuildNo {
106  /// uint16_t MinorVersion : 8;
107  /// uint16_t MajorVersion : 7;
108  /// uint16_t NewVersionFormat : 1;
109  static const uint16_t BuildMinorMask = 0x00FF;
110  static const uint16_t BuildMinorShift = 0;
111 
112  static const uint16_t BuildMajorMask = 0x7F00;
113  static const uint16_t BuildMajorShift = 8;
114 
115  static const uint16_t NewVersionFormatMask = 0x8000;
116 };
117 
118 /// The fixed size header that appears at the beginning of the DBI Stream.
122 
123  /// How "old" is this DBI Stream. Should match the age of the PDB InfoStream.
125 
126  /// Global symbol stream #
128 
129  /// See DbiBuildNo structure.
131 
132  /// Public symbols stream #
134 
135  /// version of mspdbNNN.dll
137 
138  /// Symbol records stream #
140 
141  /// rbld number of mspdbNNN.dll
143 
144  /// Size of module info stream
146 
147  /// Size of sec. contrib stream
149 
150  /// Size of sec. map substream
152 
153  /// Size of file info substream
155 
156  /// Size of type server map
158 
159  /// Index of MFC Type Server
161 
162  /// Size of DbgHeader info
164 
165  /// Size of EC stream (what is EC?)
167 
168  /// See DbiFlags enum.
170 
171  /// See PDB_MachineType enum.
173 
174  /// Pad to 64 bytes
176 };
177 static_assert(sizeof(DbiStreamHeader) == 64, "Invalid DbiStreamHeader size!");
178 
179 /// The header preceding the File Info Substream of the DBI stream.
181  /// Total # of modules, should match number of records in the ModuleInfo
182  /// substream.
184 
185  /// Total # of source files. This value is not accurate because PDB actually
186  /// supports more than 64k source files, so we ignore it and compute the value
187  /// from other stream fields.
189 
190  /// Following this header the File Info Substream is laid out as follows:
191  /// ulittle16_t ModIndices[NumModules];
192  /// ulittle16_t ModFileCounts[NumModules];
193  /// ulittle32_t FileNameOffsets[NumSourceFiles];
194  /// char Names[][NumSourceFiles];
195  /// with the caveat that `NumSourceFiles` cannot be trusted, so
196  /// it is computed by summing the `ModFileCounts` array.
197 };
198 
199 struct ModInfoFlags {
200  /// uint16_t fWritten : 1; // True if DbiModuleDescriptor is dirty
201  /// uint16_t fECEnabled : 1; // Is EC symbolic info present? (What is EC?)
202  /// uint16_t unused : 6; // Reserved
203  /// uint16_t iTSM : 8; // Type Server Index for this module
204  static const uint16_t HasECFlagMask = 0x2;
205 
206  static const uint16_t TypeServerIndexMask = 0xFF00;
207  static const uint16_t TypeServerIndexShift = 8;
208 };
209 
210 /// The header preceding each entry in the Module Info substream of the DBI
211 /// stream. Corresponds to the type MODI in the reference implementation.
213  /// Currently opened module. This field is a pointer in the reference
214  /// implementation, but that won't work on 64-bit systems, and anyway it
215  /// doesn't make sense to read a pointer from a file. For now it is unused,
216  /// so just ignore it.
218 
219  /// First section contribution of this module.
221 
222  /// See ModInfoFlags definition.
224 
225  /// Stream Number of module debug info
227 
228  /// Size of local symbol debug info in above stream
230 
231  /// Size of C11 line number info in above stream
233 
234  /// Size of C13 line number info in above stream
236 
237  /// Number of files contributing to this module
239 
240  /// Padding so the next field is 4-byte aligned.
241  char Padding1[2];
242 
243  /// Array of [0..NumFiles) DBI name buffer offsets. In the reference
244  /// implementation this field is a pointer. But since you can't portably
245  /// serialize a pointer, on 64-bit platforms they copy all the values except
246  /// this one into the 32-bit version of the struct and use that for
247  /// serialization. Regardless, this field is unused, it is only there to
248  /// store a pointer that can be accessed at runtime.
250 
251  /// Name Index for src file name
253 
254  /// Name Index for path to compiler PDB
256 
257  /// Following this header are two zero terminated strings.
258  /// char ModuleName[];
259  /// char ObjFileName[];
260 };
261 
262 // This is PSGSIHDR struct defined in
263 // https://github.com/Microsoft/microsoft-pdb/blob/master/PDB/dbi/gsi.h
270  char Padding[2];
273 };
274 
275 // The header preceding the global TPI stream.
276 // This corresponds to `HDR` in PDB/dbi/tpi.h.
278  struct EmbeddedBuf {
281  };
282 
288 
289  // The following members correspond to `TpiHash` in PDB/dbi/tpi.h.
294 
298 };
299 
301 const uint32_t MaxTpiHashBuckets = 0x40000;
302 
303 /// The header preceding the global PDB Stream (Stream 1)
309 };
310 
311 /// The header preceding the /names stream.
313  support::ulittle32_t Signature; // PDBStringTableSignature
315  support::ulittle32_t ByteSize; // Number of bytes of names buffer.
316 };
317 
319 
320 /// The header preceding the /src/headerblock stream.
322  support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration.
323  support::ulittle32_t Size; // Size of entire stream.
324  uint64_t FileTime; // Time stamp (Windows FILETIME format).
326  uint8_t Padding[44]; // Pad to 64 bytes.
327 };
328 static_assert(sizeof(SrcHeaderBlockHeader) == 64, "Incorrect struct size!");
329 
330 /// A single file record entry within the /src/headerblock stream.
332  support::ulittle32_t Size; // Record Length.
333  support::ulittle32_t Version; // PdbRaw_SrcHeaderBlockVer enumeration.
334  support::ulittle32_t CRC; // CRC of the original file contents.
335  support::ulittle32_t FileSize; // Size of original source file.
336  support::ulittle32_t FileNI; // String table index of file name.
337  support::ulittle32_t ObjNI; // String table index of object name.
338  support::ulittle32_t VFileNI; // String table index of virtual file name.
339  uint8_t Compression; // PDB_SourceCompression enumeration.
340  uint8_t IsVirtual; // Is this a virtual file (injected)?
341  short Padding; // Pad to 4 bytes.
342  char Reserved[8];
343 };
344 
345 static_assert(sizeof(SrcHeaderBlockEntry) == 40, "Incorrect struct size!");
346 
347 } // namespace pdb
348 } // namespace llvm
349 
350 #endif
support::little32_t FileInfoSize
Size of file info substream.
Definition: RawTypes.h:154
support::ulittle32_t ByteSize
Definition: RawTypes.h:315
support::ulittle32_t VerSignature
Definition: RawTypes.h:33
support::ulittle32_t Offset
Definition: RawTypes.h:83
support::ulittle16_t Ovl
Definition: RawTypes.h:76
This class represents lattice values for constants.
Definition: AllocatorList.h:23
support::ulittle16_t NumFiles
Number of files contributing to this module.
Definition: RawTypes.h:238
support::ulittle32_t SrcFileNameNI
Name Index for src file name.
Definition: RawTypes.h:252
support::ulittle32_t HashVersion
Definition: RawTypes.h:314
support::little32_t VersionSignature
Definition: RawTypes.h:120
support::ulittle16_t HashStreamIndex
Definition: RawTypes.h:290
support::ulittle32_t Age
Definition: RawTypes.h:325
EmbeddedBuf IndexOffsetBuffer
Definition: RawTypes.h:296
support::ulittle32_t NumHashBuckets
Definition: RawTypes.h:293
support::ulittle32_t Off
Definition: RawTypes.h:20
support::ulittle32_t Version
Definition: RawTypes.h:305
support::ulittle16_t GlobalSymbolStreamIndex
Global symbol stream #.
Definition: RawTypes.h:127
support::ulittle32_t MFCTypeServerIndex
Index of MFC Type Server.
Definition: RawTypes.h:160
support::ulittle32_t SymBytes
Size of local symbol debug info in above stream.
Definition: RawTypes.h:229
support::ulittle32_t VerHdr
Definition: RawTypes.h:34
support::ulittle16_t Frame
Definition: RawTypes.h:78
support::ulittle32_t NumThunks
Definition: RawTypes.h:267
support::ulittle32_t ISectCoff
Definition: RawTypes.h:62
support::ulittle32_t TypeRecordBytes
Definition: RawTypes.h:287
support::ulittle16_t BuildNumber
See DbiBuildNo structure.
Definition: RawTypes.h:130
support::little32_t TypeServerSize
Size of type server map.
Definition: RawTypes.h:157
Header of the hash tables found in the globals and publics sections.
Definition: RawTypes.h:28
support::ulittle32_t Signature
Definition: RawTypes.h:306
support::ulittle32_t SecByteLength
Definition: RawTypes.h:87
support::ulittle16_t ISectThunkTable
Definition: RawTypes.h:269
support::ulittle16_t Group
Definition: RawTypes.h:77
support::ulittle32_t CRef
Definition: RawTypes.h:42
support::little32_t SectionMapSize
Size of sec. map substream.
Definition: RawTypes.h:151
support::ulittle16_t Isect
Definition: RawTypes.h:21
support::ulittle32_t PdbFilePathNI
Name Index for path to compiler PDB.
Definition: RawTypes.h:255
This represents the 'GUID' type from windows.h.
Definition: GUID.h:21
The fixed size header that appears at the beginning of the DBI Stream.
Definition: RawTypes.h:119
support::ulittle32_t Off
Definition: RawTypes.h:41
The header preceding the /src/headerblock stream.
Definition: RawTypes.h:321
support::little32_t ECSubstreamSize
Size of EC stream (what is EC?)
Definition: RawTypes.h:166
support::ulittle16_t Flags
See ModInfoFlags definition.
Definition: RawTypes.h:223
The header preceding the /names stream.
Definition: RawTypes.h:312
SectionContrib SC
First section contribution of this module.
Definition: RawTypes.h:220
support::ulittle32_t SymHash
Definition: RawTypes.h:265
support::ulittle32_t Size
Definition: RawTypes.h:332
support::ulittle32_t Version
Definition: RawTypes.h:333
Some of the values are stored in bitfields.
Definition: RawTypes.h:94
support::ulittle32_t FileNI
Definition: RawTypes.h:336
support::ulittle32_t NumBuckets
Definition: RawTypes.h:36
support::ulittle32_t C13Bytes
Size of C13 line number info in above stream.
Definition: RawTypes.h:235
support::ulittle16_t PdbDllRbld
rbld number of mspdbNNN.dll
Definition: RawTypes.h:142
support::ulittle32_t Age
Definition: RawTypes.h:307
support::ulittle32_t RelocCrc
Definition: RawTypes.h:55
support::little32_t Size
Definition: RawTypes.h:50
support::ulittle16_t Imod
Definition: RawTypes.h:52
support::ulittle32_t TypeIndexEnd
Definition: RawTypes.h:286
The header preceding each entry in the Module Info substream of the DBI stream.
Definition: RawTypes.h:212
support::ulittle32_t FileNameOffs
Array of [0..NumFiles) DBI name buffer offsets.
Definition: RawTypes.h:249
support::ulittle32_t Signature
Definition: RawTypes.h:313
support::ulittle32_t VFileNI
Definition: RawTypes.h:338
The header preceding the File Info Substream of the DBI stream.
Definition: RawTypes.h:180
support::ulittle32_t TypeIndexBegin
Definition: RawTypes.h:285
support::little32_t Off
Definition: RawTypes.h:49
support::ulittle16_t PdbDllVersion
version of mspdbNNN.dll
Definition: RawTypes.h:136
support::ulittle32_t Reserved
Pad to 64 bytes.
Definition: RawTypes.h:175
support::ulittle32_t ObjNI
Definition: RawTypes.h:337
const uint32_t MinTpiHashBuckets
Definition: RawTypes.h:300
support::little32_t OptionalDbgHdrSize
Size of DbgHeader info.
Definition: RawTypes.h:163
support::ulittle16_t ClassName
Definition: RawTypes.h:81
support::ulittle32_t AddrMap
Definition: RawTypes.h:266
support::ulittle16_t Flags
See DbiFlags enum.
Definition: RawTypes.h:169
support::ulittle16_t Flags
Definition: RawTypes.h:75
support::ulittle16_t ISect
Definition: RawTypes.h:47
support::ulittle32_t Size
Definition: RawTypes.h:323
support::ulittle32_t Characteristics
Definition: RawTypes.h:51
support::ulittle16_t NumSourceFiles
Total # of source files.
Definition: RawTypes.h:188
support::ulittle32_t Mod
Currently opened module.
Definition: RawTypes.h:217
support::ulittle32_t SizeOfThunk
Definition: RawTypes.h:268
The header preceding the global PDB Stream (Stream 1)
Definition: RawTypes.h:304
support::ulittle16_t NumModules
Total # of modules, should match number of records in the ModuleInfo substream.
Definition: RawTypes.h:183
EmbeddedBuf HashValueBuffer
Definition: RawTypes.h:295
support::ulittle16_t SecCount
Definition: RawTypes.h:67
support::ulittle16_t HashAuxStreamIndex
Definition: RawTypes.h:291
support::little32_t ModiSubstreamSize
Size of module info stream.
Definition: RawTypes.h:145
support::ulittle32_t Version
Definition: RawTypes.h:322
support::ulittle32_t OffThunkTable
Definition: RawTypes.h:271
support::ulittle16_t ModDiStream
Stream Number of module debug info.
Definition: RawTypes.h:226
SectionContrib Base
Definition: RawTypes.h:61
support::ulittle32_t C11Bytes
Size of C11 line number info in above stream.
Definition: RawTypes.h:232
support::little32_t SecContrSubstreamSize
Size of sec. contrib stream.
Definition: RawTypes.h:148
A single file record entry within the /src/headerblock stream.
Definition: RawTypes.h:331
support::ulittle32_t Age
How "old" is this DBI Stream. Should match the age of the PDB InfoStream.
Definition: RawTypes.h:124
support::ulittle16_t SymRecordStreamIndex
Symbol records stream #.
Definition: RawTypes.h:139
support::ulittle32_t VersionHeader
Definition: RawTypes.h:121
support::ulittle32_t HashKeySize
Definition: RawTypes.h:292
const uint32_t PDBStringTableSignature
Definition: RawTypes.h:318
support::ulittle32_t HeaderSize
Definition: RawTypes.h:284
support::ulittle32_t CRC
Definition: RawTypes.h:334
support::ulittle32_t DataCrc
Definition: RawTypes.h:54
support::ulittle32_t Version
Definition: RawTypes.h:283
support::ulittle16_t SecName
Definition: RawTypes.h:79
support::ulittle16_t PublicSymbolStreamIndex
Public symbols stream #.
Definition: RawTypes.h:133
support::ulittle32_t NumSections
Definition: RawTypes.h:272
support::ulittle16_t MachineType
See PDB_MachineType enum.
Definition: RawTypes.h:172
support::ulittle32_t HrSize
Definition: RawTypes.h:35
support::ulittle32_t FileSize
Definition: RawTypes.h:335
const uint32_t MaxTpiHashBuckets
Definition: RawTypes.h:301
EmbeddedBuf HashAdjBuffer
Definition: RawTypes.h:297
support::ulittle16_t SecCountLog
Definition: RawTypes.h:68