1 /* dwarf.h - DWARF support header file
2 Copyright (C) 2005-2015 Free Software Foundation, Inc.
4 This file is part of 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 typedef unsigned HOST_WIDEST_INT dwarf_vma;
22 typedef HOST_WIDEST_INT dwarf_signed_vma;
23 typedef unsigned HOST_WIDEST_INT dwarf_size_type;
25 /* Structure found in the .debug_line section. */
28 unsigned char li_length [4];
29 unsigned char li_version [2];
30 unsigned char li_prologue_length [4];
31 unsigned char li_min_insn_length [1];
32 unsigned char li_default_is_stmt [1];
33 unsigned char li_line_base [1];
34 unsigned char li_line_range [1];
35 unsigned char li_opcode_base [1];
37 DWARF2_External_LineInfo;
42 unsigned short li_version;
43 unsigned int li_prologue_length;
44 unsigned char li_min_insn_length;
45 unsigned char li_max_ops_per_insn;
46 unsigned char li_default_is_stmt;
48 unsigned char li_line_range;
49 unsigned char li_opcode_base;
51 DWARF2_Internal_LineInfo;
53 /* Structure found in .debug_pubnames section. */
56 unsigned char pn_length [4];
57 unsigned char pn_version [2];
58 unsigned char pn_offset [4];
59 unsigned char pn_size [4];
61 DWARF2_External_PubNames;
66 unsigned short pn_version;
70 DWARF2_Internal_PubNames;
72 /* Structure found in .debug_info section. */
75 unsigned char cu_length [4];
76 unsigned char cu_version [2];
77 unsigned char cu_abbrev_offset [4];
78 unsigned char cu_pointer_size [1];
80 DWARF2_External_CompUnit;
85 unsigned short cu_version;
86 dwarf_vma cu_abbrev_offset;
87 unsigned char cu_pointer_size;
89 DWARF2_Internal_CompUnit;
93 unsigned char ar_length [4];
94 unsigned char ar_version [2];
95 unsigned char ar_info_offset [4];
96 unsigned char ar_pointer_size [1];
97 unsigned char ar_segment_size [1];
99 DWARF2_External_ARange;
104 unsigned short ar_version;
105 dwarf_vma ar_info_offset;
106 unsigned char ar_pointer_size;
107 unsigned char ar_segment_size;
109 DWARF2_Internal_ARange;
111 /* N.B. The order here must match the order in debug_displays. */
113 enum dwarf_section_display_enum
156 /* A debug section has a different name when it's stored compressed
157 or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
158 possibilities. NAME is set to whichever one is used for this
159 input file, as determined by load_debug_section(). */
160 const char *uncompressed_name;
161 const char *compressed_name;
163 unsigned char *start;
165 dwarf_size_type size;
166 enum dwarf_section_display_enum abbrev_sec;
167 /* A spare field for random use. */
171 /* A structure containing the name of a debug section
172 and a pointer to a function that can decode it. */
173 struct dwarf_section_display
175 struct dwarf_section section;
176 int (*display) (struct dwarf_section *, void *);
178 unsigned int relocate : 1;
181 extern struct dwarf_section_display debug_displays [];
183 /* This structure records the information that
184 we extract from the.debug_info section. */
187 unsigned int pointer_size;
188 unsigned int offset_size;
191 dwarf_vma base_address;
192 /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
193 is used with the form DW_AT_GNU_FORM_addr_index. */
195 /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
196 is used when calculating ranges. */
197 dwarf_vma ranges_base;
198 /* This is an array of offsets to the location list table. */
199 dwarf_vma * loc_offsets;
200 int * have_frame_base;
201 unsigned int num_loc_offsets;
202 unsigned int max_loc_offsets;
203 /* List of .debug_ranges offsets seen in this .debug_info. */
204 dwarf_vma * range_lists;
205 unsigned int num_range_lists;
206 unsigned int max_range_lists;
210 extern int eh_addr_size;
212 extern int do_debug_info;
213 extern int do_debug_abbrevs;
214 extern int do_debug_lines;
215 extern int do_debug_pubnames;
216 extern int do_debug_pubtypes;
217 extern int do_debug_aranges;
218 extern int do_debug_ranges;
219 extern int do_debug_frames;
220 extern int do_debug_frames_interp;
221 extern int do_debug_macinfo;
222 extern int do_debug_str;
223 extern int do_debug_loc;
224 extern int do_gdb_index;
225 extern int do_trace_info;
226 extern int do_trace_abbrevs;
227 extern int do_trace_aranges;
228 extern int do_debug_addr;
229 extern int do_debug_cu_index;
232 extern int dwarf_cutoff_level;
233 extern unsigned long dwarf_start_die;
235 extern int dwarf_check;
237 extern void init_dwarf_regnames (unsigned int);
238 extern void init_dwarf_regnames_i386 (void);
239 extern void init_dwarf_regnames_x86_64 (void);
240 extern void init_dwarf_regnames_aarch64 (void);
242 extern int load_debug_section (enum dwarf_section_display_enum, void *);
243 extern void free_debug_section (enum dwarf_section_display_enum);
245 extern void free_debug_memory (void);
247 extern void dwarf_select_sections_by_names (const char *);
248 extern void dwarf_select_sections_by_letters (const char *);
249 extern void dwarf_select_sections_all (void);
251 extern unsigned int * find_cu_tu_set (void *, unsigned int);
253 extern void * cmalloc (size_t, size_t);
254 extern void * xcmalloc (size_t, size_t);
255 extern void * xcrealloc (void *, size_t, size_t);
257 extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const);