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
57 #define LF_FUNC_ID 0x1601
58 #define LF_MFUNC_ID 0x1602
59 #define LF_BUILDINFO 0x1603
60 #define LF_SUBSTR_LIST 0x1604
61 #define LF_STRING_ID 0x1605
62 #define LF_UDT_SRC_LINE 0x1606
63 #define LF_UDT_MOD_SRC_LINE 0x1607
65 #define LF_CHAR 0x8000
66 #define LF_SHORT 0x8001
67 #define LF_USHORT 0x8002
68 #define LF_LONG 0x8003
69 #define LF_ULONG 0x8004
70 #define LF_QUADWORD 0x8009
71 #define LF_UQUADWORD 0x800a
73 #define S_PUB32 0x110e
75 /* PDBStream70 in pdb1.h */
84 #define PDB_STREAM_VERSION_VC70 20000404
85 #define PDB_STREAM_VERSION_VC140 20140508
88 struct pdb_tpi_stream_header
92 uint32_t type_index_begin
;
93 uint32_t type_index_end
;
94 uint32_t type_record_bytes
;
95 uint16_t hash_stream_index
;
96 uint16_t hash_aux_stream_index
;
97 uint32_t hash_key_size
;
98 uint32_t num_hash_buckets
;
99 uint32_t hash_value_buffer_offset
;
100 uint32_t hash_value_buffer_length
;
101 uint32_t index_offset_buffer_offset
;
102 uint32_t index_offset_buffer_length
;
103 uint32_t hash_adj_buffer_offset
;
104 uint32_t hash_adj_buffer_length
;
107 #define TPI_STREAM_VERSION_80 20040203
109 #define TPI_FIRST_INDEX 0x1000
110 #define NUM_TPI_HASH_BUCKETS 0x3ffff
112 /* NewDBIHdr in dbi.h */
113 struct pdb_dbi_stream_header
115 uint32_t version_signature
;
116 uint32_t version_header
;
118 uint16_t global_stream_index
;
119 uint16_t build_number
;
120 uint16_t public_stream_index
;
121 uint16_t pdb_dll_version
;
122 uint16_t sym_record_stream
;
123 uint16_t pdb_dll_rbld
;
124 uint32_t mod_info_size
;
125 uint32_t section_contribution_size
;
126 uint32_t section_map_size
;
127 uint32_t source_info_size
;
128 uint32_t type_server_map_size
;
129 uint32_t mfc_type_server_index
;
130 uint32_t optional_dbg_header_size
;
131 uint32_t ec_substream_size
;
137 #define DBI_STREAM_VERSION_70 19990903
139 /* PSGSIHDR in gsi.h */
140 struct publics_header
142 uint32_t sym_hash_size
;
143 uint32_t addr_map_size
;
145 uint32_t thunks_size
;
146 uint32_t thunk_table
;
147 uint32_t thunk_table_offset
;
151 /* GSIHashHdr in gsi.h */
152 struct globals_hash_header
156 uint32_t entries_size
;
157 uint32_t buckets_size
;
160 /* HRFile in gsi.h */
167 #define GLOBALS_HASH_SIGNATURE 0xffffffff
168 #define GLOBALS_HASH_VERSION_70 0xf12f091a
170 /* PUBSYM32 in cvinfo.h */
173 uint16_t record_length
;
174 uint16_t record_type
;
178 /* followed by null-terminated string */
181 /* see bitset CV_PUBSYMFLAGS in cvinfo.h */
182 #define PUBSYM_FUNCTION 0x2
184 struct optional_dbg_header
187 uint16_t exception_stream
;
188 uint16_t fixup_stream
;
189 uint16_t omap_to_src_stream
;
190 uint16_t omap_from_src_stream
;
191 uint16_t section_header_stream
;
192 uint16_t token_map_stream
;
193 uint16_t xdata_stream
;
194 uint16_t pdata_stream
;
195 uint16_t new_fpo_stream
;
196 uint16_t orig_section_header_stream
;
199 #define CV_SIGNATURE_C13 4
201 #define DEBUG_S_LINES 0xf2
202 #define DEBUG_S_STRINGTABLE 0xf3
203 #define DEBUG_S_FILECHKSMS 0xf4
205 #define STRING_TABLE_SIGNATURE 0xeffeeffe
206 #define STRING_TABLE_VERSION 1
209 struct string_table_header
215 #define SECTION_CONTRIB_VERSION_60 0xf12eba2d
217 /* SC in dbicommon.h */
218 struct section_contribution
224 uint32_t characteristics
;
225 uint16_t module_index
;
231 /* MODI_60_Persist in dbi.h */
235 struct section_contribution sc
;
237 uint16_t module_sym_stream
;
238 uint32_t sym_byte_size
;
239 uint32_t c11_byte_size
;
240 uint32_t c13_byte_size
;
241 uint16_t source_file_count
;
244 uint32_t source_file_name_index
;
245 uint32_t pdb_file_path_name_index
;
248 /* filedata in dumpsym7.cpp */
252 uint8_t checksum_length
;
253 uint8_t checksum_type
;
256 /* lfModifier in cvinfo.h */
266 /* lfPointer in cvinfo.h */
275 /* lfArgList in cvinfo.h (used for both LF_ARGLIST and LF_SUBSTR_LIST) */
280 uint32_t num_entries
;
284 /* lfProc in cvinfo.h */
289 uint32_t return_type
;
290 uint8_t calling_convention
;
292 uint16_t num_parameters
;
296 /* lfMFunc in cvinfo.h */
301 uint32_t return_type
;
302 uint32_t containing_class_type
;
304 uint8_t calling_convention
;
306 uint16_t num_parameters
;
308 int32_t this_adjustment
;
311 /* lfArray in cvinfo.h */
316 uint32_t element_type
;
318 uint16_t length_in_bytes
;
322 /* lfBitfield in cvinfo.h */
332 /* lfMember in cvinfo.h */
342 /* from bitfield structure CV_prop_t in cvinfo.h */
343 #define CV_PROP_FORWARD_REF 0x80
344 #define CV_PROP_SCOPED 0x100
345 #define CV_PROP_HAS_UNIQUE_NAME 0x200
347 /* lfClass in cvinfo.h */
352 uint16_t num_members
;
355 uint32_t derived_from
;
361 /* lfUnion in cvinfo.h */
366 uint16_t num_members
;
373 /* lfEnumerate in cvinfo.h */
379 /* then actual value if value >= 0x8000 */
383 /* lfEnum in cvinfo.h */
388 uint16_t num_elements
;
390 uint32_t underlying_type
;
395 /* lfIndex in cvinfo.h */
403 /* lfOneMethod in cvinfo.h */
407 uint16_t method_attribute
;
408 uint32_t method_type
;
412 /* mlMethod in cvinfo.h */
413 struct lf_methodlist_entry
415 uint16_t method_attribute
;
417 uint32_t method_type
;
420 /* lfMethodList in cvinfo.h */
425 struct lf_methodlist_entry entries
[];
428 /* lfMethod in cvinfo.h */
433 uint32_t method_list
;
437 /* lfBClass in cvinfo.h */
442 uint32_t base_class_type
;
447 /* lfVFuncTab in cvinfo.h */
455 /* lfVBClass in cvinfo.h */
460 uint32_t base_class_type
;
461 uint32_t virtual_base_pointer_type
;
462 uint16_t virtual_base_pointer_offset
;
463 uint16_t virtual_base_vbtable_offset
;
466 /* lfSTMember in cvinfo.h */
467 struct lf_static_member
475 /* lfNestType in cvinfo.h */
484 /* lfStringId in cvinfo.h */
493 /* lfBuildInfo in cvinfo.h */
502 /* lfFuncId in cvinfo.h */
507 uint32_t parent_scope
;
508 uint32_t function_type
;
512 /* lfMFuncId in cvinfo.h */
517 uint32_t parent_type
;
518 uint32_t function_type
;
522 /* lfUdtSrcLine in cvinfo.h */
523 struct lf_udt_src_line
528 uint32_t source_file_type
;
532 /* lfUdtModSrcLine in cvinfo.h */
533 struct lf_udt_mod_src_line
538 uint32_t source_file_string
;
543 extern bool create_pdb_file (bfd
*, const char *, const unsigned char *);