1 /* dwarf.h - DWARF support header file
2 Copyright (C) 2005-2017 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 #include "dwarf2.h" /* for enum dwarf_unit_type */
23 typedef unsigned HOST_WIDEST_INT dwarf_vma;
24 typedef HOST_WIDEST_INT dwarf_signed_vma;
25 typedef unsigned HOST_WIDEST_INT dwarf_size_type;
27 /* Structure found in the .debug_line section. */
31 unsigned short li_version;
32 dwarf_vma li_prologue_length;
33 unsigned char li_min_insn_length;
34 unsigned char li_max_ops_per_insn;
35 unsigned char li_default_is_stmt;
37 unsigned char li_line_range;
38 unsigned char li_opcode_base;
39 unsigned int li_offset_size;
41 DWARF2_Internal_LineInfo;
43 /* Structure found in .debug_pubnames section. */
47 unsigned short pn_version;
51 DWARF2_Internal_PubNames;
53 /* Structure found in .debug_info section. */
57 unsigned short cu_version;
58 dwarf_vma cu_abbrev_offset;
59 unsigned char cu_pointer_size;
60 enum dwarf_unit_type cu_unit_type;
62 DWARF2_Internal_CompUnit;
64 /* Structure found in .debug_aranges section. */
68 unsigned short ar_version;
69 dwarf_vma ar_info_offset;
70 unsigned char ar_pointer_size;
71 unsigned char ar_segment_size;
73 DWARF2_Internal_ARange;
75 /* N.B. The order here must match the order in debug_displays. */
77 enum dwarf_section_display_enum
124 /* A debug section has a different name when it's stored compressed
125 or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
126 possibilities. NAME is set to whichever one is used for this
127 input file, as determined by load_debug_section(). */
128 const char *uncompressed_name;
129 const char *compressed_name;
131 unsigned char *start;
133 dwarf_size_type size;
134 enum dwarf_section_display_enum abbrev_sec;
136 /* Used by clients to help them implement the reloc_at callback. */
138 unsigned long num_relocs;
140 /* A spare field for random use. */
144 /* A structure containing the name of a debug section
145 and a pointer to a function that can decode it. */
146 struct dwarf_section_display
148 struct dwarf_section section;
149 int (*display) (struct dwarf_section *, void *);
151 bfd_boolean relocate;
154 extern struct dwarf_section_display debug_displays [];
156 /* This structure records the information that
157 we extract from the.debug_info section. */
160 unsigned int pointer_size;
161 unsigned int offset_size;
164 dwarf_vma base_address;
165 /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
166 is used with the form DW_AT_GNU_FORM_addr_index. */
168 /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
169 is used when calculating ranges. */
170 dwarf_vma ranges_base;
171 /* This is an array of offsets to the location list table. */
172 dwarf_vma * loc_offsets;
173 /* This is an array of offsets to the location view table. */
174 dwarf_vma * loc_views;
175 int * have_frame_base;
176 unsigned int num_loc_offsets;
177 unsigned int max_loc_offsets;
178 unsigned int num_loc_views;
179 /* List of .debug_ranges offsets seen in this .debug_info. */
180 dwarf_vma * range_lists;
181 unsigned int num_range_lists;
182 unsigned int max_range_lists;
186 extern unsigned int eh_addr_size;
188 extern int do_debug_info;
189 extern int do_debug_abbrevs;
190 extern int do_debug_lines;
191 extern int do_debug_pubnames;
192 extern int do_debug_pubtypes;
193 extern int do_debug_aranges;
194 extern int do_debug_ranges;
195 extern int do_debug_frames;
196 extern int do_debug_frames_interp;
197 extern int do_debug_macinfo;
198 extern int do_debug_str;
199 extern int do_debug_loc;
200 extern int do_gdb_index;
201 extern int do_trace_info;
202 extern int do_trace_abbrevs;
203 extern int do_trace_aranges;
204 extern int do_debug_addr;
205 extern int do_debug_cu_index;
208 extern int dwarf_cutoff_level;
209 extern unsigned long dwarf_start_die;
211 extern int dwarf_check;
213 extern void init_dwarf_regnames (unsigned int);
214 extern void init_dwarf_regnames_i386 (void);
215 extern void init_dwarf_regnames_iamcu (void);
216 extern void init_dwarf_regnames_x86_64 (void);
217 extern void init_dwarf_regnames_aarch64 (void);
218 extern void init_dwarf_regnames_s390 (void);
220 extern int load_debug_section (enum dwarf_section_display_enum, void *);
221 extern void free_debug_section (enum dwarf_section_display_enum);
223 extern void free_debug_memory (void);
225 extern void dwarf_select_sections_by_names (const char *);
226 extern void dwarf_select_sections_by_letters (const char *);
227 extern void dwarf_select_sections_all (void);
229 extern unsigned int * find_cu_tu_set (void *, unsigned int);
231 extern void * cmalloc (size_t, size_t);
232 extern void * xcalloc2 (size_t, size_t);
233 extern void * xcmalloc (size_t, size_t);
234 extern void * xcrealloc (void *, size_t, size_t);
236 extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const);
238 /* A callback into the client. Returns TRUE if there is a
239 relocation against the given debug section at the given
241 extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma);