dwarf.h 6.2 KB

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