xref: /illumos-gate/usr/src/lib/libdwarf/common/dwarf_dnames.h (revision 20a7641f9918de8574b8b3b47dbe35c4bfc78df1)
1 /*
2   Copyright (C) 2017-2017 David Anderson. All Rights Reserved.
3 
4   This program is free software; you can redistribute it and/or modify it
5   under the terms of version 2.1 of the GNU Lesser General Public License
6   as published by the Free Software Foundation.
7 
8   This program is distributed in the hope that it would be useful, but
9   WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 
12   Further, this software is distributed without any warranty that it is
13   free of the rightful claim of any third person regarding infringement
14   or the like.  Any license provided herein, whether implied or
15   otherwise, applies only to this software file.  Patent licenses, if
16   any, provided herein do not apply to combinations of this program with
17   other software, or any other product whatsoever.
18 
19   You should have received a copy of the GNU Lesser General Public
20   License along with this program; if not, write the Free Software
21   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
22   USA.
23 
24 */
25 
26 /*  Only 5 abbrev DW_IDX defined, we
27     allow three user defined (arbitrarily) */
28 #define ABB_PAIRS_MAX 8
29 
30 struct abbrev_pair_s {
31     unsigned ap_index;
32     unsigned ap_form;
33 };
34 
35 struct Dwarf_D_Abbrev_s {
36     struct Dwarf_D_Abbrev_s * da_next;
37     unsigned da_abbrev_code;
38     unsigned da_tag;
39     unsigned da_pairs_count;
40     struct abbrev_pair_s da_pairs[ABB_PAIRS_MAX];
41 };
42 
43 
44 #define DWARF_DNAMES_VERSION5 5
45 
46 struct Dwarf_Dnames_index_header_s {
47     Dwarf_Debug    din_dbg;
48     struct Dwarf_Dnames_index_header_s *din_next;
49 
50     /*  The .debug_names section offset of 1st byte
51         of a header record. */
52     Dwarf_Unsigned din_section_offset;
53 
54     /* For offset and pointer sanity calculations. */
55     Dwarf_Small  * din_indextable_data;
56     Dwarf_Unsigned din_indextable_length;
57     unsigned       din_offset_size;
58 
59     Dwarf_Unsigned din_version;
60     Dwarf_Unsigned din_comp_unit_count;
61     Dwarf_Unsigned din_local_type_unit_count;
62     Dwarf_Unsigned din_foreign_type_unit_count;
63     Dwarf_Unsigned din_bucket_count;
64     Dwarf_Unsigned din_name_count;
65     Dwarf_Unsigned din_abbrev_table_size; /* bytes */
66     Dwarf_Unsigned din_entry_pool_size;   /* bytes */
67 
68     Dwarf_Unsigned din_augmentation_string_size;
69 
70     /*  Since we cannot assume the string is NUL
71         terminated we allocate a sufficient
72         string space and NUL terminate the string.
73         The DWARF5 standard does not specify
74         it as null-terminated.  We copy it into
75         calloc area so not 'const'  */
76     char *   din_augmentation_string;
77 
78     Dwarf_Small *  din_cu_list;
79     Dwarf_Small *  din_local_tu_list;
80     Dwarf_Small *  din_foreign_tu_list;
81     Dwarf_Small *  din_buckets;
82     Dwarf_Small *  din_hash_table;
83     Dwarf_Small *  din_string_offsets;
84     Dwarf_Small *  din_entry_offsets;
85     Dwarf_Small *  din_abbreviations;
86     Dwarf_Small *  din_entry_pool;
87 
88     unsigned       din_abbrev_list_count;
89     /* An array of size din_abbrev_list_count. */
90     struct Dwarf_D_Abbrev_s * din_abbrev_list;
91 
92 };
93 
94 
95 struct Dwarf_Dnames_Head_s {
96     Dwarf_Debug               dn_dbg;
97     Dwarf_Small             * dn_section_data;
98     Dwarf_Small             * dn_section_end;
99     Dwarf_Unsigned            dn_section_size;
100     unsigned                  dn_inhdr_count;
101 
102     /*  Becomes an array of these structs, dn_inhdr_count
103         of them. */
104     struct Dwarf_Dnames_index_header_s * dn_inhdr_first;
105 };
106 
107 void _dwarf_debugnames_destructor(void *m);
108