1 /* pdb.h - header file for generating PDB CodeView debugging files.
2 Copyright (C) 2022 Free Software Foundation, Inc.
4 This file is part of the GNU Binutils.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* Header files referred to below can be found in Microsoft's PDB
22 repository: https://github.com/microsoft/microsoft-pdb. */
32 #define LF_VTSHAPE 0x000a
33 #define LF_MODIFIER 0x1001
34 #define LF_POINTER 0x1002
35 #define LF_PROCEDURE 0x1008
36 #define LF_MFUNCTION 0x1009
37 #define LF_ARGLIST 0x1201
38 #define LF_FIELDLIST 0x1203
39 #define LF_BITFIELD 0x1205
40 #define LF_METHODLIST 0x1206
41 #define LF_BCLASS 0x1400
42 #define LF_VBCLASS 0x1401
43 #define LF_IVBCLASS 0x1402
44 #define LF_INDEX 0x1404
45 #define LF_VFUNCTAB 0x1409
46 #define LF_ENUMERATE 0x1502
47 #define LF_ARRAY 0x1503
48 #define LF_CLASS 0x1504
49 #define LF_STRUCTURE 0x1505
50 #define LF_UNION 0x1506
51 #define LF_ENUM 0x1507
52 #define LF_MEMBER 0x150d
53 #define LF_STMEMBER 0x150e
54 #define LF_METHOD 0x150f
55 #define LF_NESTTYPE 0x1510
56 #define LF_ONEMETHOD 0x1511
58 #define LF_CHAR 0x8000
59 #define LF_SHORT 0x8001
60 #define LF_USHORT 0x8002
61 #define LF_LONG 0x8003
62 #define LF_ULONG 0x8004
63 #define LF_QUADWORD 0x8009
64 #define LF_UQUADWORD 0x800a
66 #define S_PUB32 0x110e
68 /* PDBStream70 in pdb1.h */
77 #define PDB_STREAM_VERSION_VC70 20000404
78 #define PDB_STREAM_VERSION_VC140 20140508
81 struct pdb_tpi_stream_header
85 uint32_t type_index_begin
;
86 uint32_t type_index_end
;
87 uint32_t type_record_bytes
;
88 uint16_t hash_stream_index
;
89 uint16_t hash_aux_stream_index
;
90 uint32_t hash_key_size
;
91 uint32_t num_hash_buckets
;
92 uint32_t hash_value_buffer_offset
;
93 uint32_t hash_value_buffer_length
;
94 uint32_t index_offset_buffer_offset
;
95 uint32_t index_offset_buffer_length
;
96 uint32_t hash_adj_buffer_offset
;
97 uint32_t hash_adj_buffer_length
;
100 #define TPI_STREAM_VERSION_80 20040203
102 #define TPI_FIRST_INDEX 0x1000
103 #define NUM_TPI_HASH_BUCKETS 0x3ffff
105 /* NewDBIHdr in dbi.h */
106 struct pdb_dbi_stream_header
108 uint32_t version_signature
;
109 uint32_t version_header
;
111 uint16_t global_stream_index
;
112 uint16_t build_number
;
113 uint16_t public_stream_index
;
114 uint16_t pdb_dll_version
;
115 uint16_t sym_record_stream
;
116 uint16_t pdb_dll_rbld
;
117 uint32_t mod_info_size
;
118 uint32_t section_contribution_size
;
119 uint32_t section_map_size
;
120 uint32_t source_info_size
;
121 uint32_t type_server_map_size
;
122 uint32_t mfc_type_server_index
;
123 uint32_t optional_dbg_header_size
;
124 uint32_t ec_substream_size
;
130 #define DBI_STREAM_VERSION_70 19990903
132 /* PSGSIHDR in gsi.h */
133 struct publics_header
135 uint32_t sym_hash_size
;
136 uint32_t addr_map_size
;
138 uint32_t thunks_size
;
139 uint32_t thunk_table
;
140 uint32_t thunk_table_offset
;
144 /* GSIHashHdr in gsi.h */
145 struct globals_hash_header
149 uint32_t entries_size
;
150 uint32_t buckets_size
;
153 /* HRFile in gsi.h */
160 #define GLOBALS_HASH_SIGNATURE 0xffffffff
161 #define GLOBALS_HASH_VERSION_70 0xf12f091a
163 /* PUBSYM32 in cvinfo.h */
166 uint16_t record_length
;
167 uint16_t record_type
;
171 /* followed by null-terminated string */
174 /* see bitset CV_PUBSYMFLAGS in cvinfo.h */
175 #define PUBSYM_FUNCTION 0x2
177 struct optional_dbg_header
180 uint16_t exception_stream
;
181 uint16_t fixup_stream
;
182 uint16_t omap_to_src_stream
;
183 uint16_t omap_from_src_stream
;
184 uint16_t section_header_stream
;
185 uint16_t token_map_stream
;
186 uint16_t xdata_stream
;
187 uint16_t pdata_stream
;
188 uint16_t new_fpo_stream
;
189 uint16_t orig_section_header_stream
;
192 #define CV_SIGNATURE_C13 4
194 #define DEBUG_S_LINES 0xf2
195 #define DEBUG_S_STRINGTABLE 0xf3
196 #define DEBUG_S_FILECHKSMS 0xf4
198 #define STRING_TABLE_SIGNATURE 0xeffeeffe
199 #define STRING_TABLE_VERSION 1
202 struct string_table_header
208 #define SECTION_CONTRIB_VERSION_60 0xf12eba2d
210 /* SC in dbicommon.h */
211 struct section_contribution
217 uint32_t characteristics
;
218 uint16_t module_index
;
224 /* MODI_60_Persist in dbi.h */
228 struct section_contribution sc
;
230 uint16_t module_sym_stream
;
231 uint32_t sym_byte_size
;
232 uint32_t c11_byte_size
;
233 uint32_t c13_byte_size
;
234 uint16_t source_file_count
;
237 uint32_t source_file_name_index
;
238 uint32_t pdb_file_path_name_index
;
241 /* filedata in dumpsym7.cpp */
245 uint8_t checksum_length
;
246 uint8_t checksum_type
;
249 /* lfModifier in cvinfo.h */
259 /* lfPointer in cvinfo.h */
268 /* lfArgList in cvinfo.h */
273 uint32_t num_entries
;
277 /* lfProc in cvinfo.h */
282 uint32_t return_type
;
283 uint8_t calling_convention
;
285 uint16_t num_parameters
;
289 /* lfMFunc in cvinfo.h */
294 uint32_t return_type
;
295 uint32_t containing_class_type
;
297 uint8_t calling_convention
;
299 uint16_t num_parameters
;
301 int32_t this_adjustment
;
304 /* lfArray in cvinfo.h */
309 uint32_t element_type
;
311 uint16_t length_in_bytes
;
315 /* lfBitfield in cvinfo.h */
325 /* lfMember in cvinfo.h */
335 /* from bitfield structure CV_prop_t in cvinfo.h */
336 #define CV_PROP_FORWARD_REF 0x80
337 #define CV_PROP_SCOPED 0x100
338 #define CV_PROP_HAS_UNIQUE_NAME 0x200
340 /* lfClass in cvinfo.h */
345 uint16_t num_members
;
348 uint32_t derived_from
;
354 /* lfUnion in cvinfo.h */
359 uint16_t num_members
;
366 /* lfEnumerate in cvinfo.h */
372 /* then actual value if value >= 0x8000 */
376 /* lfEnum in cvinfo.h */
381 uint16_t num_elements
;
383 uint32_t underlying_type
;
388 /* lfIndex in cvinfo.h */
396 /* lfOneMethod in cvinfo.h */
400 uint16_t method_attribute
;
401 uint32_t method_type
;
405 /* mlMethod in cvinfo.h */
406 struct lf_methodlist_entry
408 uint16_t method_attribute
;
410 uint32_t method_type
;
413 /* lfMethodList in cvinfo.h */
418 struct lf_methodlist_entry entries
[];
421 /* lfMethod in cvinfo.h */
426 uint32_t method_list
;
430 /* lfBClass in cvinfo.h */
435 uint32_t base_class_type
;
440 /* lfVFuncTab in cvinfo.h */
448 /* lfVBClass in cvinfo.h */
453 uint32_t base_class_type
;
454 uint32_t virtual_base_pointer_type
;
455 uint16_t virtual_base_pointer_offset
;
456 uint16_t virtual_base_vbtable_offset
;
459 /* lfSTMember in cvinfo.h */
460 struct lf_static_member
468 /* lfNestType in cvinfo.h */
477 extern bool create_pdb_file (bfd
*, const char *, const unsigned char *);