xref: /illumos-gate/usr/src/lib/libdwarf/common/dwarf_abbrev.h (revision 4d9fdb46b215739778ebc12079842c9905586999)
1 /*
2    Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3    Portions Copyright (C) 2008-2019  David Anderson. All Rights Reserved.
4 
5    This program is free software; you can redistribute it
6    and/or modify it under the terms of version 2.1 of the
7    GNU Lesser General Public License as published by the Free
8    Software Foundation.
9 
10    This program is distributed in the hope that it would be
11    useful, but WITHOUT ANY WARRANTY; without even the implied
12    warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13    PURPOSE.
14 
15    Further, this software is distributed without any warranty
16    that it is free of the rightful claim of any third person
17    regarding infringement or the like.  Any license provided
18    herein, whether implied or otherwise, applies only to this
19    software file.  Patent licenses, if any, provided herein
20    do not apply to combinations of this program with other
21    software, or any other product whatsoever.
22 
23    You should have received a copy of the GNU Lesser General
24    Public License along with this program; if not, write
25    the Free Software Foundation, Inc., 51 Franklin Street -
26    Fifth Floor, Boston MA 02110-1301, USA.
27 
28 */
29 
30 
31 
32 
33 /*  In a given CU, one of these is (eventually) set up
34     for every abbreviation we need to find (and for all.
35     those ealier in the abbreviations for that CU).
36     So we don't want elements needlessly big.
37 */
38 struct Dwarf_Abbrev_s {
39     /*  No TAG should exceed DW_TAG_hi_user, 0xffff, but
40         we do allow a larger value here. */
41     Dwarf_Unsigned dab_tag;
42     /*  Abbreviations are numbered (normally sequentially from
43         1 and so 16 bits is not enough!  */
44     Dwarf_Unsigned dab_code;
45     Dwarf_Small dab_has_child;
46     /*  dab_abbrev_ptr points to the abbreviations
47         themselves in memory, the list of attr/form
48         integers terminated by 0,0. */
49     Dwarf_Byte_Ptr dab_abbrev_ptr;
50     Dwarf_Debug dab_dbg;
51 
52     /* Section global offset of the abbrev. */
53     Dwarf_Off    dab_goffset;
54     /* dab_count is the number of attr/form uleb pairs */
55     Dwarf_Off    dab_count;
56 
57     /*  When the caller cycles through attr/form pairs
58         by index from zero this lets the code read just one
59         pair to work. */
60     Dwarf_Byte_Ptr dab_next_ptr;
61     Dwarf_Unsigned dab_next_index;
62 };
63 
64 int _dwarf_count_abbrev_entries(Dwarf_Debug dbg,
65     Dwarf_Byte_Ptr abbrev_ptr,
66     Dwarf_Byte_Ptr abbrev_section_end,
67     Dwarf_Unsigned *abbrev_count_out,
68     Dwarf_Byte_Ptr *abbrev_ptr_out,
69     Dwarf_Error *error);
70