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