1 /* dwarf.h - DWARF support header file
2 Copyright (C) 2005-2021 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 unsigned char li_address_size
;
33 unsigned char li_segment_size
;
34 dwarf_vma li_prologue_length
;
35 unsigned char li_min_insn_length
;
36 unsigned char li_max_ops_per_insn
;
37 unsigned char li_default_is_stmt
;
39 unsigned char li_line_range
;
40 unsigned char li_opcode_base
;
41 unsigned int li_offset_size
;
43 DWARF2_Internal_LineInfo
;
45 /* Structure found in .debug_pubnames section. */
49 unsigned short pn_version
;
53 DWARF2_Internal_PubNames
;
55 /* Structure found in .debug_info section. */
59 unsigned short cu_version
;
60 dwarf_vma cu_abbrev_offset
;
61 unsigned char cu_pointer_size
;
62 enum dwarf_unit_type cu_unit_type
;
64 DWARF2_Internal_CompUnit
;
66 /* Structure found in .debug_aranges section. */
70 unsigned short ar_version
;
71 dwarf_vma ar_info_offset
;
72 unsigned char ar_pointer_size
;
73 unsigned char ar_segment_size
;
75 DWARF2_Internal_ARange
;
77 /* N.B. The order here must match the order in debug_displays. */
79 enum dwarf_section_display_enum
129 /* A debug section has a different name when it's stored compressed
130 or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
131 possibilities. NAME is set to whichever one is used for this
132 input file, as determined by load_debug_section(). */
133 const char * uncompressed_name
;
134 const char * compressed_name
;
136 /* If non-NULL then FILENAME is the name of the separate debug info
137 file containing the section. */
138 const char * filename
;
139 unsigned char * start
;
141 dwarf_size_type size
;
142 enum dwarf_section_display_enum abbrev_sec
;
143 /* Used by clients to help them implement the reloc_at callback. */
145 unsigned long num_relocs
;
146 /* A spare field for random use. */
150 /* A structure containing the name of a debug section
151 and a pointer to a function that can decode it. */
152 struct dwarf_section_display
154 struct dwarf_section section
;
155 int (* display
) (struct dwarf_section
*, void *);
157 bfd_boolean relocate
;
160 extern struct dwarf_section_display debug_displays
[];
162 /* This structure records the information that
163 we extract from the.debug_info section. */
166 unsigned int pointer_size
;
167 unsigned int offset_size
;
170 dwarf_vma base_address
;
171 /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
172 is used with the form DW_AT_GNU_FORM_addr_index. */
174 /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
175 is used when calculating ranges. */
176 dwarf_vma ranges_base
;
177 /* This is an array of offsets to the location list table. */
178 dwarf_vma
* loc_offsets
;
179 /* This is an array of offsets to the location view table. */
180 dwarf_vma
* loc_views
;
181 int * have_frame_base
;
182 unsigned int num_loc_offsets
;
183 unsigned int max_loc_offsets
;
184 unsigned int num_loc_views
;
185 /* List of .debug_ranges offsets seen in this .debug_info. */
186 dwarf_vma
* range_lists
;
187 unsigned int num_range_lists
;
188 unsigned int max_range_lists
;
192 typedef struct separate_info
194 void * handle
; /* The pointer returned by open_debug_file(). */
195 const char * filename
;
196 struct separate_info
* next
;
199 extern separate_info
* first_separate_info
;
201 extern unsigned int eh_addr_size
;
203 extern int do_debug_info
;
204 extern int do_debug_abbrevs
;
205 extern int do_debug_lines
;
206 extern int do_debug_pubnames
;
207 extern int do_debug_pubtypes
;
208 extern int do_debug_aranges
;
209 extern int do_debug_ranges
;
210 extern int do_debug_frames
;
211 extern int do_debug_frames_interp
;
212 extern int do_debug_macinfo
;
213 extern int do_debug_str
;
214 extern int do_debug_str_offsets
;
215 extern int do_debug_loc
;
216 extern int do_gdb_index
;
217 extern int do_trace_info
;
218 extern int do_trace_abbrevs
;
219 extern int do_trace_aranges
;
220 extern int do_debug_addr
;
221 extern int do_debug_cu_index
;
223 extern int do_debug_links
;
224 extern int do_follow_links
;
225 extern bfd_boolean do_checks
;
227 extern int dwarf_cutoff_level
;
228 extern unsigned long dwarf_start_die
;
230 extern int dwarf_check
;
232 extern void init_dwarf_regnames_by_elf_machine_code (unsigned int);
233 extern void init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch
,
236 extern bfd_boolean
load_debug_section (enum dwarf_section_display_enum
, void *);
237 extern void free_debug_section (enum dwarf_section_display_enum
);
238 extern bfd_boolean
load_separate_debug_files (void *, const char *);
239 extern void close_debug_file (void *);
240 extern void * open_debug_file (const char *);
242 extern void free_debug_memory (void);
244 extern void dwarf_select_sections_by_names (const char *);
245 extern void dwarf_select_sections_by_letters (const char *);
246 extern void dwarf_select_sections_all (void);
248 extern unsigned int * find_cu_tu_set (void *, unsigned int);
250 extern void * cmalloc (size_t, size_t);
251 extern void * xcalloc2 (size_t, size_t);
252 extern void * xcmalloc (size_t, size_t);
253 extern void * xcrealloc (void *, size_t, size_t);
255 /* A callback into the client. Returns TRUE if there is a
256 relocation against the given debug section at the given
258 extern bfd_boolean
reloc_at (struct dwarf_section
*, dwarf_vma
);
260 extern dwarf_vma
read_leb128 (unsigned char *, const unsigned char *const,
261 bfd_boolean
, unsigned int *, int *);
263 #if HAVE_LIBDEBUGINFOD
264 extern unsigned char * get_build_id (void *);
268 report_leb_status (int status
, const char *file
, unsigned long lnum
)
270 if ((status
& 1) != 0)
271 error (_("%s:%lu: end of data encountered whilst reading LEB\n"), file
, lnum
);
272 else if ((status
& 2) != 0)
273 error (_("%s:%lu: read LEB value is too large to store in destination variable\n"), file
, lnum
);
276 #define SKIP_ULEB(start, end) \
280 read_leb128 (start, end, FALSE, &_len, NULL); \
285 #define SKIP_SLEB(start, end) \
289 read_leb128 (start, end, TRUE, &_len, NULL); \
294 #define READ_ULEB(var, start, end) \
301 _val = read_leb128 (start, end, FALSE, &_len, &_status); \
306 report_leb_status (_status, __FILE__, __LINE__); \
310 #define READ_SLEB(var, start, end) \
313 dwarf_signed_vma _val; \
317 _val = read_leb128 (start, end, TRUE, &_len, &_status); \
322 report_leb_status (_status, __FILE__, __LINE__); \