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