Rizin
unix-like reverse engineering framework and cli tools
rz_bin_dwarf.h
Go to the documentation of this file.
1 #ifndef RZ_BIN_DWARF_H
2 #define RZ_BIN_DWARF_H
3 
4 #include <rz_types.h>
5 #include <rz_bin.h>
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
12 
13 #define DW_EXTENDED_OPCODE 0
14 #define LOP_EXTENDED 1
15 #define LOP_DISCARD 2
16 #define LOP_STANDARD 3
17 #define LOP_SPECIAL 4
18 
19 #define DW_LNS_copy 0x01
20 #define DW_LNS_advance_pc 0x02
21 #define DW_LNS_advance_line 0x03
22 #define DW_LNS_set_file 0x04
23 #define DW_LNS_set_column 0x05
24 #define DW_LNS_negate_stmt 0x06
25 #define DW_LNS_set_basic_block 0x07
26 #define DW_LNS_const_add_pc 0x08
27 #define DW_LNS_fixed_advance_pc 0x09
28 #define DW_LNS_set_prologue_end 0x0a /* DWARF3 */
29 #define DW_LNS_set_epilogue_begin 0x0b /* DWARF3 */
30 #define DW_LNS_set_isa 0x0c /* DWARF3 */
31 /* Line number extended opcode name. */
32 #define DW_LNE_end_sequence 0x01
33 #define DW_LNE_set_address 0x02
34 #define DW_LNE_define_file 0x03
35 #define DW_LNE_set_discriminator 0x04 /* DWARF4 */
36 #define DW_LNE_lo_user 0x80 /* DWARF3 */
37 #define DW_LNE_hi_user 0xff /* DWARF3 */
38 
39 /* HP extensions. */
40 #define DW_LNE_HP_negate_is_UV_update 0x11 /* 17 HP */
41 #define DW_LNE_HP_push_context 0x12 /* 18 HP */
42 #define DW_LNE_HP_pop_context 0x13 /* 19 HP */
43 #define DW_LNE_HP_set_file_line_column 0x14 /* 20 HP */
44 #define DW_LNE_HP_set_routine_name 0x15 /* 21 HP */
45 #define DW_LNE_HP_set_sequence 0x16 /* 22 HP */
46 #define DW_LNE_HP_negate_post_semantics 0x17 /* 23 HP */
47 #define DW_LNE_HP_negate_function_exit 0x18 /* 24 HP */
48 #define DW_LNE_HP_negate_front_end_logical 0x19 /* 25 HP */
49 #define DW_LNE_HP_define_proc 0x20 /* 32 HP */
50 
51 /* debug_info tags */
52 // this is not a real dwarf named entry, but I wanted to give it
53 // a name so it's more obvious and readable that it's just a type of entry
54 #define DW_TAG_null_entry 0x00
55 #define DW_TAG_array_type 0x01
56 #define DW_TAG_class_type 0x02
57 #define DW_TAG_entry_point 0x03
58 #define DW_TAG_enumeration_type 0x04
59 #define DW_TAG_formal_parameter 0x05
60 #define DW_TAG_imported_declaration 0x08
61 #define DW_TAG_label 0x0a
62 #define DW_TAG_lexical_block 0x0b
63 #define DW_TAG_member 0x0d
64 #define DW_TAG_pointer_type 0x0f
65 #define DW_TAG_reference_type 0x10
66 #define DW_TAG_compile_unit 0x11 //
67 #define DW_TAG_string_type 0x12
68 #define DW_TAG_structure_type 0x13
69 #define DW_TAG_subroutine_type 0x15
70 #define DW_TAG_typedef 0x16
71 #define DW_TAG_union_type 0x17
72 #define DW_TAG_unspecified_parameters 0x18
73 #define DW_TAG_variant 0x19
74 #define DW_TAG_common_block 0x1a
75 #define DW_TAG_common_inclusion 0x1b
76 #define DW_TAG_inheritance 0x1c
77 #define DW_TAG_inlined_subroutine 0x1d
78 #define DW_TAG_module 0x1e
79 #define DW_TAG_ptr_to_member_type 0x1f
80 #define DW_TAG_set_type 0x20
81 #define DW_TAG_subrange_type 0x21
82 #define DW_TAG_with_stmt 0x22
83 #define DW_TAG_access_declaration 0x23
84 #define DW_TAG_base_type 0x24
85 #define DW_TAG_catch_block 0x25
86 #define DW_TAG_const_type 0x26
87 #define DW_TAG_constant 0x27
88 #define DW_TAG_enumerator 0x28
89 #define DW_TAG_file_type 0x29
90 #define DW_TAG_friend 0x2a
91 #define DW_TAG_namelist 0x2b
92 /* Early releases of this header had the following
93  misspelled with a trailing 's' */
94 #define DW_TAG_namelist_item 0x2c /* DWARF3/2 spelling */
95 #define DW_TAG_namelist_items 0x2c /* SGI misspelling/typo */
96 #define DW_TAG_packed_type 0x2d
97 #define DW_TAG_subprogram 0x2e
98 /* The DWARF2 document had two spellings of the following
99  two TAGs, DWARF3 specifies the longer spelling. */
100 #define DW_TAG_template_type_parameter 0x2f /* DWARF3/2 spelling*/
101 #define DW_TAG_template_type_param 0x2f /* DWARF2 spelling*/
102 #define DW_TAG_template_value_parameter 0x30 /* DWARF3/2 spelling*/
103 #define DW_TAG_template_value_param 0x30 /* DWARF2 spelling*/
104 #define DW_TAG_thrown_type 0x31
105 #define DW_TAG_try_block 0x32
106 #define DW_TAG_variant_part 0x33
107 #define DW_TAG_variable 0x34
108 #define DW_TAG_volatile_type 0x35
109 #define DW_TAG_dwarf_procedure 0x36 /* DWARF3 */
110 #define DW_TAG_restrict_type 0x37 /* DWARF3 */
111 #define DW_TAG_interface_type 0x38 /* DWARF3 */
112 #define DW_TAG_namespace 0x39 /* DWARF3 */
113 #define DW_TAG_imported_module 0x3a /* DWARF3 */
114 #define DW_TAG_unspecified_type 0x3b /* DWARF3 */
115 #define DW_TAG_partial_unit 0x3c /* DWARF3 */
116 #define DW_TAG_imported_unit 0x3d /* DWARF3 */
117 /* Do not use DW_TAG_mutable_type */
118 #define DW_TAG_mutable_type 0x3e /* Withdrawn from DWARF3 by DWARF3f. */
119 #define DW_TAG_condition 0x3f /* DWARF3f */
120 #define DW_TAG_shared_type 0x40 /* DWARF3f */
121 #define DW_TAG_type_unit 0x41 /* DWARF4 */
122 #define DW_TAG_rvalue_reference_type 0x42 /* DWARF4 */
123 #define DW_TAG_template_alias 0x43 /* DWARF4 */
124 
125 #define DW_TAG_LAST 0x44 // correct ?
126 /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */
127 #define DW_TAG_lo_user 0x4080
128 #define DW_TAG_hi_user 0xffff
129 
130 #define DW_CHILDREN_no 0x00
131 #define DW_CHILDREN_yes 0x01
132 
133 #define DW_AT_sibling 0x01
134 #define DW_AT_location 0x02
135 #define DW_AT_name 0x03
136 #define DW_AT_ordering 0x09
137 #define DW_AT_byte_size 0x0b
138 #define DW_AT_bit_offset 0x0c
139 #define DW_AT_bit_size 0x0d
140 #define DW_AT_stmt_list 0x10
141 #define DW_AT_low_pc 0x11
142 #define DW_AT_high_pc 0x12
143 #define DW_AT_language 0x13
144 #define DW_AT_discr 0x15
145 #define DW_AT_discr_value 0x16
146 #define DW_AT_visibility 0x17
147 #define DW_AT_import 0x18
148 #define DW_AT_string_length 0x19
149 #define DW_AT_common_reference 0x1a
150 #define DW_AT_comp_dir 0x1b
151 #define DW_AT_const_value 0x1c
152 #define DW_AT_containing_type 0x1d
153 #define DW_AT_default_value 0x1e
154 #define DW_AT_inline 0x20
155 #define DW_AT_is_optional 0x21
156 #define DW_AT_lower_bound 0x22
157 #define DW_AT_producer 0x25
158 #define DW_AT_prototyped 0x27
159 #define DW_AT_return_addr 0x2a
160 #define DW_AT_start_scope 0x2c
161 #define DW_AT_stride_size 0x2e
162 #define DW_AT_upper_bound 0x2f
163 #define DW_AT_abstract_origin 0x31
164 #define DW_AT_accessibility 0x32
165 #define DW_AT_address_class 0x33
166 #define DW_AT_artificial 0x34
167 #define DW_AT_base_types 0x35
168 #define DW_AT_calling_convention 0x36
169 #define DW_AT_count 0x37
170 #define DW_AT_data_member_location 0x38
171 #define DW_AT_decl_column 0x39
172 #define DW_AT_decl_file 0x3a
173 #define DW_AT_decl_line 0x3b
174 #define DW_AT_declaration 0x3c
175 #define DW_AT_discr_list 0x3d
176 #define DW_AT_encoding 0x3e
177 #define DW_AT_external 0x3f
178 #define DW_AT_frame_base 0x40
179 #define DW_AT_friend 0x41
180 #define DW_AT_identifier_case 0x42
181 #define DW_AT_macro_info 0x43
182 #define DW_AT_namelist_item 0x44
183 #define DW_AT_priority 0x45
184 #define DW_AT_segment 0x46
185 #define DW_AT_specification 0x47
186 #define DW_AT_static_link 0x48
187 #define DW_AT_type 0x49
188 #define DW_AT_use_location 0x4a
189 #define DW_AT_variable_parameter 0x4b
190 #define DW_AT_virtuality 0x4c
191 #define DW_AT_vtable_elem_location 0x4d
192 #define DW_AT_allocated 0x4e // DWARF 3 additions start
193 #define DW_AT_associated 0x4f
194 #define DW_AT_data_location 0x50
195 #define DW_AT_byte_stride 0x51
196 #define DW_AT_entry_pc 0x52
197 #define DW_AT_use_UTF8 0x53
198 #define DW_AT_extension 0x54
199 #define DW_AT_ranges 0x55
200 #define DW_AT_trampoline 0x56
201 #define DW_AT_call_column 0x57
202 #define DW_AT_call_file 0x58
203 #define DW_AT_call_line 0x59
204 #define DW_AT_description 0x5a
205 #define DW_AT_binary_scale 0x5b
206 #define DW_AT_decimal_scale 0x5c
207 #define DW_AT_small 0x5d
208 #define DW_AT_decimal_sign 0x5e
209 #define DW_AT_digit_count 0x5f
210 #define DW_AT_picture_string 0x60
211 #define DW_AT_mutable 0x61
212 #define DW_AT_threads_scaled 0x62
213 #define DW_AT_explicit 0x63
214 #define DW_AT_object_pointer 0x64
215 #define DW_AT_endianity 0x65
216 #define DW_AT_elemental 0x66
217 #define DW_AT_pure 0x67
218 #define DW_AT_recursive 0x68 // DWARF 3 additions end
219 #define DW_AT_signature 0x69
220 #define DW_AT_main_subprogram 0x6a
221 #define DW_AT_data_bit_offset 0x6b
222 #define DW_AT_const_expr 0x6c
223 #define DW_AT_enum_class 0x6d
224 #define DW_AT_linkage_name 0x6e
225 
226 #define DW_AT_string_length_bit_size 0x6f
227 #define DW_AT_string_length_byte_size 0x70
228 #define DW_AT_rank 0x71
229 #define DW_AT_str_offsets_base 0x72
230 #define DW_AT_addr_base 0x73
231 #define DW_AT_rnglists_base 0x74
232 // #define Reserved 0x75 Unused
233 #define DW_AT_dwo_name 0x76
234 #define DW_AT_reference 0x77
235 #define DW_AT_rvalue_reference 0x78
236 #define DW_AT_macros 0x79
237 #define DW_AT_call_all_calls 0x7a
238 #define DW_AT_call_all_source_calls 0x7b
239 #define DW_AT_call_all_tail_calls 0x7c
240 #define DW_AT_call_return_pc 0x7d
241 #define DW_AT_call_value 0x7e
242 #define DW_AT_call_origin 0x7f
243 #define DW_AT_call_parameter 0x80
244 #define DW_AT_call_pc 0x81
245 #define DW_AT_call_tail_call 0x82
246 #define DW_AT_call_target 0x83
247 #define DW_AT_call_target_clobbered 0x84
248 #define DW_AT_call_data_location 0x85
249 #define DW_AT_call_data_value 0x86
250 #define DW_AT_noreturn 0x87
251 #define DW_AT_alignment 0x88
252 #define DW_AT_export_symbols 0x89
253 #define DW_AT_deleted 0x8a
254 #define DW_AT_defaulted 0x8b
255 #define DW_AT_loclists_base 0x8c
256 
257 /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */
258 #define DW_AT_lo_user 0x2000
259 // extensions:
260 #define DW_AT_MIPS_linkage_name 0x2007 // Same as DWARF4 DW_AT_linkage_name
261 #define DW_AT_GNU_call_site_value 0x2111
262 #define DW_AT_GNU_call_site_data_value 0x2112
263 #define DW_AT_GNU_call_site_target 0x2113
264 #define DW_AT_GNU_call_site_target_clobbered 0x2114
265 #define DW_AT_GNU_tail_call 0x2115
266 #define DW_AT_GNU_all_tail_call_sites 0x2116
267 #define DW_AT_GNU_all_call_sites 0x2117
268 #define DW_AT_GNU_all_source_call_sites 0x2118
269 #define DW_AT_GNU_macros 0x2119
270 #define DW_AT_GNU_deleted 0x211a
271 #define DW_AT_GNU_dwo_name 0x2130
272 #define DW_AT_GNU_dwo_id 0x2131
273 #define DW_AT_GNU_ranges_base 0x2132
274 #define DW_AT_GNU_addr_base 0x2133
275 #define DW_AT_GNU_pubnames 0x2134
276 #define DW_AT_GNU_pubtypes 0x2135
277 #define DW_AT_hi_user 0x3fff
278 
279 #define DW_FORM_addr 0x01
280 #define DW_FORM_block2 0x03
281 #define DW_FORM_block4 0x04
282 #define DW_FORM_data2 0x05
283 #define DW_FORM_data4 0x06
284 #define DW_FORM_data8 0x07
285 #define DW_FORM_string 0x08
286 #define DW_FORM_block 0x09
287 #define DW_FORM_block1 0x0a
288 #define DW_FORM_data1 0x0b
289 #define DW_FORM_flag 0x0c
290 #define DW_FORM_sdata 0x0d
291 #define DW_FORM_strp 0x0e
292 #define DW_FORM_udata 0x0f
293 #define DW_FORM_ref_addr 0x10
294 #define DW_FORM_ref1 0x11
295 #define DW_FORM_ref2 0x12
296 #define DW_FORM_ref4 0x13
297 #define DW_FORM_ref8 0x14
298 #define DW_FORM_ref_udata 0x15
299 #define DW_FORM_indirect 0x16
300 #define DW_FORM_sec_offset 0x17 // DWARF 4 new attribute for section offset
301 #define DW_FORM_exprloc 0x18
302 #define DW_FORM_flag_present 0x19
303 #define DW_FORM_strx 0x1a
304 #define DW_FORM_addrx 0x1b
305 #define DW_FORM_ref_sup4 0x1c
306 #define DW_FORM_strp_sup 0x1d
307 #define DW_FORM_data16 0x1e
308 #define DW_FORM_line_ptr 0x1f
309 #define DW_FORM_ref_sig8 0x20
310 #define DW_FORM_implicit_const 0x21
311 #define DW_FORM_loclistx 0x22
312 #define DW_FORM_rnglistx 0x23
313 #define DW_FORM_ref_sup8 0x24
314 #define DW_FORM_strx1 0x25
315 #define DW_FORM_strx2 0x26
316 #define DW_FORM_strx3 0x27
317 #define DW_FORM_strx4 0x28
318 #define DW_FORM_addrx1 0x29
319 #define DW_FORM_addrx2 0x2a
320 #define DW_FORM_addrx3 0x2b
321 #define DW_FORM_addrx4 0x2c
322 
323 #define DW_OP_addr 0x03
324 #define DW_OP_deref 0x06
325 #define DW_OP_const1u 0x08
326 #define DW_OP_const1s 0x09
327 #define DW_OP_const2u 0x0a
328 #define DW_OP_const2s 0x0b
329 #define DW_OP_const4u 0x0c
330 #define DW_OP_const4s 0x0d
331 #define DW_OP_const8u 0x0e
332 #define DW_OP_const8s 0x0f
333 #define DW_OP_constu 0x10
334 #define DW_OP_consts 0x11
335 #define DW_OP_dup 0x12
336 #define DW_OP_drop 0x13
337 #define DW_OP_over 0x14
338 #define DW_OP_pick 0x15
339 #define DW_OP_swap 0x16
340 #define DW_OP_rot 0x17
341 #define DW_OP_xderef 0x18
342 #define DW_OP_abs 0x19
343 #define DW_OP_and 0x1a
344 #define DW_OP_div 0x1b
345 #define DW_OP_minus 0x1c
346 #define DW_OP_mod 0x1d
347 #define DW_OP_mul 0x1e
348 #define DW_OP_neg 0x1f
349 #define DW_OP_not 0x20
350 #define DW_OP_or 0x21
351 #define DW_OP_plus 0x22
352 #define DW_OP_plus_uconst 0x23
353 #define DW_OP_shl 0x24
354 #define DW_OP_shr 0x25
355 #define DW_OP_shra 0x26
356 #define DW_OP_xor 0x27
357 #define DW_OP_skip 0x2f
358 #define DW_OP_bra 0x28
359 #define DW_OP_eq 0x29
360 #define DW_OP_ge 0x2a
361 #define DW_OP_gt 0x2b
362 #define DW_OP_le 0x2c
363 #define DW_OP_lt 0x2d
364 #define DW_OP_ne 0x2e
365 #define DW_OP_lit0 0x30
366 #define DW_OP_lit1 0x31
367 #define DW_OP_lit2 0x32
368 #define DW_OP_lit3 0x33
369 #define DW_OP_lit4 0x34
370 #define DW_OP_lit5 0x35
371 #define DW_OP_lit6 0x36
372 #define DW_OP_lit7 0x37
373 #define DW_OP_lit8 0x38
374 #define DW_OP_lit9 0x39
375 #define DW_OP_lit10 0x3a
376 #define DW_OP_lit11 0x3b
377 #define DW_OP_lit12 0x3c
378 #define DW_OP_lit13 0x3d
379 #define DW_OP_lit14 0x3e
380 #define DW_OP_lit15 0x3f
381 #define DW_OP_lit16 0x40
382 #define DW_OP_lit17 0x41
383 #define DW_OP_lit18 0x42
384 #define DW_OP_lit19 0x43
385 #define DW_OP_lit20 0x44
386 #define DW_OP_lit21 0x45
387 #define DW_OP_lit22 0x46
388 #define DW_OP_lit23 0x47
389 #define DW_OP_lit24 0x48
390 #define DW_OP_lit25 0x49
391 #define DW_OP_lit26 0x4a
392 #define DW_OP_lit27 0x4b
393 #define DW_OP_lit28 0x4c
394 #define DW_OP_lit29 0x4d
395 #define DW_OP_lit30 0x4e
396 #define DW_OP_lit31 0x4f
397 #define DW_OP_reg0 0x50
398 #define DW_OP_reg1 0x51
399 #define DW_OP_reg2 0x52
400 #define DW_OP_reg3 0x53
401 #define DW_OP_reg4 0x54
402 #define DW_OP_reg5 0x55
403 #define DW_OP_reg6 0x56
404 #define DW_OP_reg7 0x57
405 #define DW_OP_reg8 0x58
406 #define DW_OP_reg9 0x59
407 #define DW_OP_reg10 0x5a
408 #define DW_OP_reg11 0x5b
409 #define DW_OP_reg12 0x5c
410 #define DW_OP_reg13 0x5d
411 #define DW_OP_reg14 0x5e
412 #define DW_OP_reg15 0x5f
413 #define DW_OP_reg16 0x60
414 #define DW_OP_reg17 0x61
415 #define DW_OP_reg18 0x62
416 #define DW_OP_reg19 0x63
417 #define DW_OP_reg20 0x64
418 #define DW_OP_reg21 0x65
419 #define DW_OP_reg22 0x66
420 #define DW_OP_reg23 0x67
421 #define DW_OP_reg24 0x68
422 #define DW_OP_reg25 0x69
423 #define DW_OP_reg26 0x6a
424 #define DW_OP_reg27 0x6b
425 #define DW_OP_reg28 0x6c
426 #define DW_OP_reg29 0x6d
427 #define DW_OP_reg30 0x6e
428 #define DW_OP_reg31 0x6f
429 #define DW_OP_breg0 0x70
430 #define DW_OP_breg1 0x71
431 #define DW_OP_breg2 0x72
432 #define DW_OP_breg3 0x73
433 #define DW_OP_breg4 0x74
434 #define DW_OP_breg5 0x75
435 #define DW_OP_breg6 0x76
436 #define DW_OP_breg7 0x77
437 #define DW_OP_breg8 0x78
438 #define DW_OP_breg9 0x79
439 #define DW_OP_breg10 0x7a
440 #define DW_OP_breg11 0x7b
441 #define DW_OP_breg12 0x7c
442 #define DW_OP_breg13 0x7d
443 #define DW_OP_breg14 0x7e
444 #define DW_OP_breg15 0x7f
445 #define DW_OP_breg16 0x80
446 #define DW_OP_breg17 0x81
447 #define DW_OP_breg18 0x82
448 #define DW_OP_breg19 0x83
449 #define DW_OP_breg20 0x84
450 #define DW_OP_breg21 0x85
451 #define DW_OP_breg22 0x86
452 #define DW_OP_breg23 0x87
453 #define DW_OP_breg24 0x88
454 #define DW_OP_breg25 0x89
455 #define DW_OP_breg26 0x8a
456 #define DW_OP_breg27 0x8b
457 #define DW_OP_breg28 0x8c
458 #define DW_OP_breg29 0x8d
459 #define DW_OP_breg30 0x8e
460 #define DW_OP_breg31 0x8f
461 #define DW_OP_regx 0x90
462 #define DW_OP_fbreg 0x91
463 #define DW_OP_bregx 0x92
464 #define DW_OP_piece 0x93
465 #define DW_OP_deref_size 0x94
466 #define DW_OP_xderef_size 0x95
467 #define DW_OP_nop 0x96
468 #define DW_OP_push_object_address 0x97
469 #define DW_OP_call2 0x98
470 #define DW_OP_call4 0x99
471 #define DW_OP_call_ref 0x9a
472 #define DW_OP_form_tls_address 0x9b
473 #define DW_OP_call_frame_cfa 0x9c
474 #define DW_OP_bit_piece 0x9d
475 #define DW_OP_implicit_value 0x9e
476 #define DW_OP_stack_value 0x9f
477 
478 /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */
479 #define DW_OP_lo_user 0xe0
480 #define DW_OP_hi_user 0xff
481 
482 #define DW_ATE_address 0x01
483 #define DW_ATE_boolean 0x02
484 #define DW_ATE_complex_float 0x03
485 #define DW_ATE_float 0x04
486 #define DW_ATE_signed 0x05
487 #define DW_ATE_signed_char 0x06
488 #define DW_ATE_unsigned 0x07
489 #define DW_ATE_unsigned_char 0x08
490 #define DW_ATE_imaginary_float 0x09
491 #define DW_ATE_packed_decimal 0x0a
492 #define DW_ATE_numeric_string 0x0b
493 #define DW_ATE_edited 0x0c
494 #define DW_ATE_signed_fixed 0x0d
495 #define DW_ATE_unsigned_fixed 0x0e
496 #define DW_ATE_decimal_float 0x0f
497 #define DW_ATE_UTF 0x10
498 
499 /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */
500 #define DW_ATE_lo_user 0x80
501 #define DW_ATE_hi_user 0xff
502 
503 #define DW_DS_unsigned 0x01
504 #define DW_DS_leading_overpunch 0x02
505 #define DW_DS_trailing_overpunch 0x03
506 #define DW_DS_leading_separate 0x04
507 #define DW_DS_trailing_separate 0x05
508 
509 #define DW_END_default 0x00
510 #define DW_END_big 0x01
511 #define DW_END_little 0x02
512 
513 /* <_lo_user ; _hi_user> Interval is reserved for vendor extensions */
514 #define DW_END_lo_user 0x40
515 #define DW_END_hi_user 0xff
516 
517 #define DW_ACCESS_public 0x01
518 #define DW_ACCESS_protected 0x02
519 #define DW_ACCESS_private 0x03
520 
521 #define DW_VIS_local 0x01
522 #define DW_VIS_exported 0x02
523 #define DW_VIS_qualified 0x03
524 
525 #define DW_VIRTUALITY_none 0x00
526 #define DW_VIRTUALITY_virtual 0x01
527 #define DW_VIRTUALITY_pure_virtual 0x02
528 
529 #define DW_LANG_C89 0x0001
530 #define DW_LANG_C 0x0002
531 #define DW_LANG_Ada83 0x0003
532 #define DW_LANG_C_plus_plus 0x0004
533 #define DW_LANG_Cobol74 0x0005
534 #define DW_LANG_Cobol85 0x0006
535 #define DW_LANG_Fortran77 0x0007
536 #define DW_LANG_Fortran90 0x0008
537 #define DW_LANG_Pascal83 0x0009
538 #define DW_LANG_Modula2 0x000a
539 #define DW_LANG_Java 0x000b
540 #define DW_LANG_C99 0x000c
541 #define DW_LANG_Ada95 0x000d
542 #define DW_LANG_Fortran95 0x000e
543 #define DW_LANG_PLI 0x000f
544 #define DW_LANG_ObjC 0x0010
545 #define DW_LANG_ObjC_plus_plus 0x0011
546 #define DW_LANG_UPC 0x0012
547 #define DW_LANG_D 0x0013
548 #define DW_LANG_Python 0x0014
549 #define DW_LANG_Rust 0x001c
550 #define DW_LANG_C11 0x001d
551 #define DW_LANG_Swift 0x001e
552 #define DW_LANG_Julia 0x001f
553 #define DW_LANG_Dylan 0x0020
554 #define DW_LANG_C_plus_plus_14 0x0021
555 #define DW_LANG_Fortran03 0x0022
556 #define DW_LANG_Fortran08 0x0023
557 #define DW_LANG_lo_user 0x8000
558 #define DW_LANG_hi_user 0xffff
559 
560 #define DW_ID_case_sensitive 0x00
561 #define DW_ID_up_case 0x01
562 #define DW_ID_down_case 0x02
563 #define DW_ID_case_insensitive 0x03
564 
565 #define DW_CC_normal 0x01
566 #define DW_CC_program 0x02
567 #define DW_CC_nocall 0x03
568 #define DW_CC_lo_user 0x40
569 #define DW_CC_hi_user 0xff
570 
571 #define DW_INL_not_inlined 0x00
572 #define DW_INL_inlined 0x01
573 #define DW_INL_declared_not_inlined 0x02
574 #define DW_INL_declared_inlined 0x03
575 
576 #define DW_ORD_row_major 0x00
577 #define DW_ORD_col_major 0x01
578 
579 #define DW_DSC_label 0x00
580 #define DW_DSC_range 0x01
581 
582 #define DW_MACINFO_define 0x01
583 #define DW_MACINFO_undef 0x02
584 #define DW_MACINFO_start_file 0x03
585 #define DW_MACINFO_end_file 0x04
586 #define DW_MACINFO_vendor_ext 0xff
587 
588 #define DW_CFA_advance_loc 0x40
589 #define DW_CFA_offset 0x80
590 #define DW_CFA_restore 0xc0
591 
592 #define DW_CFA_nop 0x00
593 #define DW_CFA_set_loc 0x01
594 #define DW_CFA_advance_loc1 0x02
595 #define DW_CFA_advance_loc2 0x03
596 #define DW_CFA_advance_loc4 0x04
597 #define DW_CFA_offse_extended 0x05
598 #define DW_CFA_restore_extended 0x06
599 #define DW_CFA_undefined 0x07
600 #define DW_CFA_same_value 0x08
601 #define DW_CFA_register 0x09
602 #define DW_CFA_remember_state 0x0a
603 #define DW_CFA_restore_state 0x0b
604 #define DW_CFA_def_cfa 0x0c
605 #define DW_CFA_def_cfa_register 0x0d
606 #define DW_CFA_def_cfa_offset 0x0e
607 #define DW_CFA_def_cfa_expression 0x0f
608 #define DW_CFA_expression 0x10
609 #define DW_CFA_offset_extended_sf 0x11
610 #define DW_CFA_def_cfa_sf 0x12
611 #define DW_CFA_def_cfa_offset_sf 0x13
612 #define DW_CFA_val_offset 0x14
613 #define DW_CFA_val_offset_sf 0x15
614 #define DW_CFA_val_expression 0x16
615 #define DW_CFA_lo_user 0x1c
616 #define DW_CFA_hi_user 0x3f
617 
618 #define DW_UT_compile 0x01
619 #define DW_UT_type 0x02
620 #define DW_UT_partial 0x03
621 #define DW_UT_skeleton 0x04
622 #define DW_UT_split_compile 0x05
623 #define DW_UT_split_type 0x06
624 #define DW_UT_lo_user 0x80
625 #define DW_UT_hi_user 0xff
626 
627 typedef struct {
633  char line_base;
636  ut32 oplentable[12];
637  const char **incdirs;
638  const char *file[128];
640 #define RZ_BIN_DWARF_INFO_HEADER_FILE_LENGTH(x) (sizeof(x->file) / sizeof(*(x->file)))
641 
642 typedef struct {
644  unsigned int file;
645  unsigned int line;
646  unsigned int column;
647  int is_stmt;
651 
652 #define DWARF_INIT_LEN_64 0xffffffff
653 typedef union {
657 
658 typedef struct {
666 
667 typedef struct {
674 
675 typedef struct {
678  st64 special; // Used for values coded directly into abbrev
680 
681 typedef struct {
685 
686 // http://www.dwarfstd.org/doc/DWARF4.pdf#page=29&zoom=100,0,0
687 typedef enum {
700 
701 typedef struct dwarf_attr_kind {
705  /* This is subideal, as dw_form_data can be anything
706  we could lose information example: encoding signed
707  2 byte int into ut64 and then interpreting it as st64 TODO*/
708  union {
715  struct {
716  const char *content;
719  };
721 
727  return val->kind == DW_AT_KIND_STRING ? val->string.content : NULL;
728 }
729 
730 typedef struct {
731  // A 4-byte (or 8 byte for 64bit dwarf) unsigned length of the .debug_info contribution
732  // for that compilation unit, not including the length field itself.
735  // A 4-byte unsigned offset into the .debug_abbrev section.
737  // A 1 - byte size of an address on the target architecture.If the system uses
738  // segmented addressing, this value represents the size of the offset portion of an address.
740  ut8 unit_type; // DWARF 5 addition
741  ut8 dwo_id; // DWARF 5 addition
742  ut64 type_sig; // DWARF 5 addition
743  ut64 type_offset; // DWARF 5 addition
744  ut64 header_size; // excluding length field
746  bool is_64bit;
748 
749 typedef struct {
752  size_t count;
753  size_t capacity;
754  ut64 offset; // important for parsing types
755  bool has_children; // important for parsing types
757 } RzBinDwarfDie;
758 
759 typedef struct {
762  size_t count;
763  size_t capacity;
766 
767 #define COMP_UNIT_CAPACITY 8
768 #define DEBUG_INFO_CAPACITY 8
769 typedef struct {
770  size_t count;
771  size_t capacity;
773  HtUP /*<ut64 offset, DwarfDie *die>*/ *lookup_table;
774  size_t n_dwarf_dies;
775 
781  HtUP /*<ut64, char *>*/ *line_info_offset_comp_dir;
783 
784 #define ABBREV_DECL_CAP 8
785 
786 typedef struct {
791  size_t count;
792  size_t capacity;
795 
796 #define DEBUG_ABBREV_CAP 32
797 
798 typedef struct {
799  size_t count;
800  size_t capacity;
803 
804 #define DWARF_FALSE 0
805 #define DWARF_TRUE 1
806 
807 typedef struct {
821 
823  char *include_dir;
824  char *name;
827 
828 typedef struct {
829  ut64 offset; //< offset inside the debug_line section, for references from outside
841  bool is_64bit;
842 
851 
852  char **include_dirs;
857 
858 typedef enum {
859  RZ_BIN_DWARF_LINE_OP_TYPE_SPEC, //< single byte op, no args
860  RZ_BIN_DWARF_LINE_OP_TYPE_STD, //< fixed-size op, 0 or more leb128 args (except DW_LNS_fixed_advance_pc)
861  RZ_BIN_DWARF_LINE_OP_TYPE_EXT //< variable-size op, arbitrary format of args
863 
864 #define RZ_BIN_DWARF_LINE_OP_STD_ARGS_MAX 1
865 
866 typedef struct {
869  struct {
870  union {
871  ut64 advance_pc; //< DW_LNS_advance_pc
872  st64 advance_line; //< DW_LNS_advance_line
873  ut64 set_file; //< DW_LNS_set_file
874  ut64 set_column; //< DW_LNS_set_column
875  ut64 fixed_advance_pc; //< DW_LNS_fixed_advance_pc
876  ut64 set_isa; //< DW_LNS_set_isa
877  ut64 set_address; //< DW_LNE_set_address
878  struct {
879  char *filename;
881  } define_file; //< DW_LNE_define_file
882  ut64 set_discriminator; //< DW_LNE_set_discriminator
883  };
884  } args;
886 
891 typedef struct {
893 
894  size_t ops_count;
897 
901 typedef struct {
902  RzList /*<RzBinDwarfLineUnit>*/ *units;
905 
906 typedef enum {
907  RZ_BIN_DWARF_LINE_INFO_MASK_BASIC = 0x0, //< parse just the headers
908  RZ_BIN_DWARF_LINE_INFO_MASK_OPS = 0x1, //< decode and output all instructions
909  RZ_BIN_DWARF_LINE_INFO_MASK_LINES = 0x2 //< run instructions and output the resulting line infos
911 
912 typedef struct rz_bin_dwarf_loc_entry_t {
917 
918 typedef struct rz_bin_dwarf_loc_list_t {
919  RzList /*<RzBinDwarfLocRange>*/ *list;
922 
923 typedef struct rz_bin_dwarf_arange_t {
927 
933  bool is_64bit;
941 
942 #define rz_bin_dwarf_line_new(o, a, f, l) o->address = a, o->file = strdup(f ? f : ""), o->line = l, o->column = 0, o
943 
945 RZ_API const char *rz_bin_dwarf_get_attr_name(ut64 attr_code);
946 RZ_API const char *rz_bin_dwarf_get_attr_form_name(ut64 form_code);
947 RZ_API const char *rz_bin_dwarf_get_unit_type_name(ut64 unit_type);
948 RZ_API const char *rz_bin_dwarf_get_lang_name(ut64 lang);
949 
950 RZ_API RzList /*<RzBinDwarfARangeSet *>*/ *rz_bin_dwarf_parse_aranges(RzBinFile *binfile);
953 RZ_API HtUP /*<offset, RzBinDwarfLocList *>*/ *rz_bin_dwarf_parse_loc(RzBinFile *binfile, int addr_size);
955 RZ_API void rz_bin_dwarf_loc_free(HtUP /*<offset, RzBinDwarfLocList *>*/ *loc_table);
958 
965 typedef char **RzBinDwarfLineFileCache;
966 
979 
980 #ifdef __cplusplus
981 }
982 #endif
983 
984 #endif
#define mask()
static char * regs[]
Definition: analysis_sh.c:203
ut16 val
Definition: armass64_const.h:6
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
#define RZ_API
#define NULL
Definition: cris-opc.c:27
uint16_t ut16
uint32_t ut32
uint8_t ut8
Definition: lh5801.h:11
#define header(is_bt, len_min, ret_op)
int args
Definition: mipsasm.c:18
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API const char * rz_bin_dwarf_get_attr_name(ut64 attr_code)
Definition: dwarf.c:323
RZ_API RzBinDwarfDebugAbbrev * rz_bin_dwarf_parse_abbrev(RzBinFile *binfile)
Definition: dwarf.c:2144
struct rz_bin_dwarf_loc_list_t RzBinDwarfLocList
RZ_API const char * rz_bin_dwarf_get_lang_name(ut64 lang)
Definition: dwarf.c:387
RZ_API void rz_bin_dwarf_debug_abbrev_free(RzBinDwarfDebugAbbrev *da)
Definition: dwarf.c:1340
RzBinDwarfLineInfoMask
Definition: rz_bin_dwarf.h:906
@ RZ_BIN_DWARF_LINE_INFO_MASK_BASIC
Definition: rz_bin_dwarf.h:907
@ RZ_BIN_DWARF_LINE_INFO_MASK_OPS
Definition: rz_bin_dwarf.h:908
@ RZ_BIN_DWARF_LINE_INFO_MASK_LINES
Definition: rz_bin_dwarf.h:909
RZ_API st64 rz_bin_dwarf_line_header_get_spec_op_advance_line(const RzBinDwarfLineHeader *header, ut8 opcode)
Definition: dwarf.c:628
RZ_API void rz_bin_dwarf_line_header_free_file_cache(const RzBinDwarfLineHeader *hdr, RzBinDwarfLineFileCache fnc)
Definition: dwarf.c:589
RzBinDwarfAttrKind
Definition: rz_bin_dwarf.h:687
@ DW_AT_KIND_LINEPTR
Definition: rz_bin_dwarf.h:693
@ DW_AT_KIND_STRING
Definition: rz_bin_dwarf.h:698
@ DW_AT_KIND_REFERENCE
Definition: rz_bin_dwarf.h:697
@ DW_AT_KIND_BLOCK
Definition: rz_bin_dwarf.h:689
@ DW_AT_KIND_RANGELISTPTR
Definition: rz_bin_dwarf.h:696
@ DW_AT_KIND_CONSTANT
Definition: rz_bin_dwarf.h:690
@ DW_AT_KIND_ADDRESS
Definition: rz_bin_dwarf.h:688
@ DW_AT_KIND_FLAG
Definition: rz_bin_dwarf.h:692
@ DW_AT_KIND_MACPTR
Definition: rz_bin_dwarf.h:695
@ DW_AT_KIND_EXPRLOC
Definition: rz_bin_dwarf.h:691
@ DW_AT_KIND_LOCLISTPTR
Definition: rz_bin_dwarf.h:694
RZ_API void rz_bin_dwarf_line_info_free(RzBinDwarfLineInfo *li)
Definition: dwarf.c:1352
RZ_API void rz_bin_dwarf_loc_free(HtUP *loc_table)
Definition: dwarf.c:2283
RZ_API void rz_bin_dwarf_line_op_fini(RzBinDwarfLineOp *op)
Definition: dwarf.c:699
struct rz_bin_dwarf_arange_t RzBinDwarfARange
RZ_API const char * rz_bin_dwarf_get_attr_form_name(ut64 form_code)
Definition: dwarf.c:373
static const char * rz_bin_dwarf_attr_value_get_string_content(const RzBinDwarfAttrValue *val)
Safely get the string content from an RzBinDwarfAttrValue if it has one.
Definition: rz_bin_dwarf.h:725
RZ_API ut64 rz_bin_dwarf_line_header_get_spec_op_advance_pc(const RzBinDwarfLineHeader *header, ut8 opcode)
Definition: dwarf.c:618
RZ_API void rz_bin_dwarf_line_header_reset_regs(const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs)
Definition: dwarf.c:824
RZ_API char * rz_bin_dwarf_line_header_get_full_file_path(RZ_NULLABLE const RzBinDwarfDebugInfo *info, const RzBinDwarfLineHeader *header, ut64 file_index)
Definition: dwarf.c:547
struct rz_bin_dwarf_arange_set_t RzBinDwarfARangeSet
DWARF 3 Standard Section 6.1.2 Lookup by Address.
RZ_API const char * rz_bin_dwarf_get_tag_name(ut64 tag)
Definition: dwarf.c:316
RZ_API RzList * rz_bin_dwarf_parse_aranges(RzBinFile *binfile)
Definition: dwarf.c:2132
RZ_API void rz_bin_dwarf_arange_set_free(RzBinDwarfARangeSet *set)
Definition: dwarf.c:1106
RzBinDwarfLineOpType
Definition: rz_bin_dwarf.h:858
@ RZ_BIN_DWARF_LINE_OP_TYPE_SPEC
Definition: rz_bin_dwarf.h:859
@ RZ_BIN_DWARF_LINE_OP_TYPE_EXT
Definition: rz_bin_dwarf.h:861
@ RZ_BIN_DWARF_LINE_OP_TYPE_STD
Definition: rz_bin_dwarf.h:860
char ** RzBinDwarfLineFileCache
Opaque cache for fully resolved filenames during Dwarf Line Info Generation This cache stores full fi...
Definition: rz_bin_dwarf.h:965
RZ_API RzBinDwarfDebugInfo * rz_bin_dwarf_parse_info(RzBinFile *binfile, RzBinDwarfDebugAbbrev *da)
Parses .debug_info section.
Definition: dwarf.c:2075
RZ_API const char * rz_bin_dwarf_get_unit_type_name(ut64 unit_type)
Definition: dwarf.c:380
RZ_API HtUP * rz_bin_dwarf_parse_loc(RzBinFile *binfile, int addr_size)
Parses out the .debug_loc section into a table that maps each list as offset of a list -> LocationLis...
Definition: dwarf.c:2259
RZ_API RzBinDwarfLineFileCache rz_bin_dwarf_line_header_new_file_cache(const RzBinDwarfLineHeader *hdr)
Definition: dwarf.c:585
RZ_API void rz_bin_dwarf_debug_info_free(RzBinDwarfDebugInfo *inf)
Definition: dwarf.c:1407
RZ_API ut64 rz_bin_dwarf_line_header_get_adj_opcode(const RzBinDwarfLineHeader *header, ut8 opcode)
Definition: dwarf.c:613
RZ_API RzBinDwarfLineInfo * rz_bin_dwarf_parse_line(RzBinFile *binfile, RZ_NULLABLE RzBinDwarfDebugInfo *info, RzBinDwarfLineInfoMask mask)
Definition: dwarf.c:2119
RZ_API bool rz_bin_dwarf_line_op_run(const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs, RzBinDwarfLineOp *op, RZ_NULLABLE struct rz_bin_source_line_info_builder_t *bob, RZ_NULLABLE RzBinDwarfDebugInfo *info, RZ_NULLABLE RzBinDwarfLineFileCache fnc)
struct rz_bin_dwarf_line_file_entry_t RzBinDwarfLineFileEntry
struct dwarf_attr_kind RzBinDwarfAttrValue
struct rz_bin_dwarf_loc_entry_t RzBinDwarfLocRange
#define RZ_NULLABLE
Definition: rz_types.h:65
#define st64
Definition: rz_types_base.h:10
#define st32
Definition: rz_types_base.h:12
RzBinDwarfAttrDef * defs
Definition: rz_bin_dwarf.h:793
section_offset debug_info_offset
Definition: rz_bin_dwarf.h:670
RzBinDwarfDie * dies
Definition: rz_bin_dwarf.h:764
RzBinDwarfCompUnitHdr hdr
Definition: rz_bin_dwarf.h:760
RzBinDwarfAbbrevDecl * decls
Definition: rz_bin_dwarf.h:801
RzBinDwarfCompUnit * comp_units
Definition: rz_bin_dwarf.h:772
HtUP * line_info_offset_comp_dir
Definition: rz_bin_dwarf.h:781
RzBinDwarfAttrValue * attr_values
Definition: rz_bin_dwarf.h:756
const char ** incdirs
Definition: rz_bin_dwarf.h:637
ut8 * std_opcode_lengths
The number of LEB128 operands for each of the standard opcodes From standard_opcode_lengths in DWARF ...
Definition: rz_bin_dwarf.h:850
RzBinDwarfLineFileEntry * file_names
Definition: rz_bin_dwarf.h:854
Line info of all compilation units from the entire debug_line section.
Definition: rz_bin_dwarf.h:901
struct rz_bin_source_line_info_t * lines
Definition: rz_bin_dwarf.h:903
RzBinDwarfLineOpType type
Definition: rz_bin_dwarf.h:867
DWARF 3 Standard Section 6.2 Line Number Information This contains the entire raw line info for one c...
Definition: rz_bin_dwarf.h:891
RzBinDwarfLineHeader header
Definition: rz_bin_dwarf.h:892
RzBinDwarfLineOp * ops
Definition: rz_bin_dwarf.h:895
unsigned int column
Definition: rz_bin_dwarf.h:646
unsigned int file
Definition: rz_bin_dwarf.h:644
unsigned int line
Definition: rz_bin_dwarf.h:645
section_offset debug_abbrev_offset
Definition: rz_bin_dwarf.h:661
section_offset type_offset
Definition: rz_bin_dwarf.h:664
RzBinDwarfBlock block
Definition: rz_bin_dwarf.h:710
RzBinDwarfAttrKind kind
Definition: rz_bin_dwarf.h:704
struct dwarf_attr_kind::@251::@253 string
const char * content
Definition: rz_bin_dwarf.h:716
Definition: gzappend.c:170
DWARF 3 Standard Section 6.1.2 Lookup by Address.
Definition: rz_bin_dwarf.h:931
RzBinDwarfARange * aranges
Definition: rz_bin_dwarf.h:939
Definition: rz_bin_dwarf.h:822
ut32 file_len
Definition: rz_bin_dwarf.h:825
ut32 id_idx
Definition: rz_bin_dwarf.h:825
char * include_dir
Definition: rz_bin_dwarf.h:823
char * name
Definition: rz_bin_dwarf.h:824
ut32 mod_time
Definition: rz_bin_dwarf.h:825
Definition: rz_bin_dwarf.h:912
ut64 start
Definition: rz_bin_dwarf.h:913
ut64 end
Definition: rz_bin_dwarf.h:914
RzBinDwarfBlock * expression
Definition: rz_bin_dwarf.h:915
XX curplugin == o->plugin.
Definition: rz_bin.h:298
Definition: dis.c:32
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
int inf(FILE *source, FILE *dest)
Definition: zpipe.c:92