xref: /illumos-gate/usr/src/lib/libdwarf/common/dwarf_global.h (revision 533affcbc7fc4d0c8132976ea454aaa715fe2307)
1 /*
2 
3   Copyright (C) 2000,2004,2005 Silicon Graphics, Inc.  All Rights Reserved.
4   Portions Copyright (C) 2011 David Anderson. All Rights Reserved.
5 
6 
7   This program is free software; you can redistribute it and/or modify it
8   under the terms of version 2.1 of the GNU Lesser General Public License
9   as published by the Free Software Foundation.
10 
11   This program is distributed in the hope that it would be useful, but
12   WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 
15   Further, this software is distributed without any warranty that it is
16   free of the rightful claim of any third person regarding infringement
17   or the like.  Any license provided herein, whether implied or
18   otherwise, applies only to this software file.  Patent licenses, if
19   any, provided herein do not apply to combinations of this program with
20   other software, or any other product whatsoever.
21 
22   You should have received a copy of the GNU Lesser General Public
23   License along with this program; if not, write the Free Software
24   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
25   USA.
26 
27 */
28 
29 
30 
31 
32 typedef struct Dwarf_Global_Context_s *Dwarf_Global_Context;
33 
34 /*
35     This struct contains header information for a set of pubnames.
36     Essentially, they contain the context for a set of pubnames
37     belonging to a compilation-unit.
38 
39     This is also used for the sgi-specific
40     weaknames, typenames, varnames, funcnames data:
41     the structs for those are incomplete and
42     instances of this are used instead.
43 
44     Also used for DWARF3 .debug_pubtypes.
45 
46     These never refer to .debug_types, only to .debug_info.
47 
48 */
49 struct Dwarf_Global_Context_s {
50 
51     /*  For this context, size of a length. 4 or 8 */
52     unsigned char pu_length_size;
53 
54     /* Size of the pubnames data for the CU */
55     unsigned char pu_length;
56 
57     /*  For this CU, size of the extension 0 except for dwarf2 extension
58         64bit, in which case is 4. */
59     unsigned char pu_extension_size;
60 
61     Dwarf_Half pu_version; /* 2,3, or 4 */
62 
63     /*  offset in pubnames of the  pu header. */
64     Dwarf_Off      pu_pub_offset;
65 
66     /*  Offset into .debug_info of the compilation-unit header (not DIE)
67         for this set of pubnames. */
68     Dwarf_Off pu_offset_of_cu_header;
69 
70     /*  Size of compilation-unit that these pubnames are in. */
71     Dwarf_Unsigned pu_info_length;
72 
73     Dwarf_Debug pu_dbg;
74 };
75 
76 
77 /* This struct contains information for a single pubname. */
78 struct Dwarf_Global_s {
79 
80     /*  Offset from the start of the corresponding compilation-unit of
81         the DIE for the given pubname CU. */
82     Dwarf_Off gl_named_die_offset_within_cu;
83 
84     /* Points to the given pubname. */
85     Dwarf_Small *gl_name;
86 
87     /* Context for this pubname. */
88     Dwarf_Global_Context gl_context;
89 
90 };
91 
92 int _dwarf_internal_get_pubnames_like_data(Dwarf_Debug dbg,
93     Dwarf_Small *
94     section_data_ptr,
95     Dwarf_Unsigned
96     section_length,
97     Dwarf_Global ** globals,
98     Dwarf_Signed * return_count,
99     Dwarf_Error * error,
100     int context_code,
101     int global_code,
102     int length_err_num,
103     int version_err_num);
104 
105 void
106 _dwarf_internal_globals_dealloc( Dwarf_Debug dbg, Dwarf_Global *dwgl,
107     Dwarf_Signed count,
108     int context_code,
109     int global_code,
110     int list_code);
111 
112 
113 #ifdef __sgi  /* __sgi should only be defined for IRIX/MIPS. */
114 void _dwarf_fix_up_offset_irix(Dwarf_Debug dbg,
115     Dwarf_Unsigned *varp,
116     char *caller_site_name);
117 #define FIX_UP_OFFSET_IRIX_BUG(ldbg,var,name) _dwarf_fix_up_offset_irix(ldbg,&var,name)
118 #else  /* ! __sgi */
119 #define FIX_UP_OFFSET_IRIX_BUG(ldbg,var,name)
120 #endif  /* __sgi */
121