1 /* pdb.h - header file for generating PDB CodeView debugging files.
2 Copyright (C) 2022-2024 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_VFTABLE 0x151d
58 #define LF_FUNC_ID 0x1601
59 #define LF_MFUNC_ID 0x1602
60 #define LF_BUILDINFO 0x1603
61 #define LF_SUBSTR_LIST 0x1604
62 #define LF_STRING_ID 0x1605
63 #define LF_UDT_SRC_LINE 0x1606
64 #define LF_UDT_MOD_SRC_LINE 0x1607
66 #define LF_CHAR 0x8000
67 #define LF_SHORT 0x8001
68 #define LF_USHORT 0x8002
69 #define LF_LONG 0x8003
70 #define LF_ULONG 0x8004
71 #define LF_QUADWORD 0x8009
72 #define LF_UQUADWORD 0x800a
75 #define S_FRAMEPROC 0x1012
76 #define S_OBJNAME 0x1101
77 #define S_THUNK32 0x1102
78 #define S_BLOCK32 0x1103
79 #define S_LABEL32 0x1105
80 #define S_REGISTER 0x1106
81 #define S_CONSTANT 0x1107
83 #define S_BPREL32 0x110b
84 #define S_LDATA32 0x110c
85 #define S_GDATA32 0x110d
86 #define S_PUB32 0x110e
87 #define S_LPROC32 0x110f
88 #define S_GPROC32 0x1110
89 #define S_REGREL32 0x1111
90 #define S_LTHREAD32 0x1112
91 #define S_GTHREAD32 0x1113
92 #define S_UNAMESPACE 0x1124
93 #define S_PROCREF 0x1125
94 #define S_LPROCREF 0x1127
95 #define S_FRAMECOOKIE 0x113a
96 #define S_COMPILE3 0x113c
97 #define S_ENVBLOCK 0x113d
98 #define S_LOCAL 0x113e
99 #define S_DEFRANGE_REGISTER 0x1141
100 #define S_DEFRANGE_FRAMEPOINTER_REL 0x1142
101 #define S_DEFRANGE_SUBFIELD_REGISTER 0x1143
102 #define S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE 0x1144
103 #define S_DEFRANGE_REGISTER_REL 0x1145
104 #define S_LPROC32_ID 0x1146
105 #define S_GPROC32_ID 0x1147
106 #define S_BUILDINFO 0x114c
107 #define S_INLINESITE 0x114d
108 #define S_INLINESITE_END 0x114e
109 #define S_PROC_ID_END 0x114f
110 #define S_HEAPALLOCSITE 0x115e
112 /* PDBStream70 in pdb1.h */
121 #define PDB_STREAM_VERSION_VC70 20000404
122 #define PDB_STREAM_VERSION_VC140 20140508
125 struct pdb_tpi_stream_header
128 uint32_t header_size
;
129 uint32_t type_index_begin
;
130 uint32_t type_index_end
;
131 uint32_t type_record_bytes
;
132 uint16_t hash_stream_index
;
133 uint16_t hash_aux_stream_index
;
134 uint32_t hash_key_size
;
135 uint32_t num_hash_buckets
;
136 uint32_t hash_value_buffer_offset
;
137 uint32_t hash_value_buffer_length
;
138 uint32_t index_offset_buffer_offset
;
139 uint32_t index_offset_buffer_length
;
140 uint32_t hash_adj_buffer_offset
;
141 uint32_t hash_adj_buffer_length
;
144 #define TPI_STREAM_VERSION_80 20040203
146 #define TPI_FIRST_INDEX 0x1000
147 #define NUM_TPI_HASH_BUCKETS 0x3ffff
149 #define NUM_GLOBALS_HASH_BUCKETS 4096
151 /* NewDBIHdr in dbi.h */
152 struct pdb_dbi_stream_header
154 uint32_t version_signature
;
155 uint32_t version_header
;
157 uint16_t global_stream_index
;
158 uint16_t build_number
;
159 uint16_t public_stream_index
;
160 uint16_t pdb_dll_version
;
161 uint16_t sym_record_stream
;
162 uint16_t pdb_dll_rbld
;
163 uint32_t mod_info_size
;
164 uint32_t section_contribution_size
;
165 uint32_t section_map_size
;
166 uint32_t source_info_size
;
167 uint32_t type_server_map_size
;
168 uint32_t mfc_type_server_index
;
169 uint32_t optional_dbg_header_size
;
170 uint32_t ec_substream_size
;
176 #define DBI_STREAM_VERSION_70 19990903
178 /* PSGSIHDR in gsi.h */
179 struct publics_header
181 uint32_t sym_hash_size
;
182 uint32_t addr_map_size
;
184 uint32_t thunks_size
;
185 uint32_t thunk_table
;
186 uint32_t thunk_table_offset
;
190 /* GSIHashHdr in gsi.h */
191 struct globals_hash_header
195 uint32_t entries_size
;
196 uint32_t buckets_size
;
199 /* HRFile in gsi.h */
206 #define GLOBALS_HASH_SIGNATURE 0xffffffff
207 #define GLOBALS_HASH_VERSION_70 0xf12f091a
209 /* PUBSYM32 in cvinfo.h */
212 uint16_t record_length
;
213 uint16_t record_type
;
217 /* followed by null-terminated string */
220 /* see bitset CV_PUBSYMFLAGS in cvinfo.h */
221 #define PUBSYM_FUNCTION 0x2
223 struct optional_dbg_header
226 uint16_t exception_stream
;
227 uint16_t fixup_stream
;
228 uint16_t omap_to_src_stream
;
229 uint16_t omap_from_src_stream
;
230 uint16_t section_header_stream
;
231 uint16_t token_map_stream
;
232 uint16_t xdata_stream
;
233 uint16_t pdata_stream
;
234 uint16_t new_fpo_stream
;
235 uint16_t orig_section_header_stream
;
238 #define CV_SIGNATURE_C13 4
240 #define DEBUG_S_SYMBOLS 0xf1
241 #define DEBUG_S_LINES 0xf2
242 #define DEBUG_S_STRINGTABLE 0xf3
243 #define DEBUG_S_FILECHKSMS 0xf4
244 #define DEBUG_S_INLINEELINES 0xf6
246 #define STRING_TABLE_SIGNATURE 0xeffeeffe
247 #define STRING_TABLE_VERSION 1
249 #define CV_INLINEE_SOURCE_LINE_SIGNATURE 0
252 struct string_table_header
258 #define SECTION_CONTRIB_VERSION_60 0xf12eba2d
260 /* SC in dbicommon.h */
261 struct section_contribution
267 uint32_t characteristics
;
268 uint16_t module_index
;
274 /* MODI_60_Persist in dbi.h */
278 struct section_contribution sc
;
280 uint16_t module_sym_stream
;
281 uint32_t sym_byte_size
;
282 uint32_t c11_byte_size
;
283 uint32_t c13_byte_size
;
284 uint16_t source_file_count
;
287 uint32_t source_file_name_index
;
288 uint32_t pdb_file_path_name_index
;
291 /* filedata in dumpsym7.cpp */
295 uint8_t checksum_length
;
296 uint8_t checksum_type
;
299 /* lfModifier in cvinfo.h */
309 /* enum CV_ptrmode_e in cvinfo.h, shifted by 5 for the lfPointerAttr bitfield */
310 #define CV_PTR_MODE_MASK 0xe0
311 #define CV_PTR_MODE_PMEM 0x40
312 #define CV_PTR_MODE_PMFUNC 0x60
314 /* lfPointer in cvinfo.h */
321 /* following only if CV_PTR_MODE_PMEM or CV_PTR_MODE_PMFUNC in attributes */
322 uint32_t containing_class
;
323 uint16_t ptr_to_mem_type
;
327 /* lfArgList in cvinfo.h (used for both LF_ARGLIST and LF_SUBSTR_LIST) */
332 uint32_t num_entries
;
336 /* lfProc in cvinfo.h */
341 uint32_t return_type
;
342 uint8_t calling_convention
;
344 uint16_t num_parameters
;
348 /* lfMFunc in cvinfo.h */
353 uint32_t return_type
;
354 uint32_t containing_class_type
;
356 uint8_t calling_convention
;
358 uint16_t num_parameters
;
360 int32_t this_adjustment
;
363 /* lfArray in cvinfo.h */
368 uint32_t element_type
;
370 uint16_t length_in_bytes
;
374 /* lfBitfield in cvinfo.h */
384 /* lfMember in cvinfo.h */
394 /* from bitfield structure CV_prop_t in cvinfo.h */
395 #define CV_PROP_FORWARD_REF 0x80
396 #define CV_PROP_SCOPED 0x100
397 #define CV_PROP_HAS_UNIQUE_NAME 0x200
399 /* lfClass in cvinfo.h */
404 uint16_t num_members
;
407 uint32_t derived_from
;
413 /* lfUnion in cvinfo.h */
418 uint16_t num_members
;
425 /* lfEnumerate in cvinfo.h */
431 /* then actual value if value >= 0x8000 */
435 /* lfEnum in cvinfo.h */
440 uint16_t num_elements
;
442 uint32_t underlying_type
;
447 /* lfIndex in cvinfo.h */
455 /* lfOneMethod in cvinfo.h */
459 uint16_t method_attribute
;
460 uint32_t method_type
;
464 /* mlMethod in cvinfo.h */
465 struct lf_methodlist_entry
467 uint16_t method_attribute
;
469 uint32_t method_type
;
472 /* lfMethodList in cvinfo.h */
477 struct lf_methodlist_entry entries
[];
480 /* lfMethod in cvinfo.h */
485 uint32_t method_list
;
489 /* lfBClass in cvinfo.h */
494 uint32_t base_class_type
;
498 /* lfVFuncTab in cvinfo.h */
506 /* lfVBClass in cvinfo.h */
511 uint32_t base_class_type
;
512 uint32_t virtual_base_pointer_type
;
513 uint16_t virtual_base_pointer_offset
;
514 uint16_t virtual_base_vbtable_offset
;
517 /* lfSTMember in cvinfo.h */
518 struct lf_static_member
526 /* lfNestType in cvinfo.h */
535 /* lfStringId in cvinfo.h */
544 /* lfBuildInfo in cvinfo.h */
553 /* lfFuncId in cvinfo.h */
558 uint32_t parent_scope
;
559 uint32_t function_type
;
563 /* lfMFuncId in cvinfo.h */
568 uint32_t parent_type
;
569 uint32_t function_type
;
573 /* lfUdtSrcLine in cvinfo.h */
574 struct lf_udt_src_line
579 uint32_t source_file_type
;
583 /* lfUdtModSrcLine in cvinfo.h */
584 struct lf_udt_mod_src_line
589 uint32_t source_file_string
;
594 /* lfVftable in cvinfo.h */
600 uint32_t base_vftable
;
606 /* DATASYM32 in cvinfo.h */
617 /* PROCSYM32 in cvinfo.h */
626 uint32_t debug_start
;
635 /* REFSYM2 in cvinfo.h */
641 uint32_t symbol_offset
;
646 /* UDTSYM in cvinfo.h */
655 /* CONSTSYM in cvinfo.h */
662 /* then actual value if value >= 0x8000 */
666 /* BUILDINFOSYM in cvinfo.h */
674 /* BLOCKSYM32 in cvinfo.h */
687 /* BPRELSYM32 in cvinfo.h */
697 /* REGSYM in cvinfo.h */
707 /* REGREL32 in cvinfo.h */
718 /* LOCALSYM in cvinfo.h */
728 /* CV_LVAR_ADDR_RANGE in cvinfo.h */
729 struct lvar_addr_range
736 /* CV_LVAR_ADDR_GAP in cvinfo.h */
737 struct lvar_addr_gap
{
742 /* DEFRANGESYMREGISTERREL in cvinfo.h */
743 struct defrange_register_rel
748 uint16_t offset_parent
;
749 uint32_t offset_register
;
750 struct lvar_addr_range range
;
751 struct lvar_addr_gap gaps
[];
754 /* DEFRANGESYMFRAMEPOINTERREL in cvinfo.h */
755 struct defrange_framepointer_rel
760 struct lvar_addr_range range
;
761 struct lvar_addr_gap gaps
[];
764 /* DEFRANGESYMSUBFIELDREGISTER in cvinfo.h */
765 struct defrange_subfield_register
771 uint32_t offset_parent
;
772 struct lvar_addr_range range
;
773 struct lvar_addr_gap gaps
[];
776 /* DEFRANGESYMREGISTER in cvinfo.h */
777 struct defrange_register
783 struct lvar_addr_range range
;
784 struct lvar_addr_gap gaps
[];
787 /* INLINESITESYM in cvinfo.h */
795 uint8_t binary_annotations
[];
798 /* THUNKSYM32 in cvinfo.h */
813 /* HEAPALLOCSITE in cvinfo.h */
814 struct heap_alloc_site
824 /* OBJNAMESYM in cvinfo.h */
833 #define CV_CFL_80386 0x03
834 #define CV_CFL_X64 0xD0
835 #define CV_CFL_ARM64 0xF6
837 #define CV_CFL_LINK 0x07
839 /* COMPILESYM3 in cvinfo.h */
846 uint16_t frontend_major
;
847 uint16_t frontend_minor
;
848 uint16_t frontend_build
;
849 uint16_t frontend_qfe
;
850 uint16_t backend_major
;
851 uint16_t backend_minor
;
852 uint16_t backend_build
;
853 uint16_t backend_qfe
;
857 /* ENVBLOCKSYM in cvinfo.h */
866 extern bool create_pdb_file (bfd
*, const char *, const unsigned char *);