dwarf.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. /* dwarf.h - DWARF support header file
  2. Copyright (C) 2005-2017 Free Software Foundation, Inc.
  3. This file is part of GNU Binutils.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  15. MA 02110-1301, USA. */
  16. #include "dwarf2.h" /* for enum dwarf_unit_type */
  17. typedef unsigned HOST_WIDEST_INT dwarf_vma;
  18. typedef HOST_WIDEST_INT dwarf_signed_vma;
  19. typedef unsigned HOST_WIDEST_INT dwarf_size_type;
  20. /* Structure found in the .debug_line section. */
  21. typedef struct
  22. {
  23. dwarf_vma li_length;
  24. unsigned short li_version;
  25. dwarf_vma li_prologue_length;
  26. unsigned char li_min_insn_length;
  27. unsigned char li_max_ops_per_insn;
  28. unsigned char li_default_is_stmt;
  29. int li_line_base;
  30. unsigned char li_line_range;
  31. unsigned char li_opcode_base;
  32. unsigned int li_offset_size;
  33. }
  34. DWARF2_Internal_LineInfo;
  35. /* Structure found in .debug_pubnames section. */
  36. typedef struct
  37. {
  38. dwarf_vma pn_length;
  39. unsigned short pn_version;
  40. dwarf_vma pn_offset;
  41. dwarf_vma pn_size;
  42. }
  43. DWARF2_Internal_PubNames;
  44. /* Structure found in .debug_info section. */
  45. typedef struct
  46. {
  47. dwarf_vma cu_length;
  48. unsigned short cu_version;
  49. dwarf_vma cu_abbrev_offset;
  50. unsigned char cu_pointer_size;
  51. enum dwarf_unit_type cu_unit_type;
  52. }
  53. DWARF2_Internal_CompUnit;
  54. /* Structure found in .debug_aranges section. */
  55. typedef struct
  56. {
  57. dwarf_vma ar_length;
  58. unsigned short ar_version;
  59. dwarf_vma ar_info_offset;
  60. unsigned char ar_pointer_size;
  61. unsigned char ar_segment_size;
  62. }
  63. DWARF2_Internal_ARange;
  64. /* N.B. The order here must match the order in debug_displays. */
  65. enum dwarf_section_display_enum
  66. {
  67. abbrev = 0,
  68. aranges,
  69. frame,
  70. info,
  71. line,
  72. pubnames,
  73. gnu_pubnames,
  74. eh_frame,
  75. macinfo,
  76. macro,
  77. str,
  78. line_str,
  79. loc,
  80. loclists,
  81. pubtypes,
  82. gnu_pubtypes,
  83. ranges,
  84. rnglists,
  85. static_func,
  86. static_vars,
  87. types,
  88. weaknames,
  89. gdb_index,
  90. debug_names,
  91. trace_info,
  92. trace_abbrev,
  93. trace_aranges,
  94. info_dwo,
  95. abbrev_dwo,
  96. types_dwo,
  97. line_dwo,
  98. loc_dwo,
  99. macro_dwo,
  100. macinfo_dwo,
  101. str_dwo,
  102. str_index,
  103. str_index_dwo,
  104. debug_addr,
  105. dwp_cu_index,
  106. dwp_tu_index,
  107. max
  108. };
  109. struct dwarf_section
  110. {
  111. /* A debug section has a different name when it's stored compressed
  112. or not. COMPRESSED_NAME and UNCOMPRESSED_NAME are the two
  113. possibilities. NAME is set to whichever one is used for this
  114. input file, as determined by load_debug_section(). */
  115. const char *uncompressed_name;
  116. const char *compressed_name;
  117. const char *name;
  118. unsigned char *start;
  119. dwarf_vma address;
  120. dwarf_size_type size;
  121. enum dwarf_section_display_enum abbrev_sec;
  122. /* Used by clients to help them implement the reloc_at callback. */
  123. void * reloc_info;
  124. unsigned long num_relocs;
  125. /* A spare field for random use. */
  126. void *user_data;
  127. };
  128. /* A structure containing the name of a debug section
  129. and a pointer to a function that can decode it. */
  130. struct dwarf_section_display
  131. {
  132. struct dwarf_section section;
  133. int (*display) (struct dwarf_section *, void *);
  134. int *enabled;
  135. bfd_boolean relocate;
  136. };
  137. extern struct dwarf_section_display debug_displays [];
  138. /* This structure records the information that
  139. we extract from the.debug_info section. */
  140. typedef struct
  141. {
  142. unsigned int pointer_size;
  143. unsigned int offset_size;
  144. int dwarf_version;
  145. dwarf_vma cu_offset;
  146. dwarf_vma base_address;
  147. /* This field is filled in when reading the attribute DW_AT_GNU_addr_base and
  148. is used with the form DW_AT_GNU_FORM_addr_index. */
  149. dwarf_vma addr_base;
  150. /* This field is filled in when reading the attribute DW_AT_GNU_ranges_base and
  151. is used when calculating ranges. */
  152. dwarf_vma ranges_base;
  153. /* This is an array of offsets to the location list table. */
  154. dwarf_vma * loc_offsets;
  155. int * have_frame_base;
  156. unsigned int num_loc_offsets;
  157. unsigned int max_loc_offsets;
  158. /* List of .debug_ranges offsets seen in this .debug_info. */
  159. dwarf_vma * range_lists;
  160. unsigned int num_range_lists;
  161. unsigned int max_range_lists;
  162. }
  163. debug_info;
  164. extern unsigned int eh_addr_size;
  165. extern int do_debug_info;
  166. extern int do_debug_abbrevs;
  167. extern int do_debug_lines;
  168. extern int do_debug_pubnames;
  169. extern int do_debug_pubtypes;
  170. extern int do_debug_aranges;
  171. extern int do_debug_ranges;
  172. extern int do_debug_frames;
  173. extern int do_debug_frames_interp;
  174. extern int do_debug_macinfo;
  175. extern int do_debug_str;
  176. extern int do_debug_loc;
  177. extern int do_gdb_index;
  178. extern int do_trace_info;
  179. extern int do_trace_abbrevs;
  180. extern int do_trace_aranges;
  181. extern int do_debug_addr;
  182. extern int do_debug_cu_index;
  183. extern int do_wide;
  184. extern int dwarf_cutoff_level;
  185. extern unsigned long dwarf_start_die;
  186. extern int dwarf_check;
  187. extern void init_dwarf_regnames (unsigned int);
  188. extern void init_dwarf_regnames_i386 (void);
  189. extern void init_dwarf_regnames_iamcu (void);
  190. extern void init_dwarf_regnames_x86_64 (void);
  191. extern void init_dwarf_regnames_aarch64 (void);
  192. extern void init_dwarf_regnames_s390 (void);
  193. extern int load_debug_section (enum dwarf_section_display_enum, void *);
  194. extern void free_debug_section (enum dwarf_section_display_enum);
  195. extern void free_debug_memory (void);
  196. extern void dwarf_select_sections_by_names (const char *);
  197. extern void dwarf_select_sections_by_letters (const char *);
  198. extern void dwarf_select_sections_all (void);
  199. extern unsigned int * find_cu_tu_set (void *, unsigned int);
  200. extern void * cmalloc (size_t, size_t);
  201. extern void * xcalloc2 (size_t, size_t);
  202. extern void * xcmalloc (size_t, size_t);
  203. extern void * xcrealloc (void *, size_t, size_t);
  204. extern dwarf_vma read_leb128 (unsigned char *, unsigned int *, bfd_boolean, const unsigned char * const);
  205. /* A callback into the client. Returns TRUE if there is a
  206. relocation against the given debug section at the given
  207. offset. */
  208. extern bfd_boolean reloc_at (struct dwarf_section *, dwarf_vma);