Add support for debuginfod to the binutils (disable by default, enabled via a configu...
[deliverable/binutils-gdb.git] / binutils / dwarf.h
CommitLineData
1b315056 1/* dwarf.h - DWARF support header file
b3adc24a 2 Copyright (C) 2005-2020 Free Software Foundation, Inc.
19e6b90e 3
32866df7 4 This file is part of GNU Binutils.
19e6b90e 5
32866df7
NC
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.
19e6b90e 10
32866df7
NC
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.
19e6b90e 15
32866df7
NC
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. */
19e6b90e 20
77145576
JK
21#include "dwarf2.h" /* for enum dwarf_unit_type */
22
467c65bc
NC
23typedef unsigned HOST_WIDEST_INT dwarf_vma;
24typedef HOST_WIDEST_INT dwarf_signed_vma;
25typedef unsigned HOST_WIDEST_INT dwarf_size_type;
19e6b90e 26
47704ddf 27/* Structure found in the .debug_line section. */
47704ddf
KT
28typedef struct
29{
467c65bc 30 dwarf_vma li_length;
47704ddf 31 unsigned short li_version;
77ef8654 32 dwarf_vma li_prologue_length;
47704ddf
KT
33 unsigned char li_min_insn_length;
34 unsigned char li_max_ops_per_insn;
35 unsigned char li_default_is_stmt;
36 int li_line_base;
37 unsigned char li_line_range;
38 unsigned char li_opcode_base;
77145576 39 unsigned int li_offset_size;
47704ddf
KT
40}
41DWARF2_Internal_LineInfo;
42
43/* Structure found in .debug_pubnames section. */
47704ddf
KT
44typedef struct
45{
467c65bc 46 dwarf_vma pn_length;
47704ddf 47 unsigned short pn_version;
467c65bc
NC
48 dwarf_vma pn_offset;
49 dwarf_vma pn_size;
47704ddf
KT
50}
51DWARF2_Internal_PubNames;
52
53/* Structure found in .debug_info section. */
47704ddf
KT
54typedef struct
55{
467c65bc 56 dwarf_vma cu_length;
47704ddf 57 unsigned short cu_version;
467c65bc 58 dwarf_vma cu_abbrev_offset;
47704ddf 59 unsigned char cu_pointer_size;
77145576 60 enum dwarf_unit_type cu_unit_type;
47704ddf
KT
61}
62DWARF2_Internal_CompUnit;
63
77ef8654 64/* Structure found in .debug_aranges section. */
47704ddf
KT
65typedef struct
66{
467c65bc 67 dwarf_vma ar_length;
47704ddf 68 unsigned short ar_version;
467c65bc 69 dwarf_vma ar_info_offset;
47704ddf
KT
70 unsigned char ar_pointer_size;
71 unsigned char ar_segment_size;
72}
73DWARF2_Internal_ARange;
74
459d52c8
DE
75/* N.B. The order here must match the order in debug_displays. */
76
c34f4fc6
NC
77enum dwarf_section_display_enum
78{
19e6b90e
L
79 abbrev = 0,
80 aranges,
81 frame,
82 info,
83 line,
84 pubnames,
459d52c8 85 gnu_pubnames,
19e6b90e
L
86 eh_frame,
87 macinfo,
4ccf1e31 88 macro,
19e6b90e 89 str,
77145576 90 line_str,
19e6b90e 91 loc,
d4620bee 92 loclists,
19e6b90e 93 pubtypes,
459d52c8 94 gnu_pubtypes,
19e6b90e 95 ranges,
d4620bee 96 rnglists,
19e6b90e
L
97 static_func,
98 static_vars,
99 types,
100 weaknames,
48049d1e 101 gdb_index,
61364358 102 debug_names,
6f875884
TG
103 trace_info,
104 trace_abbrev,
105 trace_aranges,
4723351a
CC
106 info_dwo,
107 abbrev_dwo,
108 types_dwo,
109 line_dwo,
110 loc_dwo,
111 macro_dwo,
112 macinfo_dwo,
113 str_dwo,
114 str_index,
115 str_index_dwo,
116 debug_addr,
657d0d47
CC
117 dwp_cu_index,
118 dwp_tu_index,
dda8d76d
NC
119 gnu_debuglink,
120 gnu_debugaltlink,
121 separate_debug_str,
19e6b90e
L
122 max
123};
124
4723351a
CC
125struct dwarf_section
126{
127 /* A debug section has a different name when it's stored compressed
128 or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
129 possibilities. NAME is set to whichever one is used for this
130 input file, as determined by load_debug_section(). */
dda8d76d
NC
131 const char * uncompressed_name;
132 const char * compressed_name;
133 const char * name;
134 /* If non-NULL then FILENAME is the name of the separate debug info
135 file containing the section. */
136 const char * filename;
137 unsigned char * start;
138 dwarf_vma address;
139 dwarf_size_type size;
140 enum dwarf_section_display_enum abbrev_sec;
d1c4b12b 141 /* Used by clients to help them implement the reloc_at callback. */
dda8d76d
NC
142 void * reloc_info;
143 unsigned long num_relocs;
06614111 144 /* A spare field for random use. */
dda8d76d 145 void * user_data;
4723351a
CC
146};
147
148/* A structure containing the name of a debug section
149 and a pointer to a function that can decode it. */
150struct dwarf_section_display
151{
dda8d76d
NC
152 struct dwarf_section section;
153 int (* display) (struct dwarf_section *, void *);
154 int * enabled;
155 bfd_boolean relocate;
4723351a
CC
156};
157
19e6b90e
L
158extern struct dwarf_section_display debug_displays [];
159
160/* This structure records the information that
161 we extract from the.debug_info section. */
162typedef struct
163{
164 unsigned int pointer_size;
b7807392
JJ
165 unsigned int offset_size;
166 int dwarf_version;
467c65bc
NC
167 dwarf_vma cu_offset;
168 dwarf_vma base_address;
4723351a
CC
169 /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
170 is used with the form DW_AT_GNU_FORM_addr_index. */
171 dwarf_vma addr_base;
172 /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
173 is used when calculating ranges. */
174 dwarf_vma ranges_base;
19e6b90e 175 /* This is an array of offsets to the location list table. */
467c65bc 176 dwarf_vma * loc_offsets;
9f272209
AO
177 /* This is an array of offsets to the location view table. */
178 dwarf_vma * loc_views;
467c65bc 179 int * have_frame_base;
19e6b90e
L
180 unsigned int num_loc_offsets;
181 unsigned int max_loc_offsets;
9f272209 182 unsigned int num_loc_views;
01a8f077 183 /* List of .debug_ranges offsets seen in this .debug_info. */
467c65bc 184 dwarf_vma * range_lists;
19e6b90e
L
185 unsigned int num_range_lists;
186 unsigned int max_range_lists;
187}
188debug_info;
189
24841daa
NC
190typedef struct separate_info
191{
192 void * handle; /* The pointer returned by open_debug_file(). */
193 const char * filename;
194 struct separate_info * next;
195} separate_info;
196
197extern separate_info * first_separate_info;
198
77ef8654 199extern unsigned int eh_addr_size;
19e6b90e
L
200
201extern int do_debug_info;
202extern int do_debug_abbrevs;
203extern int do_debug_lines;
204extern int do_debug_pubnames;
f9f0e732 205extern int do_debug_pubtypes;
19e6b90e
L
206extern int do_debug_aranges;
207extern int do_debug_ranges;
208extern int do_debug_frames;
209extern int do_debug_frames_interp;
210extern int do_debug_macinfo;
211extern int do_debug_str;
212extern int do_debug_loc;
5bbdf3d5 213extern int do_gdb_index;
6f875884
TG
214extern int do_trace_info;
215extern int do_trace_abbrevs;
216extern int do_trace_aranges;
657d0d47
CC
217extern int do_debug_addr;
218extern int do_debug_cu_index;
c34f4fc6 219extern int do_wide;
dda8d76d 220extern int do_debug_links;
39f0547e 221extern int do_follow_links;
19e6b90e 222
fd2f0033
TT
223extern int dwarf_cutoff_level;
224extern unsigned long dwarf_start_die;
225
4723351a
CC
226extern int dwarf_check;
227
955ff7fc 228extern void init_dwarf_regnames_by_elf_machine_code (unsigned int);
229a22cf
AB
229extern void init_dwarf_regnames_by_bfd_arch_and_mach (enum bfd_architecture arch,
230 unsigned long mach);
2dc4cec1 231
dda8d76d
NC
232extern bfd_boolean load_debug_section (enum dwarf_section_display_enum, void *);
233extern void free_debug_section (enum dwarf_section_display_enum);
24841daa 234extern bfd_boolean load_separate_debug_files (void *, const char *);
dda8d76d
NC
235extern void close_debug_file (void *);
236extern void * open_debug_file (const char *);
19e6b90e
L
237
238extern void free_debug_memory (void);
239
c34f4fc6
NC
240extern void dwarf_select_sections_by_names (const char *);
241extern void dwarf_select_sections_by_letters (const char *);
4cb93e3b
TG
242extern void dwarf_select_sections_all (void);
243
82b1b41b 244extern unsigned int * find_cu_tu_set (void *, unsigned int);
657d0d47 245
82b1b41b 246extern void * cmalloc (size_t, size_t);
72c61a0d 247extern void * xcalloc2 (size_t, size_t);
82b1b41b
NC
248extern void * xcmalloc (size_t, size_t);
249extern void * xcrealloc (void *, size_t, size_t);
19e6b90e 250
222c2bf0 251/* A callback into the client. Returns TRUE if there is a
d1c4b12b
NC
252 relocation against the given debug section at the given
253 offset. */
254extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma);
cd30bcef
AM
255
256extern dwarf_vma read_leb128 (unsigned char *, const unsigned char *const,
257 bfd_boolean, unsigned int *, int *);
258
301a9420
AM
259#if HAVE_LIBDEBUGINFOD
260extern unsigned char * get_build_id (void *);
261#endif
262
cd30bcef
AM
263static inline void
264report_leb_status (int status)
265{
266 if ((status & 1) != 0)
267 error (_("LEB end of data\n"));
268 else if ((status & 2) != 0)
269 error (_("LEB value too large\n"));
270}
271
272#define SKIP_ULEB(start, end) \
273 do \
274 { \
275 unsigned int _len; \
276 read_leb128 (start, end, FALSE, &_len, NULL); \
277 start += _len; \
278 } while (0)
279
280#define SKIP_SLEB(start, end) \
281 do \
282 { \
283 unsigned int _len; \
284 read_leb128 (start, end, TRUE, &_len, NULL); \
285 start += _len; \
286 } while (0)
287
288#define READ_ULEB(var, start, end) \
289 do \
290 { \
291 dwarf_vma _val; \
292 unsigned int _len; \
293 int _status; \
294 \
295 _val = read_leb128 (start, end, FALSE, &_len, &_status); \
296 start += _len; \
297 (var) = _val; \
298 if ((var) != _val) \
299 _status |= 2; \
300 report_leb_status (_status); \
301 } while (0)
302
303#define READ_SLEB(var, start, end) \
304 do \
305 { \
306 dwarf_signed_vma _val; \
307 unsigned int _len; \
308 int _status; \
309 \
310 _val = read_leb128 (start, end, TRUE, &_len, &_status); \
311 start += _len; \
312 (var) = _val; \
313 if ((var) != _val) \
314 _status |= 2; \
315 report_leb_status (_status); \
316 } while (0)
This page took 0.565271 seconds and 4 git commands to generate.