xref: /minix3/external/bsd/elftoolchain/dist/libdwarf/_libdwarf.h (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc /*	$NetBSD: _libdwarf.h,v 1.2 2014/03/09 16:58:03 christos Exp $	*/
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc /*-
4*0a6a1f1dSLionel Sambuc  * Copyright (c) 2007 John Birrell (jb@freebsd.org)
5*0a6a1f1dSLionel Sambuc  * Copyright (c) 2009-2011 Kai Wang
6*0a6a1f1dSLionel Sambuc  * All rights reserved.
7*0a6a1f1dSLionel Sambuc  *
8*0a6a1f1dSLionel Sambuc  * Redistribution and use in source and binary forms, with or without
9*0a6a1f1dSLionel Sambuc  * modification, are permitted provided that the following conditions
10*0a6a1f1dSLionel Sambuc  * are met:
11*0a6a1f1dSLionel Sambuc  * 1. Redistributions of source code must retain the above copyright
12*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer.
13*0a6a1f1dSLionel Sambuc  * 2. Redistributions in binary form must reproduce the above copyright
14*0a6a1f1dSLionel Sambuc  *    notice, this list of conditions and the following disclaimer in the
15*0a6a1f1dSLionel Sambuc  *    documentation and/or other materials provided with the distribution.
16*0a6a1f1dSLionel Sambuc  *
17*0a6a1f1dSLionel Sambuc  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*0a6a1f1dSLionel Sambuc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*0a6a1f1dSLionel Sambuc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*0a6a1f1dSLionel Sambuc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*0a6a1f1dSLionel Sambuc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*0a6a1f1dSLionel Sambuc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*0a6a1f1dSLionel Sambuc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*0a6a1f1dSLionel Sambuc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*0a6a1f1dSLionel Sambuc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*0a6a1f1dSLionel Sambuc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*0a6a1f1dSLionel Sambuc  * SUCH DAMAGE.
28*0a6a1f1dSLionel Sambuc  *
29*0a6a1f1dSLionel Sambuc  * Id: _libdwarf.h 2075 2011-10-27 03:47:28Z jkoshy
30*0a6a1f1dSLionel Sambuc  */
31*0a6a1f1dSLionel Sambuc 
32*0a6a1f1dSLionel Sambuc #ifndef	__LIBDWARF_H_
33*0a6a1f1dSLionel Sambuc #define	__LIBDWARF_H_
34*0a6a1f1dSLionel Sambuc 
35*0a6a1f1dSLionel Sambuc #if HAVE_NBTOOL_CONFIG_H
36*0a6a1f1dSLionel Sambuc # include "nbtool_config.h"
37*0a6a1f1dSLionel Sambuc #endif
38*0a6a1f1dSLionel Sambuc 
39*0a6a1f1dSLionel Sambuc #include <sys/param.h>
40*0a6a1f1dSLionel Sambuc #include <sys/queue.h>
41*0a6a1f1dSLionel Sambuc #include <assert.h>
42*0a6a1f1dSLionel Sambuc #include <limits.h>
43*0a6a1f1dSLionel Sambuc #include <stdio.h>
44*0a6a1f1dSLionel Sambuc #include <stdlib.h>
45*0a6a1f1dSLionel Sambuc #include <string.h>
46*0a6a1f1dSLionel Sambuc #include <gelf.h>
47*0a6a1f1dSLionel Sambuc #include "dwarf.h"
48*0a6a1f1dSLionel Sambuc #include "libdwarf.h"
49*0a6a1f1dSLionel Sambuc #include "uthash.h"
50*0a6a1f1dSLionel Sambuc 
51*0a6a1f1dSLionel Sambuc #include "_elftc.h"
52*0a6a1f1dSLionel Sambuc 
53*0a6a1f1dSLionel Sambuc #define DWARF_DIE_HASH_SIZE		8191
54*0a6a1f1dSLionel Sambuc 
55*0a6a1f1dSLionel Sambuc struct _libdwarf_globals {
56*0a6a1f1dSLionel Sambuc 	Dwarf_Handler	errhand;
57*0a6a1f1dSLionel Sambuc 	Dwarf_Ptr	errarg;
58*0a6a1f1dSLionel Sambuc 	int		applyrela;
59*0a6a1f1dSLionel Sambuc };
60*0a6a1f1dSLionel Sambuc 
61*0a6a1f1dSLionel Sambuc extern struct _libdwarf_globals _libdwarf;
62*0a6a1f1dSLionel Sambuc 
63*0a6a1f1dSLionel Sambuc #define	_DWARF_SET_ERROR(_d, _e, _err, _elf_err)			\
64*0a6a1f1dSLionel Sambuc 	_dwarf_set_error(_d, _e, _err, _elf_err, __func__, __LINE__)
65*0a6a1f1dSLionel Sambuc #define	DWARF_SET_ERROR(_d, _e, _err)					\
66*0a6a1f1dSLionel Sambuc 	_DWARF_SET_ERROR(_d, _e, _err, 0)
67*0a6a1f1dSLionel Sambuc #define	DWARF_SET_ELF_ERROR(_d, _e)					\
68*0a6a1f1dSLionel Sambuc 	_DWARF_SET_ERROR(_d, _e, DW_DLE_ELF, elf_errno())
69*0a6a1f1dSLionel Sambuc 
70*0a6a1f1dSLionel Sambuc /*
71*0a6a1f1dSLionel Sambuc  * Convenient macros for producer bytes stream generation.
72*0a6a1f1dSLionel Sambuc  */
73*0a6a1f1dSLionel Sambuc #define	WRITE_VALUE(value, bytes)					\
74*0a6a1f1dSLionel Sambuc 	dbg->write_alloc(&ds->ds_data, &ds->ds_cap, &ds->ds_size,	\
75*0a6a1f1dSLionel Sambuc 	    (value), (bytes), error)
76*0a6a1f1dSLionel Sambuc #define	WRITE_ULEB128(value)						\
77*0a6a1f1dSLionel Sambuc 	_dwarf_write_uleb128_alloc(&ds->ds_data, &ds->ds_cap,		\
78*0a6a1f1dSLionel Sambuc 	    &ds->ds_size, (value), error)
79*0a6a1f1dSLionel Sambuc #define	WRITE_SLEB128(value)						\
80*0a6a1f1dSLionel Sambuc 	_dwarf_write_sleb128_alloc(&ds->ds_data, &ds->ds_cap,		\
81*0a6a1f1dSLionel Sambuc 	    &ds->ds_size, (value), error)
82*0a6a1f1dSLionel Sambuc #define	WRITE_STRING(string)						\
83*0a6a1f1dSLionel Sambuc 	_dwarf_write_string_alloc(&ds->ds_data, &ds->ds_cap,		\
84*0a6a1f1dSLionel Sambuc 	    &ds->ds_size, (string), error)
85*0a6a1f1dSLionel Sambuc #define	WRITE_BLOCK(blk, size)						\
86*0a6a1f1dSLionel Sambuc 	_dwarf_write_block_alloc(&ds->ds_data, &ds->ds_cap,		\
87*0a6a1f1dSLionel Sambuc 	    &ds->ds_size, (blk), (size), error)
88*0a6a1f1dSLionel Sambuc #define	WRITE_PADDING(byte, cnt)					\
89*0a6a1f1dSLionel Sambuc 	_dwarf_write_padding_alloc(&ds->ds_data, &ds->ds_cap,		\
90*0a6a1f1dSLionel Sambuc 	    &ds->ds_size, (byte), (cnt), error)
91*0a6a1f1dSLionel Sambuc #define	RCHECK(expr)							\
92*0a6a1f1dSLionel Sambuc 	do {								\
93*0a6a1f1dSLionel Sambuc 		ret = expr;						\
94*0a6a1f1dSLionel Sambuc 		if (ret != DW_DLE_NONE)					\
95*0a6a1f1dSLionel Sambuc 			goto gen_fail;					\
96*0a6a1f1dSLionel Sambuc 	} while (/*CONSTCOND*/0)
97*0a6a1f1dSLionel Sambuc 
98*0a6a1f1dSLionel Sambuc 
99*0a6a1f1dSLionel Sambuc struct _Dwarf_AttrDef {
100*0a6a1f1dSLionel Sambuc 	uint64_t	ad_attrib;		/* DW_AT_XXX */
101*0a6a1f1dSLionel Sambuc 	uint64_t	ad_form;		/* DW_FORM_XXX */
102*0a6a1f1dSLionel Sambuc 	uint64_t	ad_offset;		/* Offset in abbrev section. */
103*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_AttrDef) ad_next;	/* Next attribute define. */
104*0a6a1f1dSLionel Sambuc };
105*0a6a1f1dSLionel Sambuc 
106*0a6a1f1dSLionel Sambuc struct _Dwarf_Attribute {
107*0a6a1f1dSLionel Sambuc 	Dwarf_Die		at_die;		/* Ptr to containing DIE. */
108*0a6a1f1dSLionel Sambuc 	Dwarf_Die		at_refdie;	/* Ptr to reference DIE. */
109*0a6a1f1dSLionel Sambuc 	uint64_t		at_offset;	/* Offset in info section. */
110*0a6a1f1dSLionel Sambuc 	uint64_t		at_attrib;	/* DW_AT_XXX */
111*0a6a1f1dSLionel Sambuc 	uint64_t		at_form;	/* DW_FORM_XXX */
112*0a6a1f1dSLionel Sambuc 	int			at_indirect;	/* Has indirect form. */
113*0a6a1f1dSLionel Sambuc 	union {
114*0a6a1f1dSLionel Sambuc 		uint64_t	u64;		/* Unsigned value. */
115*0a6a1f1dSLionel Sambuc 		int64_t		s64;		/* Signed value. */
116*0a6a1f1dSLionel Sambuc 		char		*s;   		/* String. */
117*0a6a1f1dSLionel Sambuc 		uint8_t		*u8p;		/* Block data. */
118*0a6a1f1dSLionel Sambuc 	} u[2];					/* Value. */
119*0a6a1f1dSLionel Sambuc 	Dwarf_Block		at_block;	/* Block. */
120*0a6a1f1dSLionel Sambuc 	Dwarf_Locdesc		*at_ld;		/* at value is locdesc. */
121*0a6a1f1dSLionel Sambuc 	Dwarf_P_Expr		at_expr;	/* at value is expr. */
122*0a6a1f1dSLionel Sambuc 	uint64_t		at_relsym;	/* Relocation symbol index. */
123*0a6a1f1dSLionel Sambuc 	const char		*at_relsec;	/* Rel. to dwarf section. */
124*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Attribute) at_next;	/* Next attribute. */
125*0a6a1f1dSLionel Sambuc };
126*0a6a1f1dSLionel Sambuc 
127*0a6a1f1dSLionel Sambuc struct _Dwarf_Abbrev {
128*0a6a1f1dSLionel Sambuc 	uint64_t	ab_entry;	/* Abbrev entry. */
129*0a6a1f1dSLionel Sambuc 	uint64_t	ab_tag;		/* Tag: DW_TAG_ */
130*0a6a1f1dSLionel Sambuc 	uint8_t		ab_children;	/* DW_CHILDREN_no or DW_CHILDREN_yes */
131*0a6a1f1dSLionel Sambuc 	uint64_t	ab_offset;	/* Offset in abbrev section. */
132*0a6a1f1dSLionel Sambuc 	uint64_t	ab_length;	/* Length of this abbrev entry. */
133*0a6a1f1dSLionel Sambuc 	uint64_t	ab_atnum;	/* Number of attribute defines. */
134*0a6a1f1dSLionel Sambuc 	UT_hash_handle	ab_hh;		/* Uthash handle. */
135*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_AttrDef) ab_attrdef; /* List of attribute defs. */
136*0a6a1f1dSLionel Sambuc };
137*0a6a1f1dSLionel Sambuc 
138*0a6a1f1dSLionel Sambuc struct _Dwarf_Die {
139*0a6a1f1dSLionel Sambuc 	Dwarf_Die	die_parent;	/* Parent DIE. */
140*0a6a1f1dSLionel Sambuc 	Dwarf_Die	die_child;	/* First child DIE. */
141*0a6a1f1dSLionel Sambuc 	Dwarf_Die	die_left;	/* Left sibling DIE. */
142*0a6a1f1dSLionel Sambuc 	Dwarf_Die	die_right;	/* Right sibling DIE. */
143*0a6a1f1dSLionel Sambuc 	uint64_t	die_offset;	/* DIE offset in section. */
144*0a6a1f1dSLionel Sambuc 	uint64_t	die_next_off;	/* Next DIE offset in section. */
145*0a6a1f1dSLionel Sambuc 	uint64_t	die_abnum;	/* Abbrev number. */
146*0a6a1f1dSLionel Sambuc 	Dwarf_Abbrev	die_ab;		/* Abbrev pointer. */
147*0a6a1f1dSLionel Sambuc 	Dwarf_Tag	die_tag;	/* DW_TAG_ */
148*0a6a1f1dSLionel Sambuc 	Dwarf_Debug	die_dbg;	/* Dwarf_Debug pointer. */
149*0a6a1f1dSLionel Sambuc 	Dwarf_CU	die_cu;		/* Compilation unit pointer. */
150*0a6a1f1dSLionel Sambuc 	char		*die_name;	/* Ptr to the name string. */
151*0a6a1f1dSLionel Sambuc 	Dwarf_Attribute	*die_attrarray;	/* Array of attributes. */
152*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Attribute)	die_attr; /* List of attributes. */
153*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Die) die_pro_next; /* Next die in pro-die list. */
154*0a6a1f1dSLionel Sambuc };
155*0a6a1f1dSLionel Sambuc 
156*0a6a1f1dSLionel Sambuc struct _Dwarf_Loclist {
157*0a6a1f1dSLionel Sambuc 	Dwarf_Locdesc 	**ll_ldlist;	/* Array of Locdesc pointer. */
158*0a6a1f1dSLionel Sambuc 	int 		ll_ldlen;	/* Number of Locdesc. */
159*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ll_offset;	/* Offset in .debug_loc section. */
160*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ll_length;	/* Length (in bytes) of the loclist. */
161*0a6a1f1dSLionel Sambuc 	TAILQ_ENTRY(_Dwarf_Loclist) ll_next; /* Next loclist in list. */
162*0a6a1f1dSLionel Sambuc };
163*0a6a1f1dSLionel Sambuc 
164*0a6a1f1dSLionel Sambuc struct _Dwarf_P_Expr_Entry {
165*0a6a1f1dSLionel Sambuc 	Dwarf_Loc	ee_loc;		/* Location expression. */
166*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ee_sym;		/* Optional related reloc sym index. */
167*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_P_Expr_Entry) ee_next; /* Next entry in list. */
168*0a6a1f1dSLionel Sambuc };
169*0a6a1f1dSLionel Sambuc 
170*0a6a1f1dSLionel Sambuc struct _Dwarf_P_Expr {
171*0a6a1f1dSLionel Sambuc 	Dwarf_Debug	pe_dbg;		/* Dwarf_Debug pointer. */
172*0a6a1f1dSLionel Sambuc 	uint8_t		*pe_block;	/* Expression block data. */
173*0a6a1f1dSLionel Sambuc 	int		pe_invalid;	/* Block data is up-to-date or not. */
174*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	pe_length;	/* Length of the block. */
175*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_P_Expr_Entry) pe_eelist; /* List of entries. */
176*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_P_Expr) pe_next; /* Next expr in list. */
177*0a6a1f1dSLionel Sambuc };
178*0a6a1f1dSLionel Sambuc 
179*0a6a1f1dSLionel Sambuc struct _Dwarf_Line {
180*0a6a1f1dSLionel Sambuc 	Dwarf_LineInfo	ln_li;		/* Ptr to line info. */
181*0a6a1f1dSLionel Sambuc 	Dwarf_Addr	ln_addr;	/* Line address. */
182*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ln_symndx;	/* Symbol index for relocation. */
183*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ln_fileno;	/* File number. */
184*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ln_lineno;	/* Line number. */
185*0a6a1f1dSLionel Sambuc 	Dwarf_Signed	ln_column;	/* Column number. */
186*0a6a1f1dSLionel Sambuc 	Dwarf_Bool	ln_bblock;	/* Basic block flag. */
187*0a6a1f1dSLionel Sambuc 	Dwarf_Bool	ln_stmt;	/* Begin statement flag. */
188*0a6a1f1dSLionel Sambuc 	Dwarf_Bool	ln_endseq;	/* End sequence flag. */
189*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Line) ln_next; /* Next line in list. */
190*0a6a1f1dSLionel Sambuc };
191*0a6a1f1dSLionel Sambuc 
192*0a6a1f1dSLionel Sambuc struct _Dwarf_LineFile {
193*0a6a1f1dSLionel Sambuc 	char		*lf_fname;	/* Filename. */
194*0a6a1f1dSLionel Sambuc 	char		*lf_fullpath;	/* Full pathname of the file. */
195*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	lf_dirndx;	/* Dir index. */
196*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	lf_mtime;	/* Modification time. */
197*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	lf_size;	/* File size. */
198*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_LineFile) lf_next; /* Next file in list. */
199*0a6a1f1dSLionel Sambuc };
200*0a6a1f1dSLionel Sambuc 
201*0a6a1f1dSLionel Sambuc struct _Dwarf_LineInfo {
202*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	li_length;	/* Length of line info data. */
203*0a6a1f1dSLionel Sambuc 	Dwarf_Half	li_version;	/* Version of line info. */
204*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	li_hdrlen;	/* Length of line info header. */
205*0a6a1f1dSLionel Sambuc 	Dwarf_Small	li_minlen;	/* Minimum instrutction length. */
206*0a6a1f1dSLionel Sambuc 	Dwarf_Small	li_defstmt;	/* Default value of is_stmt. */
207*0a6a1f1dSLionel Sambuc 	int8_t		li_lbase;    	/* Line base for special opcode. */
208*0a6a1f1dSLionel Sambuc 	Dwarf_Small	li_lrange;    	/* Line range for special opcode. */
209*0a6a1f1dSLionel Sambuc 	Dwarf_Small	li_opbase;	/* Fisrt std opcode number. */
210*0a6a1f1dSLionel Sambuc 	Dwarf_Small	*li_oplen;	/* Array of std opcode len. */
211*0a6a1f1dSLionel Sambuc 	char		**li_incdirs;	/* Array of include dirs. */
212*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	li_inclen;	/* Length of inc dir array. */
213*0a6a1f1dSLionel Sambuc 	char		**li_lfnarray;	/* Array of file names. */
214*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	li_lflen;	/* Length of filename array. */
215*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_LineFile) li_lflist; /* List of files. */
216*0a6a1f1dSLionel Sambuc 	Dwarf_Line	*li_lnarray;	/* Array of lines. */
217*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	li_lnlen;	/* Length of the line array. */
218*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Line) li_lnlist; /* List of lines. */
219*0a6a1f1dSLionel Sambuc };
220*0a6a1f1dSLionel Sambuc 
221*0a6a1f1dSLionel Sambuc struct _Dwarf_NamePair {
222*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	np_nt;		/* Ptr to containing name table. */
223*0a6a1f1dSLionel Sambuc 	Dwarf_Die	np_die;		/* Ptr to Ref. Die. */
224*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	np_offset;	/* Offset in CU. */
225*0a6a1f1dSLionel Sambuc 	char		*np_name;	/* Object/Type name. */
226*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_NamePair) np_next; /* Next pair in the list. */
227*0a6a1f1dSLionel Sambuc };
228*0a6a1f1dSLionel Sambuc 
229*0a6a1f1dSLionel Sambuc struct _Dwarf_NameTbl {
230*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	nt_length;	/* Name lookup table length. */
231*0a6a1f1dSLionel Sambuc 	Dwarf_Half	nt_version;	/* Name lookup table version. */
232*0a6a1f1dSLionel Sambuc 	Dwarf_CU	nt_cu;		/* Ptr to Ref. CU. */
233*0a6a1f1dSLionel Sambuc 	Dwarf_Off	nt_cu_offset;	/* Ref. CU offset in .debug_info */
234*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	nt_cu_length;	/* Ref. CU length. */
235*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_NamePair) nt_nplist; /* List of offset+name pairs. */
236*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_NameTbl) nt_next; /* Next name table in the list. */
237*0a6a1f1dSLionel Sambuc };
238*0a6a1f1dSLionel Sambuc 
239*0a6a1f1dSLionel Sambuc struct _Dwarf_NameSec {
240*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_NameTbl) ns_ntlist; /* List of name tables. */
241*0a6a1f1dSLionel Sambuc 	Dwarf_NamePair	*ns_array;	/* Array of pairs of all tables. */
242*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ns_len;		/* Length of the pair array. */
243*0a6a1f1dSLionel Sambuc };
244*0a6a1f1dSLionel Sambuc 
245*0a6a1f1dSLionel Sambuc struct _Dwarf_Fde {
246*0a6a1f1dSLionel Sambuc 	Dwarf_Debug	fde_dbg;	/* Ptr to containing dbg. */
247*0a6a1f1dSLionel Sambuc 	Dwarf_Cie	fde_cie;	/* Ptr to associated CIE. */
248*0a6a1f1dSLionel Sambuc 	Dwarf_FrameSec	fde_fs;		/* Ptr to containing .debug_frame. */
249*0a6a1f1dSLionel Sambuc 	Dwarf_Ptr	fde_addr;	/* Ptr to start of the FDE. */
250*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_offset;	/* Offset of the FDE. */
251*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_length;	/* Length of the FDE. */
252*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_cieoff;	/* Offset of associated CIE. */
253*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_initloc;	/* Initial location. */
254*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_adrange;	/* Address range. */
255*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_auglen;	/* Augmentation length. */
256*0a6a1f1dSLionel Sambuc 	uint8_t		*fde_augdata;	/* Augmentation data. */
257*0a6a1f1dSLionel Sambuc 	uint8_t		*fde_inst;	/* Instructions. */
258*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_instlen;	/* Length of instructions. */
259*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_instcap;	/* Capacity of inst buffer. */
260*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_symndx;	/* Symbol index for relocation. */
261*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fde_esymndx;	/* End symbol index for relocation. */
262*0a6a1f1dSLionel Sambuc 	Dwarf_Addr	fde_eoff;	/* Offset from the end symbol. */
263*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Fde) fde_next; /* Next FDE in list. */
264*0a6a1f1dSLionel Sambuc };
265*0a6a1f1dSLionel Sambuc 
266*0a6a1f1dSLionel Sambuc struct _Dwarf_Cie {
267*0a6a1f1dSLionel Sambuc 	Dwarf_Debug	cie_dbg;	/* Ptr to containing dbg. */
268*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_index;	/* Index of the CIE. */
269*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_offset;	/* Offset of the CIE. */
270*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_length;	/* Length of the CIE. */
271*0a6a1f1dSLionel Sambuc 	Dwarf_Half	cie_version;	/* CIE version. */
272*0a6a1f1dSLionel Sambuc 	uint8_t		*cie_augment;	/* CIE augmentation (UTF-8). */
273*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_ehdata;	/* Optional EH Data. */
274*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_caf;	/* Code alignment factor. */
275*0a6a1f1dSLionel Sambuc 	Dwarf_Signed	cie_daf;	/* Data alignment factor. */
276*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_ra;		/* Return address register. */
277*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_auglen;	/* Augmentation length. */
278*0a6a1f1dSLionel Sambuc 	uint8_t		*cie_augdata;	/* Augmentation data; */
279*0a6a1f1dSLionel Sambuc 	uint8_t		cie_fde_encode; /* FDE PC start/range encode. */
280*0a6a1f1dSLionel Sambuc 	Dwarf_Ptr	cie_initinst;	/* Initial instructions. */
281*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	cie_instlen;	/* Length of init instructions. */
282*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Cie) cie_next;  /* Next CIE in list. */
283*0a6a1f1dSLionel Sambuc };
284*0a6a1f1dSLionel Sambuc 
285*0a6a1f1dSLionel Sambuc struct _Dwarf_FrameSec {
286*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Cie) fs_cielist; /* List of CIE. */
287*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Fde) fs_fdelist; /* List of FDE. */
288*0a6a1f1dSLionel Sambuc 	Dwarf_Cie	*fs_ciearray;	/* Array of CIE. */
289*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fs_cielen;	/* Length of CIE array. */
290*0a6a1f1dSLionel Sambuc 	Dwarf_Fde	*fs_fdearray;	/* Array of FDE.*/
291*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	fs_fdelen;	/* Length of FDE array. */
292*0a6a1f1dSLionel Sambuc };
293*0a6a1f1dSLionel Sambuc 
294*0a6a1f1dSLionel Sambuc struct _Dwarf_Arange {
295*0a6a1f1dSLionel Sambuc 	Dwarf_ArangeSet	ar_as;		/* Ptr to the set it belongs to. */
296*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ar_address;	/* Start PC. */
297*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ar_range;	/* PC range. */
298*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ar_symndx;	/* First symbol index for reloc. */
299*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ar_esymndx;	/* Second symbol index for reloc. */
300*0a6a1f1dSLionel Sambuc 	Dwarf_Addr	ar_eoff;	/* Offset from second symbol. */
301*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Arange) ar_next; /* Next arange in list. */
302*0a6a1f1dSLionel Sambuc };
303*0a6a1f1dSLionel Sambuc 
304*0a6a1f1dSLionel Sambuc struct _Dwarf_ArangeSet {
305*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	as_length;	/* Length of the arange set. */
306*0a6a1f1dSLionel Sambuc 	Dwarf_Half	as_version;	/* Version of the arange set. */
307*0a6a1f1dSLionel Sambuc 	Dwarf_Off	as_cu_offset;	/* Offset of associated CU. */
308*0a6a1f1dSLionel Sambuc 	Dwarf_CU	as_cu;		/* Ptr to associated CU. */
309*0a6a1f1dSLionel Sambuc 	Dwarf_Small	as_addrsz;	/* Target address size. */
310*0a6a1f1dSLionel Sambuc 	Dwarf_Small	as_segsz;	/* Target segment size. */
311*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD (, _Dwarf_Arange) as_arlist; /* List of ae entries. */
312*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_ArangeSet) as_next; /* Next set in list. */
313*0a6a1f1dSLionel Sambuc };
314*0a6a1f1dSLionel Sambuc 
315*0a6a1f1dSLionel Sambuc struct _Dwarf_MacroSet {
316*0a6a1f1dSLionel Sambuc 	Dwarf_Macro_Details *ms_mdlist; /* Array of macinfo entries. */
317*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ms_cnt;		/* Length of the array. */
318*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_MacroSet) ms_next; /* Next set in list. */
319*0a6a1f1dSLionel Sambuc };
320*0a6a1f1dSLionel Sambuc 
321*0a6a1f1dSLionel Sambuc struct _Dwarf_Rangelist {
322*0a6a1f1dSLionel Sambuc 	Dwarf_CU	rl_cu;		/* Ptr to associated CU. */
323*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	rl_offset;	/* Offset of the rangelist. */
324*0a6a1f1dSLionel Sambuc 	Dwarf_Ranges	*rl_rgarray;	/* Array of ranges. */
325*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	rl_rglen;	/* Length of the ranges array. */
326*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Rangelist) rl_next; /* Next rangelist in list. */
327*0a6a1f1dSLionel Sambuc };
328*0a6a1f1dSLionel Sambuc 
329*0a6a1f1dSLionel Sambuc struct _Dwarf_CU {
330*0a6a1f1dSLionel Sambuc 	Dwarf_Debug	cu_dbg;		/* Ptr to containing dbg. */
331*0a6a1f1dSLionel Sambuc 	Dwarf_Off	cu_offset;	/* Offset to the this CU. */
332*0a6a1f1dSLionel Sambuc 	uint32_t	cu_length;	/* Length of CU data. */
333*0a6a1f1dSLionel Sambuc 	uint16_t	cu_length_size; /* Size in bytes of the length field. */
334*0a6a1f1dSLionel Sambuc 	uint16_t	cu_version;	/* DWARF version. */
335*0a6a1f1dSLionel Sambuc 	uint64_t	cu_abbrev_offset; /* Offset into .debug_abbrev. */
336*0a6a1f1dSLionel Sambuc 	uint64_t	cu_abbrev_offset_cur; /* Current abbrev offset. */
337*0a6a1f1dSLionel Sambuc 	int		cu_abbrev_loaded; /* Abbrev table parsed. */
338*0a6a1f1dSLionel Sambuc 	uint64_t	cu_abbrev_cnt;	/* Abbrev entry count. */
339*0a6a1f1dSLionel Sambuc 	uint64_t	cu_lineno_offset; /* Offset into .debug_lineno. */
340*0a6a1f1dSLionel Sambuc 	uint8_t		cu_pointer_size;/* Number of bytes in pointer. */
341*0a6a1f1dSLionel Sambuc 	uint8_t		cu_dwarf_size;	/* CU section dwarf size. */
342*0a6a1f1dSLionel Sambuc 	Dwarf_Off	cu_next_offset; /* Offset to the next CU. */
343*0a6a1f1dSLionel Sambuc 	uint64_t	cu_1st_offset;	/* First DIE offset. */
344*0a6a1f1dSLionel Sambuc 	int		cu_pass2;	/* Two pass DIE traverse. */
345*0a6a1f1dSLionel Sambuc 	Dwarf_LineInfo	cu_lineinfo;	/* Ptr to Dwarf_LineInfo. */
346*0a6a1f1dSLionel Sambuc 	Dwarf_Abbrev	cu_abbrev_hash; /* Abbrev hash table. */
347*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_CU) cu_next; /* Next compilation unit. */
348*0a6a1f1dSLionel Sambuc };
349*0a6a1f1dSLionel Sambuc 
350*0a6a1f1dSLionel Sambuc typedef struct _Dwarf_Section {
351*0a6a1f1dSLionel Sambuc 	const char	*ds_name;	/* Section name. */
352*0a6a1f1dSLionel Sambuc 	Dwarf_Small	*ds_data;	/* Section data. */
353*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_addr;	/* Section virtual addr. */
354*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_size;	/* Section size. */
355*0a6a1f1dSLionel Sambuc } Dwarf_Section;
356*0a6a1f1dSLionel Sambuc 
357*0a6a1f1dSLionel Sambuc typedef struct _Dwarf_P_Section {
358*0a6a1f1dSLionel Sambuc 	char		*ds_name;	/* Section name. */
359*0a6a1f1dSLionel Sambuc 	Dwarf_Small	*ds_data;	/* Section data. */
360*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_size;	/* Section size. */
361*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_cap;		/* Section capacity. */
362*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_ndx;		/* ELF section index. */
363*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	ds_symndx;	/* Section symbol index. (for reloc) */
364*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_P_Section) ds_next; /* Next section in the list. */
365*0a6a1f1dSLionel Sambuc } *Dwarf_P_Section;
366*0a6a1f1dSLionel Sambuc 
367*0a6a1f1dSLionel Sambuc typedef struct _Dwarf_Rel_Entry {
368*0a6a1f1dSLionel Sambuc 	unsigned char	dre_type;	/* Reloc type. */
369*0a6a1f1dSLionel Sambuc 	unsigned char	dre_length;	/* Reloc storage unit length. */
370*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dre_offset;	/* Reloc storage unit offset. */
371*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dre_addend;	/* Reloc addend. */
372*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dre_symndx;	/* Reloc symbol index. */
373*0a6a1f1dSLionel Sambuc 	const char	*dre_secname;	/* Refer to some debug section. */
374*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Rel_Entry) dre_next; /* Next reloc entry. */
375*0a6a1f1dSLionel Sambuc } *Dwarf_Rel_Entry;
376*0a6a1f1dSLionel Sambuc 
377*0a6a1f1dSLionel Sambuc typedef struct _Dwarf_Rel_Section {
378*0a6a1f1dSLionel Sambuc 	struct _Dwarf_P_Section *drs_ds; /* Ptr to actual reloc ELF section. */
379*0a6a1f1dSLionel Sambuc 	struct _Dwarf_P_Section *drs_ref; /* Which debug section it refers. */
380*0a6a1f1dSLionel Sambuc 	struct Dwarf_Relocation_Data_s *drs_drd; /* Reloc data array. */
381*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Rel_Entry) drs_dre; /* Reloc entry list. */
382*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	drs_drecnt;	/* Count of entries. */
383*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	drs_size;	/* Size of ELF section in bytes. */
384*0a6a1f1dSLionel Sambuc 	int		drs_addend;	/* Elf_Rel or Elf_Rela */
385*0a6a1f1dSLionel Sambuc 	STAILQ_ENTRY(_Dwarf_Rel_Section) drs_next; /* Next reloc section. */
386*0a6a1f1dSLionel Sambuc } *Dwarf_Rel_Section;
387*0a6a1f1dSLionel Sambuc 
388*0a6a1f1dSLionel Sambuc typedef struct {
389*0a6a1f1dSLionel Sambuc 	Elf_Data *ed_data;
390*0a6a1f1dSLionel Sambuc 	void *ed_alloc;
391*0a6a1f1dSLionel Sambuc } Dwarf_Elf_Data;
392*0a6a1f1dSLionel Sambuc 
393*0a6a1f1dSLionel Sambuc typedef struct {
394*0a6a1f1dSLionel Sambuc 	Elf		*eo_elf;
395*0a6a1f1dSLionel Sambuc 	GElf_Ehdr	eo_ehdr;
396*0a6a1f1dSLionel Sambuc 	GElf_Shdr	*eo_shdr;
397*0a6a1f1dSLionel Sambuc 	Dwarf_Elf_Data	*eo_data;
398*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	eo_seccnt;
399*0a6a1f1dSLionel Sambuc 	size_t		eo_strndx;
400*0a6a1f1dSLionel Sambuc 	Dwarf_Obj_Access_Methods eo_methods;
401*0a6a1f1dSLionel Sambuc } Dwarf_Elf_Object;
402*0a6a1f1dSLionel Sambuc 
403*0a6a1f1dSLionel Sambuc struct _Dwarf_Debug {
404*0a6a1f1dSLionel Sambuc 	Dwarf_Obj_Access_Interface *dbg_iface;
405*0a6a1f1dSLionel Sambuc 	Dwarf_Section	*dbg_section;	/* Dwarf section list. */
406*0a6a1f1dSLionel Sambuc 	Dwarf_Section	*dbg_info_sec;	/* Pointer to info section. */
407*0a6a1f1dSLionel Sambuc 	Dwarf_Off	dbg_info_off;	/* Current info section offset. */
408*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbg_seccnt;	/* Total number of dwarf sections. */
409*0a6a1f1dSLionel Sambuc 	int		dbg_mode;	/* Access mode. */
410*0a6a1f1dSLionel Sambuc 	int		dbg_pointer_size; /* Object address size. */
411*0a6a1f1dSLionel Sambuc 	int		dbg_offset_size;  /* DWARF offset size. */
412*0a6a1f1dSLionel Sambuc 	int		dbg_info_loaded; /* Flag indicating all CU loaded. */
413*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_machine;	/* ELF machine architecture. */
414*0a6a1f1dSLionel Sambuc 	Dwarf_Handler	dbg_errhand;	/* Error handler. */
415*0a6a1f1dSLionel Sambuc 	Dwarf_Ptr	dbg_errarg;	/* Argument to the error handler. */
416*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_CU) dbg_cu;/* List of compilation units. */
417*0a6a1f1dSLionel Sambuc 	Dwarf_CU	dbg_cu_current; /* Ptr to the current CU. */
418*0a6a1f1dSLionel Sambuc 	TAILQ_HEAD(, _Dwarf_Loclist) dbg_loclist; /* List of location list. */
419*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_globals;	/* Ptr to pubnames lookup section. */
420*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_pubtypes;	/* Ptr to pubtypes lookup section. */
421*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_weaks;	/* Ptr to weaknames lookup section. */
422*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_funcs;	/* Ptr to static funcs lookup sect. */
423*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_vars;	/* Ptr to static vars lookup sect. */
424*0a6a1f1dSLionel Sambuc 	Dwarf_NameSec	dbg_types;	/* Ptr to types lookup section. */
425*0a6a1f1dSLionel Sambuc 	Dwarf_FrameSec	dbg_frame;	/* Ptr to .debug_frame section. */
426*0a6a1f1dSLionel Sambuc 	Dwarf_FrameSec	dbg_eh_frame;	/* Ptr to .eh_frame section. */
427*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_ArangeSet) dbg_aslist; /* List of arange set. */
428*0a6a1f1dSLionel Sambuc 	Dwarf_Arange	*dbg_arange_array; /* Array of arange. */
429*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbg_arange_cnt;	/* Length of the arange array. */
430*0a6a1f1dSLionel Sambuc 	char		*dbg_strtab;	/* Dwarf string table. */
431*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbg_strtab_cap; /* Dwarf string table capacity. */
432*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbg_strtab_size; /* Dwarf string table size. */
433*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_MacroSet) dbg_mslist; /* List of macro set. */
434*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Rangelist) dbg_rllist; /* List of rangelist. */
435*0a6a1f1dSLionel Sambuc 	uint64_t	(*read)(uint8_t *, uint64_t *, int);
436*0a6a1f1dSLionel Sambuc 	void		(*write)(uint8_t *, uint64_t *, uint64_t, int);
437*0a6a1f1dSLionel Sambuc 	int		(*write_alloc)(uint8_t **, uint64_t *, uint64_t *,
438*0a6a1f1dSLionel Sambuc 			    uint64_t, int, Dwarf_Error *);
439*0a6a1f1dSLionel Sambuc 	uint64_t	(*decode)(uint8_t **, int);
440*0a6a1f1dSLionel Sambuc 
441*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_frame_rule_table_size;
442*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_frame_rule_initial_value;
443*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_frame_cfa_value;
444*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_frame_same_value;
445*0a6a1f1dSLionel Sambuc 	Dwarf_Half	dbg_frame_undefined_value;
446*0a6a1f1dSLionel Sambuc 
447*0a6a1f1dSLionel Sambuc 	Dwarf_Regtable3	*dbg_internal_reg_table;
448*0a6a1f1dSLionel Sambuc 
449*0a6a1f1dSLionel Sambuc 	/*
450*0a6a1f1dSLionel Sambuc 	 * Fields used by libdwarf producer.
451*0a6a1f1dSLionel Sambuc 	 */
452*0a6a1f1dSLionel Sambuc 
453*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_flags;
454*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_isa;
455*0a6a1f1dSLionel Sambuc 	Dwarf_Callback_Func dbgp_func;
456*0a6a1f1dSLionel Sambuc 	Dwarf_Callback_Func_b dbgp_func_b;
457*0a6a1f1dSLionel Sambuc 	Dwarf_Die	dbgp_root_die;
458*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Die) dbgp_dielist;
459*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_P_Expr) dbgp_pelist;
460*0a6a1f1dSLionel Sambuc 	Dwarf_LineInfo	dbgp_lineinfo;
461*0a6a1f1dSLionel Sambuc 	Dwarf_ArangeSet dbgp_as;
462*0a6a1f1dSLionel Sambuc 	Dwarf_Macro_Details *dbgp_mdlist;
463*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_mdcnt;
464*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Cie) dbgp_cielist;
465*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Fde) dbgp_fdelist;
466*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_cielen;
467*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_fdelen;
468*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	dbgp_pubs;
469*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	dbgp_weaks;
470*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	dbgp_funcs;
471*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	dbgp_types;
472*0a6a1f1dSLionel Sambuc 	Dwarf_NameTbl	dbgp_vars;
473*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_P_Section) dbgp_seclist;
474*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_seccnt;
475*0a6a1f1dSLionel Sambuc 	Dwarf_P_Section	dbgp_secpos;
476*0a6a1f1dSLionel Sambuc 	Dwarf_P_Section	dbgp_info;
477*0a6a1f1dSLionel Sambuc 	STAILQ_HEAD(, _Dwarf_Rel_Section) dbgp_drslist;
478*0a6a1f1dSLionel Sambuc 	Dwarf_Unsigned	dbgp_drscnt;
479*0a6a1f1dSLionel Sambuc 	Dwarf_Rel_Section dbgp_drspos;
480*0a6a1f1dSLionel Sambuc };
481*0a6a1f1dSLionel Sambuc 
482*0a6a1f1dSLionel Sambuc /*
483*0a6a1f1dSLionel Sambuc  * Internal function prototypes.
484*0a6a1f1dSLionel Sambuc  */
485*0a6a1f1dSLionel Sambuc 
486*0a6a1f1dSLionel Sambuc int		_dwarf_abbrev_add(Dwarf_CU, uint64_t, uint64_t, uint8_t,
487*0a6a1f1dSLionel Sambuc 		    uint64_t, Dwarf_Abbrev *, Dwarf_Error *);
488*0a6a1f1dSLionel Sambuc void		_dwarf_abbrev_cleanup(Dwarf_CU);
489*0a6a1f1dSLionel Sambuc int		_dwarf_abbrev_find(Dwarf_CU, uint64_t, Dwarf_Abbrev *,
490*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
491*0a6a1f1dSLionel Sambuc int		_dwarf_abbrev_gen(Dwarf_P_Debug, Dwarf_Error *);
492*0a6a1f1dSLionel Sambuc int		_dwarf_abbrev_parse(Dwarf_Debug, Dwarf_CU, Dwarf_Unsigned *,
493*0a6a1f1dSLionel Sambuc 		    Dwarf_Abbrev *, Dwarf_Error *);
494*0a6a1f1dSLionel Sambuc int		_dwarf_add_AT_dataref(Dwarf_P_Debug, Dwarf_P_Die, Dwarf_Half,
495*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, const char *,
496*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Attribute *, Dwarf_Error *);
497*0a6a1f1dSLionel Sambuc int		_dwarf_add_string_attr(Dwarf_P_Die, Dwarf_P_Attribute *,
498*0a6a1f1dSLionel Sambuc 		    Dwarf_Half, char *, Dwarf_Error *);
499*0a6a1f1dSLionel Sambuc int		_dwarf_alloc(Dwarf_Debug *, int, Dwarf_Error *);
500*0a6a1f1dSLionel Sambuc void		_dwarf_arange_cleanup(Dwarf_Debug);
501*0a6a1f1dSLionel Sambuc int		_dwarf_arange_gen(Dwarf_P_Debug, Dwarf_Error *);
502*0a6a1f1dSLionel Sambuc int		_dwarf_arange_init(Dwarf_Debug, Dwarf_Error *);
503*0a6a1f1dSLionel Sambuc void		_dwarf_arange_pro_cleanup(Dwarf_P_Debug);
504*0a6a1f1dSLionel Sambuc int		_dwarf_attr_alloc(Dwarf_Die, Dwarf_Attribute *, Dwarf_Error *);
505*0a6a1f1dSLionel Sambuc Dwarf_Attribute	_dwarf_attr_find(Dwarf_Die, Dwarf_Half);
506*0a6a1f1dSLionel Sambuc int		_dwarf_attr_gen(Dwarf_P_Debug, Dwarf_P_Section, Dwarf_Rel_Section,
507*0a6a1f1dSLionel Sambuc 		    Dwarf_CU, Dwarf_Die, int, Dwarf_Error *);
508*0a6a1f1dSLionel Sambuc int		_dwarf_attr_init(Dwarf_Debug, Dwarf_Section *, uint64_t *, int,
509*0a6a1f1dSLionel Sambuc 		    Dwarf_CU, Dwarf_Die, Dwarf_AttrDef, uint64_t, int,
510*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
511*0a6a1f1dSLionel Sambuc int		_dwarf_attrdef_add(Dwarf_Debug, Dwarf_Abbrev, uint64_t,
512*0a6a1f1dSLionel Sambuc 		    uint64_t, uint64_t, Dwarf_AttrDef *, Dwarf_Error *);
513*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_decode_lsb(uint8_t **, int);
514*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_decode_msb(uint8_t **, int);
515*0a6a1f1dSLionel Sambuc int64_t		_dwarf_decode_sleb128(uint8_t **);
516*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_decode_uleb128(uint8_t **);
517*0a6a1f1dSLionel Sambuc void		_dwarf_deinit(Dwarf_Debug);
518*0a6a1f1dSLionel Sambuc int		_dwarf_die_alloc(Dwarf_Debug, Dwarf_Die *, Dwarf_Error *);
519*0a6a1f1dSLionel Sambuc int		_dwarf_die_count_links(Dwarf_P_Die, Dwarf_P_Die,
520*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Die, Dwarf_P_Die);
521*0a6a1f1dSLionel Sambuc Dwarf_Die	_dwarf_die_find(Dwarf_Die, Dwarf_Unsigned);
522*0a6a1f1dSLionel Sambuc int		_dwarf_die_gen(Dwarf_P_Debug, Dwarf_CU, Dwarf_Rel_Section,
523*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
524*0a6a1f1dSLionel Sambuc void		_dwarf_die_link(Dwarf_P_Die, Dwarf_P_Die, Dwarf_P_Die,
525*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Die, Dwarf_P_Die);
526*0a6a1f1dSLionel Sambuc int		_dwarf_die_parse(Dwarf_Debug, Dwarf_Section *, Dwarf_CU, int,
527*0a6a1f1dSLionel Sambuc 		    uint64_t, uint64_t, Dwarf_Die *, int, Dwarf_Error *);
528*0a6a1f1dSLionel Sambuc void		_dwarf_die_pro_cleanup(Dwarf_P_Debug);
529*0a6a1f1dSLionel Sambuc void		_dwarf_elf_deinit(Dwarf_Debug);
530*0a6a1f1dSLionel Sambuc int		_dwarf_elf_init(Dwarf_Debug, Elf *, Dwarf_Error *);
531*0a6a1f1dSLionel Sambuc int		_dwarf_elf_load_section(void *, Dwarf_Half, Dwarf_Small **,
532*0a6a1f1dSLionel Sambuc 		    int *);
533*0a6a1f1dSLionel Sambuc Dwarf_Endianness _dwarf_elf_get_byte_order(void *);
534*0a6a1f1dSLionel Sambuc Dwarf_Small	_dwarf_elf_get_length_size(void *);
535*0a6a1f1dSLionel Sambuc Dwarf_Small	_dwarf_elf_get_pointer_size(void *);
536*0a6a1f1dSLionel Sambuc Dwarf_Unsigned	_dwarf_elf_get_section_count(void *);
537*0a6a1f1dSLionel Sambuc int		_dwarf_elf_get_section_info(void *, Dwarf_Half,
538*0a6a1f1dSLionel Sambuc 		    Dwarf_Obj_Access_Section *, int *);
539*0a6a1f1dSLionel Sambuc void		_dwarf_expr_cleanup(Dwarf_P_Debug);
540*0a6a1f1dSLionel Sambuc int		_dwarf_expr_into_block(Dwarf_P_Expr, Dwarf_Error *);
541*0a6a1f1dSLionel Sambuc Dwarf_Section	*_dwarf_find_section(Dwarf_Debug, const char *);
542*0a6a1f1dSLionel Sambuc void		_dwarf_frame_cleanup(Dwarf_Debug);
543*0a6a1f1dSLionel Sambuc int		_dwarf_frame_fde_add_inst(Dwarf_P_Fde, Dwarf_Small,
544*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Error *);
545*0a6a1f1dSLionel Sambuc int		_dwarf_frame_gen(Dwarf_P_Debug, Dwarf_Error *);
546*0a6a1f1dSLionel Sambuc int		_dwarf_frame_get_fop(Dwarf_Debug, uint8_t *, Dwarf_Unsigned,
547*0a6a1f1dSLionel Sambuc 		    Dwarf_Frame_Op **, Dwarf_Signed *, Dwarf_Error *);
548*0a6a1f1dSLionel Sambuc int		_dwarf_frame_get_internal_table(Dwarf_Fde, Dwarf_Addr,
549*0a6a1f1dSLionel Sambuc 		    Dwarf_Regtable3 **, Dwarf_Addr *, Dwarf_Error *);
550*0a6a1f1dSLionel Sambuc int		_dwarf_frame_interal_table_init(Dwarf_Debug, Dwarf_Error *);
551*0a6a1f1dSLionel Sambuc void		_dwarf_frame_params_init(Dwarf_Debug);
552*0a6a1f1dSLionel Sambuc void		_dwarf_frame_pro_cleanup(Dwarf_P_Debug);
553*0a6a1f1dSLionel Sambuc int		_dwarf_frame_regtable_copy(Dwarf_Debug, Dwarf_Regtable3 **,
554*0a6a1f1dSLionel Sambuc 		    Dwarf_Regtable3 *, Dwarf_Error *);
555*0a6a1f1dSLionel Sambuc int		_dwarf_frame_section_load(Dwarf_Debug, Dwarf_Error *);
556*0a6a1f1dSLionel Sambuc int		_dwarf_frame_section_load_eh(Dwarf_Debug, Dwarf_Error *);
557*0a6a1f1dSLionel Sambuc int		_dwarf_generate_sections(Dwarf_P_Debug, Dwarf_Error *);
558*0a6a1f1dSLionel Sambuc Dwarf_Unsigned	_dwarf_get_reloc_type(Dwarf_P_Debug, int);
559*0a6a1f1dSLionel Sambuc int		_dwarf_get_reloc_size(Dwarf_Debug, Dwarf_Unsigned);
560*0a6a1f1dSLionel Sambuc void		_dwarf_info_cleanup(Dwarf_Debug);
561*0a6a1f1dSLionel Sambuc int		_dwarf_info_first_cu(Dwarf_Debug, Dwarf_Error *);
562*0a6a1f1dSLionel Sambuc int		_dwarf_info_gen(Dwarf_P_Debug, Dwarf_Error *);
563*0a6a1f1dSLionel Sambuc int		_dwarf_info_load(Dwarf_Debug, int, Dwarf_Error *);
564*0a6a1f1dSLionel Sambuc int		_dwarf_info_next_cu(Dwarf_Debug, Dwarf_Error *);
565*0a6a1f1dSLionel Sambuc void		_dwarf_info_pro_cleanup(Dwarf_P_Debug);
566*0a6a1f1dSLionel Sambuc int		_dwarf_init(Dwarf_Debug, Dwarf_Unsigned, Dwarf_Handler,
567*0a6a1f1dSLionel Sambuc 		    Dwarf_Ptr, Dwarf_Error *);
568*0a6a1f1dSLionel Sambuc int		_dwarf_lineno_gen(Dwarf_P_Debug, Dwarf_Error *);
569*0a6a1f1dSLionel Sambuc int		_dwarf_lineno_init(Dwarf_Die, uint64_t, Dwarf_Error *);
570*0a6a1f1dSLionel Sambuc void		_dwarf_lineno_cleanup(Dwarf_LineInfo);
571*0a6a1f1dSLionel Sambuc void		_dwarf_lineno_pro_cleanup(Dwarf_P_Debug);
572*0a6a1f1dSLionel Sambuc int		_dwarf_loc_fill_locdesc(Dwarf_Debug, Dwarf_Locdesc *, uint8_t *,
573*0a6a1f1dSLionel Sambuc 		    uint64_t, uint8_t, Dwarf_Error *);
574*0a6a1f1dSLionel Sambuc int		_dwarf_loc_fill_locexpr(Dwarf_Debug, Dwarf_Locdesc **,
575*0a6a1f1dSLionel Sambuc 		    uint8_t *, uint64_t, uint8_t, Dwarf_Error *);
576*0a6a1f1dSLionel Sambuc int		_dwarf_loc_add(Dwarf_Die, Dwarf_Attribute, Dwarf_Error *);
577*0a6a1f1dSLionel Sambuc int		_dwarf_loc_expr_add_atom(Dwarf_Debug, uint8_t *, uint8_t *,
578*0a6a1f1dSLionel Sambuc 		    Dwarf_Small, Dwarf_Unsigned, Dwarf_Unsigned, int *,
579*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
580*0a6a1f1dSLionel Sambuc int		_dwarf_loclist_find(Dwarf_Debug, Dwarf_CU, uint64_t,
581*0a6a1f1dSLionel Sambuc 		    Dwarf_Loclist *, Dwarf_Error *);
582*0a6a1f1dSLionel Sambuc void		_dwarf_loclist_cleanup(Dwarf_Debug);
583*0a6a1f1dSLionel Sambuc void		_dwarf_loclist_free(Dwarf_Loclist);
584*0a6a1f1dSLionel Sambuc int		_dwarf_loclist_add(Dwarf_Debug, Dwarf_CU, uint64_t,
585*0a6a1f1dSLionel Sambuc 		    Dwarf_Loclist *, Dwarf_Error *);
586*0a6a1f1dSLionel Sambuc void		_dwarf_macinfo_cleanup(Dwarf_Debug);
587*0a6a1f1dSLionel Sambuc int		_dwarf_macinfo_gen(Dwarf_P_Debug, Dwarf_Error *);
588*0a6a1f1dSLionel Sambuc int		_dwarf_macinfo_init(Dwarf_Debug, Dwarf_Error *);
589*0a6a1f1dSLionel Sambuc void		_dwarf_macinfo_pro_cleanup(Dwarf_P_Debug);
590*0a6a1f1dSLionel Sambuc int		_dwarf_nametbl_init(Dwarf_Debug, Dwarf_NameSec *,
591*0a6a1f1dSLionel Sambuc 		    Dwarf_Section *, Dwarf_Error *);
592*0a6a1f1dSLionel Sambuc void		_dwarf_nametbl_cleanup(Dwarf_NameSec *);
593*0a6a1f1dSLionel Sambuc int		_dwarf_nametbl_gen(Dwarf_P_Debug, const char *, Dwarf_NameTbl,
594*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
595*0a6a1f1dSLionel Sambuc void		_dwarf_nametbl_pro_cleanup(Dwarf_NameTbl *);
596*0a6a1f1dSLionel Sambuc int		_dwarf_pro_callback(Dwarf_P_Debug, char *, int, Dwarf_Unsigned,
597*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
598*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned *, int *);
599*0a6a1f1dSLionel Sambuc Dwarf_P_Section	_dwarf_pro_find_section(Dwarf_P_Debug, const char *);
600*0a6a1f1dSLionel Sambuc int		_dwarf_ranges_add(Dwarf_Debug, Dwarf_CU, uint64_t,
601*0a6a1f1dSLionel Sambuc 		    Dwarf_Rangelist *, Dwarf_Error *);
602*0a6a1f1dSLionel Sambuc void		_dwarf_ranges_cleanup(Dwarf_Debug);
603*0a6a1f1dSLionel Sambuc int		_dwarf_ranges_find(Dwarf_Debug, uint64_t, Dwarf_Rangelist *);
604*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_read_lsb(uint8_t *, uint64_t *, int);
605*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_read_msb(uint8_t *, uint64_t *, int);
606*0a6a1f1dSLionel Sambuc int64_t		_dwarf_read_sleb128(uint8_t *, uint64_t *);
607*0a6a1f1dSLionel Sambuc uint64_t	_dwarf_read_uleb128(uint8_t *, uint64_t *);
608*0a6a1f1dSLionel Sambuc char		*_dwarf_read_string(void *, Dwarf_Unsigned, uint64_t *);
609*0a6a1f1dSLionel Sambuc uint8_t		*_dwarf_read_block(void *, uint64_t *, uint64_t);
610*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_section_finalize(Dwarf_P_Debug, Dwarf_Rel_Section,
611*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
612*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_entry_add(Dwarf_P_Debug, Dwarf_Rel_Section,
613*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Section, unsigned char, unsigned char,
614*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
615*0a6a1f1dSLionel Sambuc 		    const char *, Dwarf_Error *);
616*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_entry_add_pair(Dwarf_P_Debug, Dwarf_Rel_Section,
617*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Section, unsigned char, Dwarf_Unsigned,
618*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
619*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Error *);
620*0a6a1f1dSLionel Sambuc void		_dwarf_reloc_cleanup(Dwarf_P_Debug);
621*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_gen(Dwarf_P_Debug, Dwarf_Error *);
622*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_section_gen(Dwarf_P_Debug, Dwarf_Rel_Section,
623*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
624*0a6a1f1dSLionel Sambuc int		_dwarf_reloc_section_init(Dwarf_P_Debug, Dwarf_Rel_Section *,
625*0a6a1f1dSLionel Sambuc 		    Dwarf_P_Section, Dwarf_Error *);
626*0a6a1f1dSLionel Sambuc void		_dwarf_reloc_section_free(Dwarf_P_Debug, Dwarf_Rel_Section *);
627*0a6a1f1dSLionel Sambuc void		_dwarf_section_cleanup(Dwarf_P_Debug);
628*0a6a1f1dSLionel Sambuc int		_dwarf_section_callback(Dwarf_P_Debug, Dwarf_P_Section,
629*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Unsigned, Dwarf_Unsigned,
630*0a6a1f1dSLionel Sambuc 		    Dwarf_Unsigned, Dwarf_Error *);
631*0a6a1f1dSLionel Sambuc void		_dwarf_section_free(Dwarf_P_Debug, Dwarf_P_Section *);
632*0a6a1f1dSLionel Sambuc int		_dwarf_section_init(Dwarf_P_Debug, Dwarf_P_Section *,
633*0a6a1f1dSLionel Sambuc 		    const char *, int, Dwarf_Error *);
634*0a6a1f1dSLionel Sambuc void		_dwarf_set_error(Dwarf_Debug, Dwarf_Error *, int, int,
635*0a6a1f1dSLionel Sambuc 		    const char *, int);
636*0a6a1f1dSLionel Sambuc int		_dwarf_strtab_add(Dwarf_Debug, char *, uint64_t *,
637*0a6a1f1dSLionel Sambuc 		    Dwarf_Error *);
638*0a6a1f1dSLionel Sambuc void		_dwarf_strtab_cleanup(Dwarf_Debug);
639*0a6a1f1dSLionel Sambuc int		_dwarf_strtab_gen(Dwarf_P_Debug, Dwarf_Error *);
640*0a6a1f1dSLionel Sambuc char		*_dwarf_strtab_get_table(Dwarf_Debug);
641*0a6a1f1dSLionel Sambuc int		_dwarf_strtab_init(Dwarf_Debug, Dwarf_Error *);
642*0a6a1f1dSLionel Sambuc void		_dwarf_write_block(void *, uint64_t *, uint8_t *, uint64_t);
643*0a6a1f1dSLionel Sambuc int		_dwarf_write_block_alloc(uint8_t **, uint64_t *, uint64_t *,
644*0a6a1f1dSLionel Sambuc 		    uint8_t *, uint64_t, Dwarf_Error *);
645*0a6a1f1dSLionel Sambuc void		_dwarf_write_lsb(uint8_t *, uint64_t *, uint64_t, int);
646*0a6a1f1dSLionel Sambuc int		_dwarf_write_lsb_alloc(uint8_t **, uint64_t *, uint64_t *,
647*0a6a1f1dSLionel Sambuc 		    uint64_t, int, Dwarf_Error *);
648*0a6a1f1dSLionel Sambuc void		_dwarf_write_msb(uint8_t *, uint64_t *, uint64_t, int);
649*0a6a1f1dSLionel Sambuc int		_dwarf_write_msb_alloc(uint8_t **, uint64_t *, uint64_t *,
650*0a6a1f1dSLionel Sambuc 		    uint64_t, int, Dwarf_Error *);
651*0a6a1f1dSLionel Sambuc void		_dwarf_write_padding(void *, uint64_t *, uint8_t, uint64_t);
652*0a6a1f1dSLionel Sambuc int		_dwarf_write_padding_alloc(uint8_t **, uint64_t *, uint64_t *,
653*0a6a1f1dSLionel Sambuc 		    uint8_t, uint64_t, Dwarf_Error *);
654*0a6a1f1dSLionel Sambuc void		_dwarf_write_string(void *, uint64_t *, char *);
655*0a6a1f1dSLionel Sambuc int		_dwarf_write_string_alloc(uint8_t **, uint64_t *, uint64_t *,
656*0a6a1f1dSLionel Sambuc 		    char *, Dwarf_Error *);
657*0a6a1f1dSLionel Sambuc int		_dwarf_write_sleb128(uint8_t *, uint8_t *, int64_t);
658*0a6a1f1dSLionel Sambuc int		_dwarf_write_sleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
659*0a6a1f1dSLionel Sambuc 		    int64_t, Dwarf_Error *);
660*0a6a1f1dSLionel Sambuc int		_dwarf_write_uleb128(uint8_t *, uint8_t *, uint64_t);
661*0a6a1f1dSLionel Sambuc int		_dwarf_write_uleb128_alloc(uint8_t **, uint64_t *, uint64_t *,
662*0a6a1f1dSLionel Sambuc 		    uint64_t, Dwarf_Error *);
663*0a6a1f1dSLionel Sambuc 
664*0a6a1f1dSLionel Sambuc #endif /* !__LIBDWARF_H_ */
665