Debian Codegraph @

src/lib/libdwarf/dwarf_opaque.h

raw
1 /*
2 Copyright (C) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
3 Portions Copyright (C) 2007-2024 David Anderson. All Rights Reserved.
4 Portions Copyright (C) 2008-2010 Arxan Technologies, Inc. All Rights Reserved.
5
6 This program is free software; you can redistribute it
7 and/or modify it under the terms of version 2.1 of the
8 GNU Lesser General Public License as published by the Free
9 Software Foundation.
10
11 This program is distributed in the hope that it would be
12 useful, but WITHOUT ANY WARRANTY; without even the implied
13 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE.
15
16 Further, this software is distributed without any warranty
17 that it is free of the rightful claim of any third person
18 regarding infringement or the like. Any license provided
19 herein, whether implied or otherwise, applies only to this
20 software file. Patent licenses, if any, provided herein
21 do not apply to combinations of this program with other
22 software, or any other product whatsoever.
23
24 You should have received a copy of the GNU Lesser General
25 Public License along with this program; if not, write the
26 Free Software Foundation, Inc., 51 Franklin Street - Fifth
27 Floor, Boston MA 02110-1301, USA.
28
29 */
30 /* Following the nomenclature of the DWARF standard
31 Section Version Numbers (DWARF 5):
32 * means not applicable.
33 - means not defined in that version.
34 The version numbers for .debug_info is the same as .debug_info.dwo
35 (etc for the other dwo sections).
36 The versions applicable by section are:
37 . DWARF2 DWARF3 DWARF4 DWARF5
38 .debug_abbrev * * * *
39 .debug_addr - - - 5
40 .debug_aranges 2 2 2 2
41 .debug_frame 1 3 4 4
42 .debug_info 2 3 4 5
43 .debug_line 2 3 4 5
44 .debug_line_str - - - 5
45 .debug_loc * * * -
46 .debug_loclists - - - 5
47 .debug_macinfo * * * -
48 .debug_macro - - - 5
49 .debug_names - - - 5
50 .debug_pubnames 2 2 2 -
51 .debug_pubtypes - 2 2 -
52 .debug_ranges - * * -
53 .debug_rnglists - - - 5
54 .debug_str * * * *
55 .debug_str_offsets - - - 5
56 .debug_sup - - - 5
57 .debug_types - - 4 -
58
59 .debug_abbrev.dwo - - - *
60 .debug_info.dwo - - - 5
61 .debug_line.dwo - - - 5
62 .debug_loc.dwo - - - -
63 .debug_loclists.dwo - - - 5
64 .debug_macro.dwo - - - 5
65 .debug_rnglists.dwo - - - 5
66 .debug_str.dwo - - - *
67 .debug_str_offsets.dwo - - - 5
68
69 .debug_cu_index - - - 5
70 .debug_tu_index - - - 5
71
72 */
73 #define DBG_IS_SECONDARY(p) ((p) && (p)->de_secondary_dbg && \
74 ((p)->de_secondary_dbg == (p)))
75 #define DBG_IS_PRIMARY(p) ((p) && ((!(p)->de_secondary_dbg) || \
76 ((p)->de_secondary_dbg && ((p)->de_secondary_dbg != (p)))))
77 #define DBG_HAS_SECONDARY(p) (DBG_IS_PRIMARY(p) && \
78 (DBG_IS_SECONDARY((p)->de_secondary_dbg)))
79
80 #define DEBUG_PRIMARY_DBG 1 /* only for debugging */
81 #undef DEBUG_PRIMARY_DBG
82 #ifdef DEBUG_PRIMARY_DBG
83 const char *
84 _dwarf_basename(const char *full);
85
86 void
87 _dwarf_print_is_primary(const char *msg,Dwarf_Debug p,int line,
88 const char *filepath);
89 void
90 _dwarf_dump_prim_sec(const char *msg,Dwarf_Debug p, int line,
91 const char *filepath);
92 void
93 _dwarf_dump_optional_fields(const char *msg,
94 Dwarf_CU_Context context,
95 int line,
96 const char *filepath);
97 #endif /* DEBUG_PRIMARY_DBG */
98
99 struct Dwarf_Rnglists_Context_s;
100 typedef struct Dwarf_Rnglists_Context_s *Dwarf_Rnglists_Context;
101 struct Dwarf_Loclists_Context_s;
102 typedef struct Dwarf_Loclists_Context_s *Dwarf_Loclists_Context;
103
104 struct Dwarf_Die_s {
105 Dwarf_Byte_Ptr di_debug_ptr;
106 Dwarf_Abbrev_List di_abbrev_list;
107 Dwarf_CU_Context di_cu_context;
108 /* Abbrev codes are expected to be smallish numbers,
109 but the Standard does not require smallish numbers. */
110 Dwarf_Unsigned di_abbrev_code;
111 /* TRUE if part of debug_info. FALSE if part of .debug_types. */
112 Dwarf_Bool di_is_info;
113 };
114
115 struct Dwarf_Attribute_s {
116 Dwarf_Half ar_attribute; /* Attribute Value. */
117 Dwarf_Half ar_attribute_form; /* Attribute Form. */
118 Dwarf_Half ar_attribute_form_direct;
119 /* *form_direct Identical to ar_attribute_form
120 except that if
121 the original form uleb was DW_FORM_indirect,
122 ar_attribute_form_direct contains DW_FORM_indirect
123 but ar_attribute_form contains the true form. */
124
125 Dwarf_CU_Context ar_cu_context;
126 /* The following points to either debug_info or debug_types
127 depending on if context is cc_is_info or not. */
128 Dwarf_Small *ar_debug_ptr;
129 /* If DW_FORM_implicit const, the value is here, not
130 in the DIE. */
131 Dwarf_Signed ar_implicit_const;
132 Dwarf_Debug ar_dbg; /* dbg owning the attr */
133
134 Dwarf_Die ar_die;/* Access to the DIE owning the attribute */
135 Dwarf_Attribute ar_next;
136 };
137
138 #define CC_PROD_METROWERKS 1
139 #define CC_PROD_Apple 2 /* Apple clang */
140
141 /*
142 This structure provides the context for a compilation unit.
143 Thus, it contains the Dwarf_Debug, cc_dbg, that this cu
144 belongs to. It contains the information
145 in the compilation unit header, cc_length,
146 cc_version_stamp, cc_abbrev_offset,
147 and cc_address_size, in the .debug_info section for that cu.
148 In addition, it contains the count, cc_count_cu, of the cu
149 number of that cu in the list of cu's in the .debug_info.
150 The count starts at 1, ie cc_count_cu is 1 for the first cu,
151 2 for the second and so on. This struct also contains a
152 pointer, to a list of pairs of abbrev code
153 and a pointer to the start of that abbrev
154 in the .debug_abbrev section.
155
156 Each die will also contain a pointer to such a struct to
157 record the context for that die.
158
159 Notice that a pointer to the CU DIE itself is
160 Dwarf_Off off2 = cu_context->cc_debug_info_offset;
161 cu_die_info_ptr = dbg->de_debug_info.dss_data +
162 off2 + _dwarf_length_of_cu_header(dbg, off2);
163 Or similar for de_debug_types.
164
165 **Updated by dwarf_next_cu_header in dwarf_die_deliv.c
166 */
167 struct Dwarf_CU_Context_s {
168 Dwarf_Debug cc_dbg;
169 /* The sum of cc_length, cc_length_size, and cc_extension_size
170 is the total length of the CU including its header.
171 cc_length is the length of the compilation unit excluding
172 cc_length_size and cc_extension_size. */
173 Dwarf_Unsigned cc_length;
174
175 /* cc_length_size is the size in bytes of an offset.
176 Should probably be renamed cc_offset_size.
177 4 for 32bit dwarf, 8 for 64bit dwarf (whether MIPS/IRIX
178 64bit dwarf or standard 64bit dwarf using the extension
179 mechanism). */
180 Dwarf_Small cc_length_size;
181
182 /* cc_extension_size is zero unless this is standard
183 DWARF3 and later 64bit dwarf using the extension mechanism.
184 64bit DWARF3 and later: cc_extension_size is 4.
185 64bit DWARF2 MIPS/IRIX: cc_extension_size is zero.
186 32bit DWARF: cc_extension_size is zero. */
187 Dwarf_Small cc_extension_size;
188
189 /* cc_version_stamp is the DWARF version number applicable
190 to the DWARF in this compilation unit. 2,3,4,... */
191 Dwarf_Half cc_version_stamp;
192 /* cc_abbrev_offset is the section-global offset
193 of the .debug_abbrev section this CU uses.
194 Data from CU header. Includes DWP adjustment made
195 as soon as we create a cu_context. */
196 Dwarf_Unsigned cc_abbrev_offset;
197
198 /* cc_address_size is the size of an address in this
199 compilation unit. */
200 Dwarf_Small cc_address_size;
201 Dwarf_Small cc_segment_selector_size;
202 /* Normally zero, For the defective Metrowerks
203 compiler is set to CC_PROD_METROW */
204 Dwarf_Small cc_producer;
205
206 /* cc_debug_offset is the global offset in the section
207 of the area length field of the CU.
208 The CU header of the CU is at offset
209 cc_debug_offset+cc_length_size+cc_extension_size;
210 This is a section global offset.
211 May be debug_info or debug_types.
212 Even in DWP this is set to true global offset
213 right away when cu_context created.
214 See cc_is_info flag. */
215 Dwarf_Unsigned cc_debug_offset;
216
217 /* === START DEBUG FISSION (Split Dwarf) data
218 cc_signature is in the TU header
219 of a type unit of a TU DIE (or for DW5 in the
220 skeleton or split_compile header is a dwo_id).
221 Ignore this field if cc_signature_present is zero.
222 (TU CUs signature is not the same namespace
223 as DW_AT_dwo_id signatures. The two must be
224 kept separate (for DWARF5))
225
226 If cc_unit_type == DW_UT_compile or DW_UT_partial
227 the signature is a CU signature (dwo_id).
228 Some early DW5 drafts encouraged DWARF4 output
229 of some compilers to include dwo_id, but
230 in a messier way(lacking DW_UT_*).
231 If cc_unit_type == DW_UT_split_type
232 the signature is a type signature. */
233 Dwarf_Half cc_cu_die_tag;
234
235 Dwarf_Sig8 cc_signature;
236
237 /* cc_type_signature_offset contains the
238 section-local DIE offset of the type
239 the signature applies to if the cc_unit_type
240 is DW_UT_type or DW_UT_split_type. */
241 Dwarf_Unsigned cc_signature_offset;
242
243 /* For each CU and each TU
244 in a dwp package file there is
245 is a hash and
246 a set of offsets indexed by DW_SECT_* id.
247 Only one such set per CU or TU.
248 The data on all that is in cc_dwp_offsets
249
250 If it is a TU the signature in cc_dwp_offsets
251 must match the signature in cc_signature.
252 */
253 struct Dwarf_Debug_Fission_Per_CU_s cc_dwp_offsets;
254
255 Dwarf_Bool cc_signature_present; /* Meaning type signature
256 in TU header or, for CU header, signature in CU DIE. */
257
258 /* cc_low_pc[_present] is applied as base address of
259 of rnglists and loclists when reading an rle_head,
260 compied into cc_cu_base_address. Comes from
261 CU_DIE, not rnglists or loclists */
262 Dwarf_Bool cc_low_pc_present;
263
264 /* From CU_DIE. Copied from cc_low_pc_present.
265 Used as default base address for rnglists, loclists.
266 in a DWARF5 dwo, inherited from skeleton (tieddbg). */
267 Dwarf_Bool cc_base_address_present;
268
269 Dwarf_Bool cc_cu_die_has_children;
270 Dwarf_Bool cc_dwo_name_present;
271 Dwarf_Bool cc_at_strx_present;
272
273 /* Non zero if this context is a dwo section. Either
274 dwo or dwp file. */
275 Dwarf_Bool cc_is_dwo;
276
277 /* cc_cu_die_offset_present is non-zero if
278 cc_cu_die_global_sec_offset is meaningful. */
279 Dwarf_Bool cc_cu_die_offset_present;
280 Dwarf_Bool cc_at_ranges_offset_present;
281 /* About: DW_AT_addr_base in CU DIE,
282 offset to .debug_addr table */
283 Dwarf_Bool cc_addr_base_offset_present;
284
285 /* If present, is base address of CU. In DWARF2
286 nothing says what attribute is the base address.
287 DW_AT_producer 4.2.1 (Based on Apple Inc. build 5658)
288 (LLVM build 2336.1.00) uses DW_AT_entry_pc as the
289 base address. DW_AT_entry_pc first appears
290 in DWARF3.
291 We allow DW_AT_entry_pc as an extension,
292 as a 'low_pc' if there is DW_AT_entry_pc with
293 no DW_AT_low_pc. 19 May 2022.
294 In DWARF3, DWARF4 DW_AT_low_pc is specifically
295 mentioned as the base address. */
296 Dwarf_Unsigned cc_low_pc;
297
298 /* from DW_AT_addr_base in CU DIE, offset to .debug_addr table */
299 Dwarf_Unsigned cc_addr_base_offset; /* Zero in .dwo */
300
301 /* From cc_low_pc, used as initial base_address
302 in processing loclists and rnglists */
303 Dwarf_Unsigned cc_base_address;
304
305 /* DW_SECT_LINE */
306 Dwarf_Bool cc_line_base_present; /*DW5 */
307 Dwarf_Unsigned cc_line_base; /*DW5 */
308 Dwarf_Unsigned cc_line_base_contr_size; /*DW5 */
309
310 /* From DW_AT_loclists_base or
311 computed from DW_SECT_LOCLISTS */
312 Dwarf_Unsigned cc_loclists_base;
313 Dwarf_Unsigned cc_loclists_base_contr_size;
314 Dwarf_Bool cc_loclists_base_present;
315 /* via_at means there was a DW_AT_loclists_base */
316 Dwarf_Bool cc_loclists_base_via_at;
317 Dwarf_Bool cc_loclists_header_length_present;
318
319 /* ======= str_offsets table data =======*/
320 /* header_offset is global offset in str_offsets section
321 of an array of string offsets. Not a header offset
322 at all.
323 from DW_AT_str_offsets_base DW5 page 66 item 13.
324 Not related to the Name Table */
325 /* Set from DW_AT_str_offsets_base. Global offset. */
326 Dwarf_Bool cc_str_offsets_array_offset_present;
327 Dwarf_Unsigned cc_str_offsets_array_offset;
328
329 /* Set from str_offsets header, means all the relevant
330 data from the header is present. Does not mean
331 the data from DW_AT_str_offsets_base is present */
332 Dwarf_Bool cc_str_offsets_tab_present;
333 /* Set from str_offsets header. */
334 Dwarf_Unsigned cc_str_offsets_header_offset;
335
336 /* Set by reading str_offsets header. Local offset
337 from header to its array. */
338 Dwarf_Unsigned cc_str_offsets_tab_to_array;
339
340 /* The following three set but not used. Might
341 be useful for error checking. */
342 Dwarf_Unsigned cc_str_offsets_offset_size;
343 /* The size of the table from table header
344 to end of this table. Not the size of array
345 in the table */
346 Dwarf_Unsigned cc_str_offsets_table_size;
347 Dwarf_Half cc_str_offsets_version;
348 /* ======= end str_offsets table data =======*/
349
350 /* DW_SECT_MACRO */
351 Dwarf_Unsigned cc_macro_base; /*DW5 */
352 Dwarf_Unsigned cc_macro_base_contr_size; /*DW5 */
353 Dwarf_Bool cc_macro_base_present;
354 Dwarf_Bool cc_macro_header_length_present;
355
356 /* For quick access to .debug_ranges from a CU DIE. */
357 Dwarf_Unsigned cc_at_ranges_offset;
358 /* DW_SECT_RNGLISTS */
359 /* DW_AT_GNU_ranges_base was a GNU extension that appeared
360 but was unused. See dwarf_die_deliv.c for details. */
361 Dwarf_Unsigned cc_ranges_base;
362 /* DW_AT_GNU_ranges_base is a GNU extension, DW4 */
363 Dwarf_Bool cc_ranges_base_present;
364 /* .debug_rnglists */
365 Dwarf_Unsigned cc_rnglists_base; /*DW5 */
366 Dwarf_Unsigned cc_rnglists_base_contr_size; /*DW5 */
367 Dwarf_Bool cc_rnglists_base_present; /* DW5 */
368 /* via_at means there was a DW_AT_rnglists_base */
369 Dwarf_Bool cc_rnglists_base_via_at;
370 Dwarf_Bool cc_rnglists_header_length_present;
371
372 char * cc_dwo_name;
373 /* === END DEBUG FISSION (Split Dwarf) data */
374
375 /* Global section offset to the bytes of the CU die for this CU.
376 Set when the CU die is accessed by dwarf_siblingof_b(). */
377 Dwarf_Unsigned cc_cu_die_global_sec_offset;
378
379 Dwarf_Byte_Ptr cc_last_abbrev_ptr;
380 Dwarf_Byte_Ptr cc_last_abbrev_endptr;
381 Dwarf_Hash_Table cc_abbrev_hash_table;
382 Dwarf_Unsigned cc_highest_known_code;
383 Dwarf_CU_Context cc_next;
384
385 Dwarf_Bool cc_is_info; /* TRUE means context is
386 in debug_info, FALSE means is in debug_types.
387 FALSE only possible for DWARF4 .debug_types
388 section CUs.
389 For DWARF5 all DIEs are in .debug_info[.dwo] */
390
391 Dwarf_Half cc_unit_type; /* DWARF5
392 Set from header as a DW_UT_ value.
393 For DWARF 2,3,4 this is filled in initially
394 from the CU header and refined by inspecting
395 the CU DIE to detect the correct setting. */
396
397 };
398
399 /* Consolidates section-specific data in one place.
400 Section is an Elf specific term, intended as a general
401 term (for non-Elf objects some code must synthesize the
402 values somehow). */
403 struct Dwarf_Section_s {
404 Dwarf_Small * dss_data;
405 Dwarf_Unsigned dss_size;
406 /* Some Elf sections have a non-zero dss_entrysize which
407 is the size in bytes of a table entry in the section.
408 Relocations and symbols are both in tables, so have a
409 non-zero entrysize. Object formats which do not care
410 about this should leave this field zero. */
411 Dwarf_Unsigned dss_entrysize;
412 /* dss_index is the section index as things are numbered in
413 an object file being read. An Elf section number. */
414 Dwarf_Unsigned dss_index;
415 /* dss_addr is the 'section address' which is only
416 non-zero for a GNU eh section.
417 Purpose: to handle DW_EH_PE_pcrel encoding. Leaving
418 it zero is fine for non-elf. */
419 Dwarf_Addr dss_addr;
420 Dwarf_Small dss_data_was_malloc;
421 /* is_in_use set during initial object reading to
422 detect duplicates. Ignored after setup done. */
423 Dwarf_Small dss_is_in_use;
424
425 /* When loading COMDAT they refer (sometimes) to
426 base sections, so we need to have the BASE
427 group sections filled in when the corresponding is
428 not in the COMDAT group list. .debug_abbrev is
429 an example. */
430 Dwarf_Unsigned dss_group_number;
431
432 /* These for reporting compression */
433 Dwarf_Unsigned dss_uncompressed_length;
434 Dwarf_Unsigned dss_compressed_length;
435
436 /* If this is zdebug, to start data/size are the
437 raw section bytes.
438 Initially for all sections dss_data_was_malloc set FALSE
439 and dss_requires_decompress set FALSE.
440 For zdebug set dss_zdebug_requires_decompress set TRUE
441 In that case it is likely ZLIB compressed but
442 we do not know that just scanning section headers.
443 If not .zdebug but it is SHF_COMPRESSED
444 then decompress is required.
445
446 On translation (ie zlib use and malloc)
447 Set dss_data dss_size to point to malloc space and
448 malloc size.
449 Set dss_did_decompress FALSE
450 Set dss_was_malloc TRUE */
451 Dwarf_Small dss_zdebug_requires_decompress;
452 Dwarf_Small dss_did_decompress;
453 Dwarf_Small dss_shf_compressed; /* section flag SHF_COMPRESS */
454
455 /* Section compression starts with ZLIB chars*/
456 Dwarf_Small dss_ZLIB_compressed;
457
458 /* For non-elf, leaving the following fields zero
459 will mean they are ignored. */
460 /* dss_link should be zero unless a section has a link
461 to another (sh_link). Used to access relocation data for
462 a section (and for symtab section, access its strtab). */
463 Dwarf_Unsigned dss_link;
464 /* The following is used when reading .rela sections
465 (such sections appear in some .o files). */
466 Dwarf_Unsigned dss_reloc_index; /* Zero means ignore
467 the reloc fields. */
468 Dwarf_Small * dss_reloc_data;
469 Dwarf_Unsigned dss_reloc_size;
470 Dwarf_Unsigned dss_reloc_entrysize;
471 Dwarf_Addr dss_reloc_addr;
472 /* dss_reloc_symtab is the sh_link of a .rela
473 to its .symtab, leave
474 it 0 if non-meaningful. */
475 Dwarf_Addr dss_reloc_symtab;
476 /* dss_reloc_link should be zero unless a reloc section
477 has a link to another (sh_link).
478 Used to access the symtab for relocating a section. */
479 Dwarf_Unsigned dss_reloc_link;
480 /* Pointer to the elf symtab, used for elf .rela. Leave it 0
481 if not relevant. */
482 struct Dwarf_Section_s *dss_symtab;
483 /* dss_name, dss_standard_name must never be freed,
484 they are static strings in libdwarf. */
485 const char * dss_name;
486 const char * dss_standard_name;
487
488 /* Object section number in object file. */
489 Dwarf_Unsigned dss_number;
490
491 /* These are elf flags and non-elf object should
492 just leave these fields zero. */
493 Dwarf_Unsigned dss_flags;
494 Dwarf_Unsigned dss_addralign;
495
496 /* Set when loading .group section as those are special and
497 neither compressed nor have relocations so never malloc
498 space for libdwarf. */
499 Dwarf_Small dss_ignore_reloc_group_sec;
500 char dss_is_rela;
501 };
502
503 /* Overview: if next_to_use== first, no error slots are used.
504 If next_to_use+1 (mod maxcount) == first the slots are all used
505 */
506 struct Dwarf_Harmless_s {
507 unsigned dh_maxcount;
508 unsigned dh_next_to_use;
509 unsigned dh_first;
510 unsigned dh_errs_count;
511 char ** dh_errors;
512 };
513
514 /* Data needed separately for debug_info and debug_types
515 as we may be reading both interspersed. So we always
516 select the one we need. */
517 struct Dwarf_Debug_InfoTypes_s {
518 /* Context for the compilation_unit just read by a call to
519 dwarf_next_cu_header. **Updated by dwarf_next_cu_header in
520 dwarf_die_deliv.c */
521 Dwarf_CU_Context de_cu_context;
522 /* Points to linked list of CU Contexts for the
523 CU's already read. These are only CU's read
524 by dwarf_next_cu_header(). */
525 Dwarf_CU_Context de_cu_context_list;
526 /* Points to the last CU Context added to the list by
527 dwarf_next_cu_header(). */
528 Dwarf_CU_Context de_cu_context_list_end;
529
530 /* Offset of last byte of last CU read.
531 Actually one-past that last byte. So
532 use care and compare as offset >= de_last_offset
533 to know if offset is too big. */
534 Dwarf_Unsigned de_last_offset;
535 /* de_last_di_info_ptr and de_last_die are used with
536 dwarf_siblingof, dwarf_child, and dwarf_validate_die_sibling.
537 dwarf_validate_die_sibling will not give meaningful results
538 if called inappropriately. */
539 Dwarf_Byte_Ptr de_last_di_ptr;
540 Dwarf_Die de_last_die;
541 };
542 typedef struct Dwarf_Debug_InfoTypes_s *Dwarf_Debug_InfoTypes;
543
544 /* As the tasks performed on a debug related section is the same,
545 in order to make the process of adding a new section
546 (very unlikely) a little bit easy and to reduce the
547 possibility of errors, a simple table
548 build dynamically, will contain the relevant information.
549 */
550
551 struct Dwarf_dbg_sect_s {
552 /* Debug section name must not be freed, is quoted string.
553 This is the name from the object file itself. */
554 const char *ds_name;
555 /* The section number in object section numbering. */
556 Dwarf_Unsigned ds_number;
557 /* Debug section information, points to de_debug_*member
558 (or the like) of the dbg struct. */
559 struct Dwarf_Section_s *ds_secdata;
560
561 unsigned ds_groupnumber;
562 int ds_duperr; /* Error code for duplicated section */
563 int ds_emptyerr; /* Error code for empty section */
564 int ds_have_dwarf; /* Section contains DWARF */
565 int ds_have_zdebug; /* Section compressed: .zdebug name */
566 };
567
568 /* As the number of debug sections does not change very often,
569 in the case a
570 new section is added in 'enter_section_in_array()'
571 the 'MAX_DEBUG_SECTIONS' must
572 be updated accordingly.
573 This does not yet allow for section-groups in object files,
574 for which many .debug_info (and other) sections may exist.
575 */
576 #define DWARF_MAX_DEBUG_SECTIONS 50
577 #define DWARFSTRING_ALLOC_SIZE 200
578
579 /* A 'magic number' to validate a Dwarf_Debug pointer is live.*/
580 #define DBG_IS_VALID 0xebfdebfd
581
582 /* All the Dwarf_Debug tied-file info in one place. */
583 struct Dwarf_Tied_Data_s {
584 /* Used to access executable from .dwo or .dwp object.
585 Pointer to the tied_to Dwarf_Debug*/
586 Dwarf_Debug td_tied_object;
587
588 /* Used for Type Unit signatures.
589 Type Units are in .debug_types in DW4
590 but in .debug_info in DW5.
591 Some .debug_info point to them symbolically
592 via DW_AT_signature attributes.
593 If non-zero is a dwarf_tsearch 'tree'.
594 Only non-zero if
595 we had a reason to build the search tree..
596 Type Units have a Dwarf_Sig8 signature
597 in the header, and such is recorded here.
598
599 Type Unit signatures can conflict with
600 signatures in split-dwarf (dwo/dwp) sections.
601
602 The Key for each record is a Dwarf_Sig8 (8 bytes).
603 The data for each is a pointer to a Dwarf_CU_Context
604 record in this dbg (cu_context in
605 one of tied dbg's de_cu_context_list). */
606 void *td_tied_search;
607
608 };
609
610 /* dg_groupnum 0 does not exist.
611 dg_groupnum 1 is base
612 dg_groupnum 2 is dwo
613 dg_groupnum 3 and higher are COMDAT groups (if any).
614
615 We assume the number of groups will not exceed
616 event the Windows 16 bit int maximum.
617 */
618 struct Dwarf_Group_Data_s {
619 /* For traditional DWARF the value is one, just one group. */
620 unsigned gd_number_of_groups;
621
622 /* Raw elf (elf-like) section count. */
623 unsigned gd_number_of_sections;
624
625 unsigned gd_map_entry_count;
626
627 /* A map from section number to group number. */
628 void *gd_map;
629 };
630
631 struct Dwarf_Debug_s {
632 Dwarf_Unsigned de_magic;
633 /* All file access methods and support data
634 are hidden in this structure.
635 We get a pointer, callers control the lifetime of the
636 structure and contents. */
637 struct Dwarf_Obj_Access_Interface_a_s *de_obj_file;
638
639 /* See dwarf_generic_init.c comments on the
640 use of the next four fields. And see
641 DBG_IS_SECONDARY(p) DBG_IS_PRIMARY(p)
642 DBG_HAS_SECONDARY(p) below and also dwarf_util.c */
643 struct Dwarf_Debug_s * de_dbg;
644 struct Dwarf_Debug_s * de_primary_dbg;
645 struct Dwarf_Debug_s * de_secondary_dbg;
646 struct Dwarf_Debug_s * de_errors_dbg;
647
648 Dwarf_Handler de_errhand;
649 Dwarf_Ptr de_errarg;
650
651 /* Enabling us to close an fd if we own it,
652 as in the case of dwarf_init_path().
653 de_fd is only meaningful
654 if de_owns_fd is set. Each object
655 file type has any necessary fd recorded
656 under de_obj_file. */
657 int de_fd;
658 char de_owns_fd;
659 Dwarf_Small de_ftype; /* DW_FTYPE_PE, ... */
660 char de_in_tdestroy; /* for de_alloc_tree DW202309-001 */
661 /* DW_PATHSOURCE_BASIC or MACOS or DEBUGLINK */
662 Dwarf_Small de_path_source;
663 /* de_path is only set automatically if dwarf_init_path()
664 was used to initialize things.
665 Used with the .gnu_debuglink section. */
666 const char *de_path;
667
668 const char ** de_gnu_global_paths;
669 unsigned de_gnu_global_path_count;
670
671 struct Dwarf_Debug_InfoTypes_s de_info_reading;
672 struct Dwarf_Debug_InfoTypes_s de_types_reading;
673
674 /* DW_GROUPNUMBER_ANY, DW_GROUPNUMBER_BASE, DW_GROUPNUMBER_DWO,
675 or a comdat group number > 2
676 Selected at init time of this dbg based on
677 user request and on data in the object. */
678 unsigned de_groupnumber;
679
680 /* Supporting data for groupnumbers. */
681 struct Dwarf_Group_Data_s de_groupnumbers;
682
683 /* Number of bytes in the length, and offset field in various
684 .debu* sections. It's not very meaningful, and is
685 only used in one 'approximate' calculation.
686 de_offset_size would be a more apropos name. */
687 Dwarf_Small de_length_size;
688
689 /* Size of the object file in bytes. If Unknown
690 leave this zero. */
691 Dwarf_Unsigned de_filesize;
692
693 /* The value is what the object file encodes for
694 the machine, In an Elf Header, for example, its value
695 comes from the e_machine field.
696 MACOS provides a cputype field.
697 PE provides IMAGE_FILE_HEADER.Machine.
698 Inspect de_ftype using the value of
699 de_obj_machine or the following de_obj_* fields. */
700 Dwarf_Unsigned de_obj_machine;
701 /* For DW_FTYPE_APPLEUNIVERSAL this is the
702 offset of an executable object in the multi-executable
703 file. For all other de_ftype values this has
704 value zero. */
705 Dwarf_Unsigned de_obj_ub_offset;
706 /* The flags field from an Elf or Macos header
707 or the Charactersics field from a PE header. */
708 Dwarf_Unsigned de_obj_flags;
709
710 /* number of bytes in a pointer of the target in various .debug_
711 sections. 4 in 32bit, 8 in MIPS 64, ia64.
712 This is taken from object file headers. */
713 Dwarf_Small de_pointer_size;
714
715 /* set at creation of a Dwarf_Debug to say if form_string
716 should be checked for valid length at every call.
717 0 means do the check.
718 non-zero means do not do the check. */
719 Dwarf_Small de_assume_string_in_bounds;
720
721 /* Keep track of allocations so a dwarf_finish call can clean up.
722 Null till a tree is created */
723 void * de_alloc_tree;
724
725 /* These fields are used to process debug_frame section.
726 Updated
727 by dwarf_get_fde_list in dwarf_frame.h */
728 /* Points to contiguous block of pointers to
729 Dwarf_Cie_s structs. */
730 Dwarf_Cie *de_cie_data;
731 /* Count of number of Dwarf_Cie_s structs. */
732 Dwarf_Signed de_cie_count;
733 /* Keep eh (GNU) separate!. */
734 Dwarf_Cie *de_cie_data_eh;
735 Dwarf_Signed de_cie_count_eh;
736 /* Points to contiguous block of pointers to
737 Dwarf_Fde_s structs. */
738 Dwarf_Fde *de_fde_data;
739 /* Count of number of Dwarf_Fde_s structs. */
740 Dwarf_Unsigned de_fde_count;
741 /* Keep eh (GNU) separate!. */
742 Dwarf_Fde *de_fde_data_eh;
743 Dwarf_Unsigned de_fde_count_eh;
744
745 struct Dwarf_Section_s de_debug_info;
746 struct Dwarf_Section_s de_debug_types;
747 struct Dwarf_Section_s de_debug_abbrev;
748 struct Dwarf_Section_s de_debug_line;
749 struct Dwarf_Section_s de_debug_line_str; /* New in DWARF5 */
750 struct Dwarf_Section_s de_debug_loc;
751 struct Dwarf_Section_s de_debug_aranges;
752 struct Dwarf_Section_s de_debug_macinfo;
753 struct Dwarf_Section_s de_debug_macro; /* New in DWARF5 */
754 struct Dwarf_Section_s de_debug_names; /* New in DWARF5 */
755 struct Dwarf_Section_s de_debug_pubnames;
756 struct Dwarf_Section_s de_debug_str;
757 struct Dwarf_Section_s de_debug_sup; /* New in DWARF5 */
758 struct Dwarf_Section_s de_debug_loclists; /* New in DWARF5 */
759 struct Dwarf_Section_s de_debug_rnglists; /* New in DWARF5 */
760 struct Dwarf_Section_s de_debug_frame;
761 struct Dwarf_Section_s de_gnu_debuglink; /* New Sept. 2019 */
762 struct Dwarf_Section_s de_note_gnu_buildid; /* New Sept. 2019 */
763
764 /* gnu: the g++ eh_frame section */
765 struct Dwarf_Section_s de_debug_frame_eh_gnu;
766
767 /* DWARF3 .debug_pubtypes */
768 struct Dwarf_Section_s de_debug_pubtypes;
769
770 /* Four SGI IRIX extensions essentially
771 identical to DWARF3 .debug_pubtypes.
772 Only on SGI IRIX. */
773 struct Dwarf_Section_s de_debug_funcnames;
774 struct Dwarf_Section_s de_debug_typenames;
775 struct Dwarf_Section_s de_debug_varnames;
776 struct Dwarf_Section_s de_debug_weaknames;
777
778 struct Dwarf_Section_s de_debug_ranges;
779 /* Following two part of DebugFission and DWARF5 */
780 struct Dwarf_Section_s de_debug_str_offsets;
781 struct Dwarf_Section_s de_debug_addr;
782
783 /* For the .debug_rnglists[.dwo] section */
784 Dwarf_Unsigned de_rnglists_context_count;
785 /* pointer to array of pointers to
786 rnglists context instances */
787 Dwarf_Rnglists_Context * de_rnglists_context;
788
789 /* For the .debug_loclists[.dwo] section */
790 Dwarf_Unsigned de_loclists_context_count;
791 /* pointer to array of pointers to
792 loclists context instances */
793 Dwarf_Loclists_Context * de_loclists_context;
794
795 /* Following for the .gdb_index section. */
796 struct Dwarf_Section_s de_debug_gdbindex;
797
798 /* Types in DWARF5 are in .debug_info
799 and in DWARF4 are in .debug_types.
800 These indexes first standardized in DWARF5,
801 DWARF4 can have them as an extension.
802 The next to refer to the DWP index sections and the
803 tu and cu indexes sections are distinct in DWARF4 & 5. */
804 struct Dwarf_Section_s de_debug_cu_index;
805 struct Dwarf_Section_s de_debug_tu_index;
806 struct Dwarf_Section_s de_debug_gnu_pubnames;
807 struct Dwarf_Section_s de_debug_gnu_pubtypes;
808
809 /* For non-elf, simply leave the following two structs
810 zeroed and they will be ignored. */
811 struct Dwarf_Section_s de_elf_symtab;
812 struct Dwarf_Section_s de_elf_strtab;
813
814 /* For a .dwp object file .
815 For DWARF4, type units are in .debug_types
816 (DWP is a GNU extension in DW4)..
817 For DWARF5, type units are in .debug_info.
818 */
819 Dwarf_Xu_Index_Header de_cu_hashindex_data;
820 Dwarf_Xu_Index_Header de_tu_hashindex_data;
821
822 void (*de_copy_word) (void *dw_targ, const void *dw_src,
823 unsigned long dw_len);
824 unsigned char de_elf_must_close; /* If non-zero, then
825 it was dwarf_init (not dwarf_elf_init)
826 so must elf_end() */
827
828 /* Default is DW_FRAME_INITIAL_VALUE from header. */
829 Dwarf_Unsigned de_frame_rule_initial_value;
830
831 /* Default is DW_FRAME_LAST_REG_NUM. */
832 Dwarf_Unsigned de_frame_reg_rules_entry_count;
833
834 Dwarf_Unsigned de_frame_cfa_col_number;
835 Dwarf_Unsigned de_frame_same_value_number;
836 Dwarf_Unsigned de_frame_undefined_value_number;
837
838 /* If count > 0 means the DW_FTYPE_APPLEUNIVERSAL
839 we initially read has this number of
840 binaries in it, and de_universalbinary_index
841 is the index of the current object inside
842 the universal binary. */
843 unsigned int de_universalbinary_count;
844 unsigned int de_universalbinary_index;
845
846 unsigned char de_big_endian_object; /* Non-zero if
847 object being read is big-endian. */
848
849 /* Non-zero if dwarf_get_globals(), dwarf_get_funcs,
850 dwarf_get_types,dwarf_get_pubtypes,
851 dwarf_get_vars,dwarf_get_weaks should create
852 and return a special zero-die-offset for the
853 corresponding pubnames-style section CU header with
854 zero pubnames-style named DIEs. In that case the
855 list returned will have an entry with a zero for
856 the die-offset (which is an impossible debug_info
857 die_offset). New March 2019.
858 See dwarf_return_empty_pubnames() */
859 unsigned char de_return_empty_pubnames;
860
861 struct Dwarf_dbg_sect_s de_debug_sections[
862 DWARF_MAX_DEBUG_SECTIONS];
863
864 /* Number actually used. */
865 unsigned de_debug_sections_total_entries;
866
867 struct Dwarf_Harmless_s de_harmless_errors;
868
869 struct Dwarf_Printf_Callback_Info_s de_printf_callback;
870 void * de_printf_callback_null_device_handle;
871
872 /* Used in a tied dbg to hold global info
873 on the tied object (DW_AT_dwo_id).
874 And for Type Unit signatures whether tied
875 or not. It is not defined whether
876 the main object is executable and
877 the tied file is a dwo/dwp or the
878 reverse. The focus of reporting
879 is on the main file, but the tied
880 file is sometimes needed
881 and referenced.*/
882 struct Dwarf_Tied_Data_s de_tied_data;
883
884 /* The following two are used to detect a DWARF4
885 .debug_addr (a GNU extension) and attempt
886 to print a raw .debug_addr section. Simply
887 assuming the first CU seen values for these
888 work for everything in the GNU extenstion
889 .debug_addr section. Only needed if the version
890 here is 4 (DWARF4). */
891 Dwarf_Half de_debug_addr_version;
892 Dwarf_Half de_debug_addr_offset_size;
893 Dwarf_Half de_debug_addr_address_size;
894 };
895
896 /* New style. takes advantage of dwarfstrings capability.
897 This not a public function. */
898 void _dwarf_printf(Dwarf_Debug dbg, const char * data);
899
900 typedef struct Dwarf_Chain_s *Dwarf_Chain;
901 struct Dwarf_Chain_s {
902 void *ch_item;
903 int ch_itemtype; /* Needed to dealloc chain contents */
904 Dwarf_Chain ch_next;
905 };
906
907 typedef struct Dwarf_Chain_o *Dwarf_Chain_2;
908 struct Dwarf_Chain_o {
909 Dwarf_Off ch_item;
910 Dwarf_Chain_2 ch_next;
911 };
912
913 /* Size of cu header version stamp field. */
914 #define CU_VERSION_STAMP_SIZE DWARF_HALF_SIZE
915
916 /* Size of cu header address size field. */
917 #define CU_ADDRESS_SIZE_SIZE sizeof(Dwarf_Small)
918
919 #define ORIGINAL_DWARF_OFFSET_SIZE 4
920 /* The DISTINGUISHED VALUE is 4 byte value defined by DWARF
921 since DWARF3. */
922 #define DISTINGUISHED_VALUE 0xffffffff
923 #define DISTINGUISHED_VALUE_OFFSET_SIZE 8
924 #define DISTINGUISHED_VALUE_ARRAY(x) char (x)[4] = \
925 { 0xff,0xff,0xff,0xff }
926
927 /* We don't load the sections until they are needed.
928 This function is used to load the section. */
929 int _dwarf_load_section(Dwarf_Debug,
930 struct Dwarf_Section_s *,
931 Dwarf_Error *);
932
933 void _dwarf_dealloc_rnglists_context(Dwarf_Debug dbg);
934 void _dwarf_dealloc_loclists_context(Dwarf_Debug dbg);
935
936 int _dwarf_get_string_base_attr_value(Dwarf_Debug dbg,
937 Dwarf_CU_Context context,
938 Dwarf_Unsigned *sbase_out,
939 Dwarf_Error *error);
940
941 int _dwarf_look_in_local_and_tied_by_index(
942 Dwarf_Debug dbg,
943 Dwarf_CU_Context context,
944 Dwarf_Unsigned index,
945 Dwarf_Addr *return_addr,
946 Dwarf_Error *error);
947
948 Dwarf_Bool _dwarf_file_has_debug_fission_cu_index(Dwarf_Debug dbg);
949 Dwarf_Bool _dwarf_file_has_debug_fission_tu_index(Dwarf_Debug dbg);
950 Dwarf_Bool _dwarf_file_has_debug_fission_index(Dwarf_Debug dbg);
951
952 /* This should only be called on a CU. Never a TU. */
953 int _dwarf_get_debugfission_for_offset(Dwarf_Debug dbg,
954 Dwarf_Off offset_wanted,
955 const char *keytype, /* "cu" or "tu" */
956 Dwarf_Debug_Fission_Per_CU * percu_out,
957 Dwarf_Error *error);
958
959 /* whichone: must be a valid DW_SECT* macro value. */
960 Dwarf_Unsigned _dwarf_get_dwp_extra_offset(
961 struct Dwarf_Debug_Fission_Per_CU_s* dwp,
962 unsigned whichone, Dwarf_Unsigned * size);
963
964 /* This will look into the tied Dwarf_Debug
965 to which should have a skeleton CU DIE
966 and an addr_base and also have the .debug_addr
967 section. */
968
969 int _dwarf_get_addr_from_tied(Dwarf_Debug dbg,
970 Dwarf_CU_Context context,
971 Dwarf_Unsigned addrindex,
972 Dwarf_Addr *addr_out,
973 Dwarf_Error *error);
974
975 int _dwarf_get_fission_addition_die(Dwarf_Die die, int dw_sect_index,
976 Dwarf_Unsigned* offset, Dwarf_Unsigned*size,
977 Dwarf_Error *error);
978 int _dwarf_get_addr_index_itself(int theform,
979 Dwarf_Small *info_ptr,
980 Dwarf_Debug dbg,
981 Dwarf_CU_Context cu_context,
982 Dwarf_Unsigned *val_out,
983 Dwarf_Error * error);
984 Dwarf_Bool _dwarf_addr_form_is_indexed(int form);
985
986 int _dwarf_load_die_containing_section(Dwarf_Debug dbg,
987 Dwarf_Bool is_info,
988 Dwarf_Error *error);
989
990 int _dwarf_create_a_new_cu_context_record_on_list(
991 Dwarf_Debug dbg,
992 Dwarf_Debug_InfoTypes dis,
993 Dwarf_Bool is_info,
994 Dwarf_Unsigned section_size,
995 Dwarf_Unsigned new_cu_offset,
996 Dwarf_CU_Context *context_out,
997 Dwarf_Die *cu_die_out,
998 Dwarf_Error *error);
999 Dwarf_Unsigned _dwarf_calculate_next_cu_context_offset(
1000 Dwarf_CU_Context cu_context);
1001
1002 int _dwarf_search_for_signature(Dwarf_Debug dbg,
1003 Dwarf_Sig8 sig,
1004 Dwarf_CU_Context *context_out,
1005 Dwarf_Error *error);
1006
1007 int _dwarf_merge_all_base_attrs_of_cu_die(Dwarf_CU_Context context,
1008 Dwarf_Debug tieddbg,
1009 Dwarf_CU_Context *tiedcontext_out,
1010 Dwarf_Error *error);
1011
1012 void _dwarf_tied_destroy_free_node(void *node);
1013 void _dwarf_destroy_group_map(Dwarf_Debug dbg);
1014
1015 int _dwarf_section_get_target_group(Dwarf_Debug dbg,
1016 unsigned obj_section_index,
1017 unsigned * groupnumber,
1018 Dwarf_Error * error);
1019
1020 int _dwarf_dwo_groupnumber_given_name(
1021 const char *name,
1022 unsigned *grpnum_out);
1023
1024 int _dwarf_section_get_target_group_from_map(Dwarf_Debug dbg,
1025 unsigned obj_section_index,
1026 unsigned * groupnumber_out,
1027 Dwarf_Error * error);
1028
1029 int _dwarf_insert_in_group_map(Dwarf_Debug dbg,
1030 unsigned groupnum,
1031 unsigned section_index,
1032 const char *name,
1033 Dwarf_Error * error);
1034
1035 /* returns TRUE/FALSE: meaning this section name is in
1036 map for this groupnum or not.*/
1037 int _dwarf_section_in_group_by_name(Dwarf_Debug dbg,
1038 const char * scn_name,
1039 unsigned groupnum);
1040
1041 int
1042 _dwarf_next_cu_header_internal(Dwarf_Debug dbg,
1043 Dwarf_Bool is_info,
1044 Dwarf_Die * cu_die_out,
1045 Dwarf_Unsigned * cu_header_length,
1046 Dwarf_Half * version_stamp,
1047 Dwarf_Unsigned * abbrev_offset,
1048 Dwarf_Half * address_size,
1049 Dwarf_Half * offset_size,
1050 Dwarf_Half * extension_size,
1051 Dwarf_Sig8 * signature,
1052 Dwarf_Bool * has_signature,
1053 Dwarf_Unsigned *typeoffset,
1054 Dwarf_Unsigned * next_cu_offset,
1055 Dwarf_Half * header_cu_type,
1056 Dwarf_Error * error);
1057
1058 /* Relates to .debug_addr */
1059 int _dwarf_look_in_local_and_tied(Dwarf_Half attr_form,
1060 Dwarf_CU_Context context,
1061 Dwarf_Small *info_ptr,
1062 Dwarf_Addr *return_addr,
1063 Dwarf_Error *error);
1064
1065 int _dwarf_get_ranges_base_attr_from_tied(Dwarf_Debug dbg,
1066 Dwarf_CU_Context context,
1067 Dwarf_Unsigned * ranges_base_out,
1068 Dwarf_Unsigned * addr_base_out,
1069 Dwarf_Error * error);
1070
1071 int _dwarf_get_string_from_tied(Dwarf_Debug dbg,
1072 Dwarf_Unsigned offset,
1073 char **return_str, Dwarf_Error*error);
1074
1075 int _dwarf_valid_form_we_know(Dwarf_Unsigned at_form,
1076 Dwarf_Unsigned at_name);
1077 int _dwarf_extract_local_debug_str_string_given_offset(
1078 Dwarf_Debug dbg,
1079 unsigned attrform,
1080 Dwarf_Unsigned offset,
1081 char ** return_str,
1082 Dwarf_Error * error);
1083
1084 int _dwarf_file_name_is_full_path(Dwarf_Small *fname);
1085
1086 /* This is libelf access to Elf object. */
1087 extern int _dwarf_elf_setup(int fd,
1088 char *true_path_out_buffer,
1089 unsigned ftype,
1090 unsigned endian,
1091 unsigned offsetsize,
1092 size_t filesize,
1093 unsigned groupnumber,
1094 Dwarf_Handler errhand,
1095 Dwarf_Ptr errarg,
1096 Dwarf_Debug *dbg,Dwarf_Error *error);
1097
1098 /* This is non-libelf Elf access */
1099 extern int
1100 _dwarf_elf_nlsetup(int fd,
1101 char *true_path,
1102 unsigned ftype,
1103 unsigned endian,
1104 unsigned offsetsize,
1105 size_t filesize,
1106 unsigned groupnumber,
1107 Dwarf_Handler errhand,
1108 Dwarf_Ptr errarg,
1109 Dwarf_Debug *dbg,Dwarf_Error *error);
1110 void _dwarf_destruct_elf_nlaccess(
1111 struct Dwarf_Obj_Access_Interface_a_s *aip);
1112
1113 extern int _dwarf_macho_setup(int fd,
1114 char *true_path,
1115 unsigned universalnumber,
1116 unsigned ftype,
1117 unsigned endian,
1118 unsigned offsetsize,
1119 Dwarf_Unsigned filesize,
1120 unsigned groupnumber,
1121 Dwarf_Handler errhand,
1122 Dwarf_Ptr errarg,
1123 Dwarf_Debug *dbg,Dwarf_Error *error);
1124 void _dwarf_destruct_macho_access(
1125 struct Dwarf_Obj_Access_Interface_a_s *aip);
1126
1127 extern int _dwarf_pe_setup(int fd,
1128 char *path,
1129 unsigned ftype,
1130 unsigned endian,
1131 unsigned offsetsize,
1132 size_t filesize,
1133 unsigned groupnumber,
1134 Dwarf_Handler errhand,
1135 Dwarf_Ptr errarg,
1136 Dwarf_Debug *dbg,Dwarf_Error *error);
1137 void _dwarf_destruct_pe_access(
1138 struct Dwarf_Obj_Access_Interface_a_s *aip);
1139
1140 void _dwarf_create_address_size_dwarf_error(Dwarf_Debug dbg,
1141 Dwarf_Error *error,
1142 Dwarf_Unsigned addrsize,
1143 int errcode,const char *errname);
1144
1145 extern Dwarf_Bool _dwarf_allow_formudata(unsigned form);
1146 extern int _dwarf_formudata_internal(Dwarf_Debug dbg,
1147 Dwarf_Attribute attr,
1148 unsigned form,
1149 Dwarf_Byte_Ptr data,
1150 Dwarf_Byte_Ptr section_end,
1151 Dwarf_Unsigned *return_uval,
1152 Dwarf_Unsigned *bytes_read,
1153 Dwarf_Error *error);
1154
1155 Dwarf_Byte_Ptr _dwarf_calculate_info_section_start_ptr(
1156 Dwarf_CU_Context context,
1157 Dwarf_Unsigned *section_len_out);
1158
1159 Dwarf_Byte_Ptr _dwarf_calculate_info_section_end_ptr(
1160 Dwarf_CU_Context context);
1161 Dwarf_Byte_Ptr _dwarf_calculate_abbrev_section_end_ptr(
1162 Dwarf_CU_Context context);
1163
1164 void _dwarf_closer(int fd);
1165 int _dwarf_readr(int fd, char *buf, Dwarf_Unsigned size,
1166 Dwarf_Unsigned *sizeread);
1167 int _dwarf_seekr(int fd, Dwarf_Unsigned loc, int seektype,
1168 Dwarf_Unsigned *out_loc);
1169 int _dwarf_openr(const char *name);
1170
1171 int _dwarf_formblock_internal(Dwarf_Debug dbg,
1172 Dwarf_Attribute attr,
1173 Dwarf_CU_Context cu_context,
1174 Dwarf_Block * return_block,
1175 Dwarf_Error * error);
1176
1177 int _dwarf_extract_data16(Dwarf_Debug dbg,
1178 Dwarf_Small *data,
1179 Dwarf_Small *section_start,
1180 Dwarf_Small *section_end,
1181 Dwarf_Form_Data16 * returned_val,
1182 Dwarf_Error *error);
1183
1184 int _dwarf_fill_in_attr_form_abtable(Dwarf_CU_Context context,
1185 Dwarf_Byte_Ptr abbrev_ptr,
1186 Dwarf_Byte_Ptr abbrev_end,
1187 Dwarf_Abbrev_List abbrev_list,
1188 Dwarf_Error *error);
1189
1190 int _dwarf_internal_find_die_given_sig8(Dwarf_Debug dbg,
1191 int context_level,
1192 Dwarf_Sig8 *ref,
1193 Dwarf_Die *die_out,
1194 Dwarf_Bool *is_info,
1195 Dwarf_Error *error);
1196 int
1197 _dwarf_internal_global_formref_b(Dwarf_Attribute attr,
1198 int context_level,
1199 Dwarf_Off * ret_offset,
1200 Dwarf_Bool * offset_is_info,
1201 Dwarf_Error * error);
1202
1203 int
1204 _dwarf_has_SECT_fission(Dwarf_CU_Context ctx,
1205 unsigned int SECT_number, /* example: DW_SECT_RNGLISTS */
1206 Dwarf_Bool *hasfissionoffset,
1207 Dwarf_Unsigned *loclistsbase);
1208
1209 int _dwarf_skip_leb128(char * leb,
1210 Dwarf_Unsigned * leblen,
1211 char * endptr);
1212
1213 /* Used for DW_AT_ranges to get base address along with
1214 dwarf_lowpc() */
1215 int
1216 _dwarf_entrypc(Dwarf_Die die,
1217 Dwarf_Addr *return_addr,
1218 Dwarf_Error *error);
1219
1220 int _dwarf_get_suppress_debuglink_crc(void);
1221 void _dwarf_dumpsig(const char *msg, Dwarf_Sig8 *sig, int lineno);