Commit | Line | Data |
---|---|---|
1b315056 | 1 | /* dwarf.h - DWARF support header file |
2571583a | 2 | Copyright (C) 2005-2017 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 |
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; | |
19e6b90e | 26 | |
47704ddf | 27 | /* Structure found in the .debug_line section. */ |
47704ddf KT |
28 | typedef 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 | } |
41 | DWARF2_Internal_LineInfo; | |
42 | ||
43 | /* Structure found in .debug_pubnames section. */ | |
47704ddf KT |
44 | typedef 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 | } |
51 | DWARF2_Internal_PubNames; | |
52 | ||
53 | /* Structure found in .debug_info section. */ | |
47704ddf KT |
54 | typedef 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 | } |
62 | DWARF2_Internal_CompUnit; | |
63 | ||
77ef8654 | 64 | /* Structure found in .debug_aranges section. */ |
47704ddf KT |
65 | typedef 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 | } | |
73 | DWARF2_Internal_ARange; | |
74 | ||
459d52c8 DE |
75 | /* N.B. The order here must match the order in debug_displays. */ |
76 | ||
c34f4fc6 NC |
77 | enum 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 L |
91 | loc, |
92 | pubtypes, | |
459d52c8 | 93 | gnu_pubtypes, |
19e6b90e L |
94 | ranges, |
95 | static_func, | |
96 | static_vars, | |
97 | types, | |
98 | weaknames, | |
48049d1e | 99 | gdb_index, |
6f875884 TG |
100 | trace_info, |
101 | trace_abbrev, | |
102 | trace_aranges, | |
4723351a CC |
103 | info_dwo, |
104 | abbrev_dwo, | |
105 | types_dwo, | |
106 | line_dwo, | |
107 | loc_dwo, | |
108 | macro_dwo, | |
109 | macinfo_dwo, | |
110 | str_dwo, | |
111 | str_index, | |
112 | str_index_dwo, | |
113 | debug_addr, | |
657d0d47 CC |
114 | dwp_cu_index, |
115 | dwp_tu_index, | |
19e6b90e L |
116 | max |
117 | }; | |
118 | ||
4723351a CC |
119 | struct dwarf_section |
120 | { | |
121 | /* A debug section has a different name when it's stored compressed | |
122 | or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two | |
123 | possibilities. NAME is set to whichever one is used for this | |
124 | input file, as determined by load_debug_section(). */ | |
125 | const char *uncompressed_name; | |
126 | const char *compressed_name; | |
127 | const char *name; | |
128 | unsigned char *start; | |
129 | dwarf_vma address; | |
130 | dwarf_size_type size; | |
131 | enum dwarf_section_display_enum abbrev_sec; | |
d1c4b12b NC |
132 | |
133 | /* Used by clients to help them implement the reloc_at callback. */ | |
134 | void * reloc_info; | |
135 | unsigned long num_relocs; | |
136 | ||
06614111 NC |
137 | /* A spare field for random use. */ |
138 | void *user_data; | |
4723351a CC |
139 | }; |
140 | ||
141 | /* A structure containing the name of a debug section | |
142 | and a pointer to a function that can decode it. */ | |
143 | struct dwarf_section_display | |
144 | { | |
145 | struct dwarf_section section; | |
146 | int (*display) (struct dwarf_section *, void *); | |
147 | int *enabled; | |
d1c4b12b | 148 | bfd_boolean relocate; |
4723351a CC |
149 | }; |
150 | ||
19e6b90e L |
151 | extern struct dwarf_section_display debug_displays []; |
152 | ||
153 | /* This structure records the information that | |
154 | we extract from the.debug_info section. */ | |
155 | typedef struct | |
156 | { | |
157 | unsigned int pointer_size; | |
b7807392 JJ |
158 | unsigned int offset_size; |
159 | int dwarf_version; | |
467c65bc NC |
160 | dwarf_vma cu_offset; |
161 | dwarf_vma base_address; | |
4723351a CC |
162 | /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and |
163 | is used with the form DW_AT_GNU_FORM_addr_index. */ | |
164 | dwarf_vma addr_base; | |
165 | /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and | |
166 | is used when calculating ranges. */ | |
167 | dwarf_vma ranges_base; | |
19e6b90e | 168 | /* This is an array of offsets to the location list table. */ |
467c65bc NC |
169 | dwarf_vma * loc_offsets; |
170 | int * have_frame_base; | |
19e6b90e L |
171 | unsigned int num_loc_offsets; |
172 | unsigned int max_loc_offsets; | |
01a8f077 | 173 | /* List of .debug_ranges offsets seen in this .debug_info. */ |
467c65bc | 174 | dwarf_vma * range_lists; |
19e6b90e L |
175 | unsigned int num_range_lists; |
176 | unsigned int max_range_lists; | |
177 | } | |
178 | debug_info; | |
179 | ||
77ef8654 | 180 | extern unsigned int eh_addr_size; |
19e6b90e L |
181 | |
182 | extern int do_debug_info; | |
183 | extern int do_debug_abbrevs; | |
184 | extern int do_debug_lines; | |
185 | extern int do_debug_pubnames; | |
f9f0e732 | 186 | extern int do_debug_pubtypes; |
19e6b90e L |
187 | extern int do_debug_aranges; |
188 | extern int do_debug_ranges; | |
189 | extern int do_debug_frames; | |
190 | extern int do_debug_frames_interp; | |
191 | extern int do_debug_macinfo; | |
192 | extern int do_debug_str; | |
193 | extern int do_debug_loc; | |
5bbdf3d5 | 194 | extern int do_gdb_index; |
6f875884 TG |
195 | extern int do_trace_info; |
196 | extern int do_trace_abbrevs; | |
197 | extern int do_trace_aranges; | |
657d0d47 CC |
198 | extern int do_debug_addr; |
199 | extern int do_debug_cu_index; | |
c34f4fc6 | 200 | extern int do_wide; |
19e6b90e | 201 | |
fd2f0033 TT |
202 | extern int dwarf_cutoff_level; |
203 | extern unsigned long dwarf_start_die; | |
204 | ||
4723351a CC |
205 | extern int dwarf_check; |
206 | ||
2dc4cec1 | 207 | extern void init_dwarf_regnames (unsigned int); |
b129eb0e | 208 | extern void init_dwarf_regnames_i386 (void); |
3d875af5 | 209 | extern void init_dwarf_regnames_iamcu (void); |
b129eb0e | 210 | extern void init_dwarf_regnames_x86_64 (void); |
4ee22035 | 211 | extern void init_dwarf_regnames_aarch64 (void); |
d6bb17b0 | 212 | extern void init_dwarf_regnames_s390 (void); |
2dc4cec1 | 213 | |
467c65bc | 214 | extern int load_debug_section (enum dwarf_section_display_enum, void *); |
19e6b90e L |
215 | extern void free_debug_section (enum dwarf_section_display_enum); |
216 | ||
217 | extern void free_debug_memory (void); | |
218 | ||
c34f4fc6 NC |
219 | extern void dwarf_select_sections_by_names (const char *); |
220 | extern void dwarf_select_sections_by_letters (const char *); | |
4cb93e3b TG |
221 | extern void dwarf_select_sections_all (void); |
222 | ||
82b1b41b | 223 | extern unsigned int * find_cu_tu_set (void *, unsigned int); |
657d0d47 | 224 | |
82b1b41b | 225 | extern void * cmalloc (size_t, size_t); |
72c61a0d | 226 | extern void * xcalloc2 (size_t, size_t); |
82b1b41b NC |
227 | extern void * xcmalloc (size_t, size_t); |
228 | extern void * xcrealloc (void *, size_t, size_t); | |
19e6b90e | 229 | |
f6f0e17b | 230 | extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const); |
d1c4b12b | 231 | |
222c2bf0 | 232 | /* A callback into the client. Returns TRUE if there is a |
d1c4b12b NC |
233 | relocation against the given debug section at the given |
234 | offset. */ | |
235 | extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma); |