1/* dwwrf.h - DWARF support header file
2   Copyright 2005
3   Free Software Foundation, Inc.
4
5This file is part of GNU Binutils.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
20
21#include "bfd.h"
22#include "elf/dwarf2.h"
23
24#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
25/* We can't use any bfd types here since readelf may define BFD64 and
26   objdump may not.  */
27typedef unsigned long long dwarf_vma;
28typedef unsigned long long dwarf_size_type;
29#else
30typedef unsigned long dwarf_vma;
31typedef unsigned long dwarf_size_type;
32#endif
33
34struct dwarf_section
35{
36  const char *name;
37  unsigned char *start;
38  dwarf_vma address;
39  dwarf_size_type size;
40};
41
42/* A structure containing the name of a debug section
43   and a pointer to a function that can decode it.  */
44struct dwarf_section_display
45{
46  struct dwarf_section section;
47  int (*display) (struct dwarf_section *, void *);
48  unsigned int relocate : 1;
49  unsigned int eh_frame : 1;
50};
51
52enum dwarf_section_display_enum {
53  abbrev = 0,
54  aranges,
55  frame,
56  info,
57  line,
58  pubnames,
59  eh_frame,
60  macinfo,
61  str,
62  loc,
63  pubtypes,
64  ranges,
65  static_func,
66  static_vars,
67  types,
68  weaknames,
69  max
70};
71
72extern struct dwarf_section_display debug_displays [];
73
74/* This structure records the information that
75   we extract from the.debug_info section.  */
76typedef struct
77{
78  unsigned int   pointer_size;
79  unsigned long  cu_offset;
80  unsigned long	 base_address;
81  /* This is an array of offsets to the location list table.  */
82  unsigned long *loc_offsets;
83  int		*have_frame_base;
84  unsigned int   num_loc_offsets;
85  unsigned int   max_loc_offsets;
86  unsigned long *range_lists;
87  unsigned int   num_range_lists;
88  unsigned int   max_range_lists;
89}
90debug_info;
91
92extern dwarf_vma (*byte_get) (unsigned char *, int);
93extern dwarf_vma byte_get_little_endian (unsigned char *, int);
94extern dwarf_vma byte_get_big_endian (unsigned char *, int);
95
96extern dwarf_vma eh_addr_size;
97extern int is_relocatable;
98
99extern int do_debug_info;
100extern int do_debug_abbrevs;
101extern int do_debug_lines;
102extern int do_debug_pubnames;
103extern int do_debug_aranges;
104extern int do_debug_ranges;
105extern int do_debug_frames;
106extern int do_debug_frames_interp;
107extern int do_debug_macinfo;
108extern int do_debug_str;
109extern int do_debug_loc;
110
111extern int load_debug_section (enum dwarf_section_display_enum,
112			       void *);
113extern void free_debug_section (enum dwarf_section_display_enum);
114
115extern void free_debug_memory (void);
116
117void *cmalloc (size_t, size_t);
118void *xcmalloc (size_t, size_t);
119void *xcrealloc (void *, size_t, size_t);
120
121void error (const char *, ...) ATTRIBUTE_PRINTF_1;
122void warn (const char *, ...) ATTRIBUTE_PRINTF_1;
123