@@ -58,6 +58,80 @@ the other streams, will change if the value is something other than ``VC70``.
58
58
`UuidCreate <https://msdn.microsoft.com/en-us/library/windows/desktop/aa379205(v=vs.85).aspx >`__,
59
59
although LLVM cannot rely on that, as it must work on non-Windows platforms.
60
60
61
+ .. _pdb_named_stream_map :
62
+
63
+ Named Stream Map
64
+ ================
65
+
66
+ Following the header is a serialized hash table whose key type is a string, and
67
+ whose value type is an integer. The existence of a mapping ``X -> Y `` means
68
+ that the stream with the name ``X `` has stream index ``Y `` in the underlying MSF
69
+ file. Note that not all streams are named (for example, the
70
+ :doc: `TPI Stream <TpiStream >` has a fixed index and as such there is no need to
71
+ look up its index by name). In practice, there are usually only a small number
72
+ of named streams and these are enumerated in the table of streams in :doc: `index `.
73
+ A corollary of this is if a stream does have a name (and as such is in the named
74
+ stream map) then consulting the Named Stream Map is likely to be the only way to
75
+ discover the stream's MSF stream index. Several important streams (such as the
76
+ global string table, which is called ``/names ``) can only be located this way, and
77
+ so it is important to both produce and consume this correctly as tools will not
78
+ function correctly without it.
79
+
80
+ .. important ::
81
+ Some streams are located by fixed indices (e.g TPI Stream has index 2), but
82
+ other streams are located by fixed names (e.g. the string table is called
83
+ ``/names ``) and can only be located by consulting the Named Stream Map.
84
+
85
+ The on-disk layout of the Named Stream Map consists of 2 components. The first is
86
+ a buffer of string data prefixed by a 32-bit length. The second is a serialized
87
+ hash table whose key and value types are both ``uint32_t ``. The key is the offset
88
+ of a null-terminated string in the string data buffer specifying the name of the
89
+ stream, and the value is the MSF stream index of the stream with said name.
90
+ Note that although the key is an integer, the hash function used to find the right
91
+ bucket hashes the string at the corresponding offset in the string data buffer.
92
+
93
+ The on-disk layout of the serialized hash table is described at :doc: `HashTable `.
94
+
95
+ Note that the entire Named Stream Map is not length-prefixed, so the only way to
96
+ get to the data following it is to de-serialize it in its entirety.
97
+
98
+
99
+ .. _pdb_stream_features :
100
+
101
+ PDB Feature Codes
102
+ =================
103
+ Following the Named Stream Map, and consuming all remaining bytes of the PDB
104
+ Stream is a list of values from the following enumeration:
105
+
106
+ .. code-block :: c++
107
+
108
+ enum class PdbRaw_FeatureSig : uint32_t {
109
+ VC110 = 20091201,
110
+ VC140 = 20140508,
111
+ NoTypeMerge = 0x4D544F4E,
112
+ MinimalDebugInfo = 0x494E494D,
113
+ };
114
+
115
+ The meaning of these values is summarized by the following table:
116
+
117
+ +------------------+-------------------------------------------------+
118
+ | Flag | Meaning |
119
+ +==================+=================================================+
120
+ | VC110 | - No other features flags are present |
121
+ | | - PDB contains an :doc: `IPI Stream <TpiStream >` |
122
+ +------------------+-------------------------------------------------+
123
+ | VC140 | - Other feature flags may be present |
124
+ | | - PDB contains an :doc: `IPI Stream <TpiStream >` |
125
+ +------------------+-------------------------------------------------+
126
+ | NoTypeMerge | - Presumably duplicate types can appear in the |
127
+ | | TPI Stream, although it's unclear why this |
128
+ | | might happen. |
129
+ +------------------+-------------------------------------------------+
130
+ | MinimalDebugInfo | - Program was linked with /DEBUG:FASTLINK |
131
+ | | - There is no TPI / IPI stream, all type info |
132
+ | | is contained in the original object files. |
133
+ +------------------+-------------------------------------------------+
134
+
61
135
Matching a PDB to its executable
62
136
================================
63
137
The linker is responsible for writing both the PDB and the final executable, and
0 commit comments