10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51882Sjohnlev * Common Development and Distribution License (the "License"). 61882Sjohnlev * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 221882Sjohnlev * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _CTFTOOLS_H 270Sstevel@tonic-gate #define _CTFTOOLS_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * Functions and data structures used in the manipulation of stabs and CTF data 330Sstevel@tonic-gate */ 340Sstevel@tonic-gate 350Sstevel@tonic-gate #include <stdio.h> 360Sstevel@tonic-gate #include <stdlib.h> 370Sstevel@tonic-gate #include <stdarg.h> 380Sstevel@tonic-gate #include <libelf.h> 390Sstevel@tonic-gate #include <gelf.h> 400Sstevel@tonic-gate #include <pthread.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #ifdef __cplusplus 430Sstevel@tonic-gate extern "C" { 440Sstevel@tonic-gate #endif 450Sstevel@tonic-gate 460Sstevel@tonic-gate #include "list.h" 470Sstevel@tonic-gate #include "hash.h" 480Sstevel@tonic-gate 490Sstevel@tonic-gate #ifndef DEBUG_LEVEL 500Sstevel@tonic-gate #define DEBUG_LEVEL 0 510Sstevel@tonic-gate #endif 520Sstevel@tonic-gate #ifndef DEBUG_PARSE 530Sstevel@tonic-gate #define DEBUG_PARSE 0 540Sstevel@tonic-gate #endif 550Sstevel@tonic-gate 560Sstevel@tonic-gate #ifndef DEBUG_STREAM 570Sstevel@tonic-gate #define DEBUG_STREAM stderr 580Sstevel@tonic-gate #endif 590Sstevel@tonic-gate 600Sstevel@tonic-gate #ifndef MAX 610Sstevel@tonic-gate #define MAX(a, b) ((a) < (b) ? (b) : (a)) 620Sstevel@tonic-gate #endif 630Sstevel@tonic-gate 640Sstevel@tonic-gate #ifndef MIN 650Sstevel@tonic-gate #define MIN(a, b) ((a) > (b) ? (b) : (a)) 660Sstevel@tonic-gate #endif 670Sstevel@tonic-gate 680Sstevel@tonic-gate #define TRUE 1 690Sstevel@tonic-gate #define FALSE 0 700Sstevel@tonic-gate 710Sstevel@tonic-gate #define CTF_ELF_SCN_NAME ".SUNW_ctf" 720Sstevel@tonic-gate 730Sstevel@tonic-gate #define CTF_LABEL_LASTIDX -1 740Sstevel@tonic-gate 750Sstevel@tonic-gate #define CTF_DEFAULT_LABEL "*** No Label Provided ***" 760Sstevel@tonic-gate 770Sstevel@tonic-gate /* 780Sstevel@tonic-gate * Default hash sizes 790Sstevel@tonic-gate */ 800Sstevel@tonic-gate #define TDATA_LAYOUT_HASH_SIZE 8191 /* A tdesc hash based on layout */ 810Sstevel@tonic-gate #define TDATA_ID_HASH_SIZE 997 /* A tdesc hash based on type id */ 820Sstevel@tonic-gate #define IIDESC_HASH_SIZE 8191 /* Hash of iidesc's */ 830Sstevel@tonic-gate 840Sstevel@tonic-gate /* 850Sstevel@tonic-gate * The default function argument array size. We'll realloc the array larger 860Sstevel@tonic-gate * if we need to, but we want a default value that will allow us to avoid 870Sstevel@tonic-gate * reallocation in the common case. 880Sstevel@tonic-gate */ 890Sstevel@tonic-gate #define FUNCARG_DEF 5 900Sstevel@tonic-gate 910Sstevel@tonic-gate extern const char *progname; 920Sstevel@tonic-gate extern int debug_level; 930Sstevel@tonic-gate extern int debug_parse; 940Sstevel@tonic-gate extern const char *curhdr; 950Sstevel@tonic-gate 960Sstevel@tonic-gate /* 970Sstevel@tonic-gate * This is a partial copy of the stab.h that DevPro includes with their 980Sstevel@tonic-gate * compiler. 990Sstevel@tonic-gate */ 1000Sstevel@tonic-gate typedef struct stab { 1010Sstevel@tonic-gate uint32_t n_strx; 1020Sstevel@tonic-gate uint8_t n_type; 1030Sstevel@tonic-gate int8_t n_other; 1040Sstevel@tonic-gate int16_t n_desc; 1050Sstevel@tonic-gate uint32_t n_value; 1060Sstevel@tonic-gate } stab_t; 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ 1090Sstevel@tonic-gate #define N_FUN 0x24 /* procedure: name,,0,linenumber,0 */ 1100Sstevel@tonic-gate #define N_STSYM 0x26 /* static symbol: name,,0,type,0 or section relative */ 1110Sstevel@tonic-gate #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,0 or section relative */ 1120Sstevel@tonic-gate #define N_ROSYM 0x2c /* ro_data: name,,0,type,0 or section relative */ 1130Sstevel@tonic-gate #define N_OPT 0x3c /* compiler options */ 1140Sstevel@tonic-gate #define N_RSYM 0x40 /* register sym: name,,0,type,register */ 1150Sstevel@tonic-gate #define N_SO 0x64 /* source file name: name,,0,0,0 */ 1160Sstevel@tonic-gate #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ 1170Sstevel@tonic-gate #define N_SOL 0x84 /* #included file name: name,,0,0,0 */ 1180Sstevel@tonic-gate #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ 1190Sstevel@tonic-gate #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,function relative */ 1200Sstevel@tonic-gate #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,func relative */ 1210Sstevel@tonic-gate #define N_BINCL 0x82 /* header file: name,,0,0,0 */ 1220Sstevel@tonic-gate #define N_EINCL 0xa2 /* end of include file */ 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate /* 1250Sstevel@tonic-gate * Nodes in the type tree 1260Sstevel@tonic-gate * 1270Sstevel@tonic-gate * Each node consists of a single tdesc_t, with one of several auxiliary 1280Sstevel@tonic-gate * structures linked in via the `data' union. 1290Sstevel@tonic-gate */ 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate /* The type of tdesc_t node */ 1320Sstevel@tonic-gate typedef enum stabtype { 1330Sstevel@tonic-gate STABTYPE_FIRST, /* do not use */ 1340Sstevel@tonic-gate INTRINSIC, 1350Sstevel@tonic-gate POINTER, 1360Sstevel@tonic-gate ARRAY, 1370Sstevel@tonic-gate FUNCTION, 1380Sstevel@tonic-gate STRUCT, 1390Sstevel@tonic-gate UNION, 1400Sstevel@tonic-gate ENUM, 1410Sstevel@tonic-gate FORWARD, 1420Sstevel@tonic-gate TYPEDEF, 1430Sstevel@tonic-gate TYPEDEF_UNRES, 1440Sstevel@tonic-gate VOLATILE, 1450Sstevel@tonic-gate CONST, 1460Sstevel@tonic-gate RESTRICT, 1470Sstevel@tonic-gate STABTYPE_LAST /* do not use */ 1480Sstevel@tonic-gate } stabtype_t; 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate typedef struct tdesc tdesc_t; 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate /* Auxiliary structure for array tdesc_t */ 1530Sstevel@tonic-gate typedef struct ardef { 1540Sstevel@tonic-gate tdesc_t *ad_contents; 1550Sstevel@tonic-gate tdesc_t *ad_idxtype; 1560Sstevel@tonic-gate uint_t ad_nelems; 1570Sstevel@tonic-gate } ardef_t; 1580Sstevel@tonic-gate 1590Sstevel@tonic-gate /* Auxiliary structure for structure/union tdesc_t */ 1600Sstevel@tonic-gate typedef struct mlist { 1610Sstevel@tonic-gate int ml_offset; /* Offset from start of structure (in bits) */ 1620Sstevel@tonic-gate int ml_size; /* Member size (in bits) */ 1630Sstevel@tonic-gate char *ml_name; /* Member name */ 1640Sstevel@tonic-gate struct tdesc *ml_type; /* Member type */ 1650Sstevel@tonic-gate struct mlist *ml_next; /* Next member */ 1660Sstevel@tonic-gate } mlist_t; 1670Sstevel@tonic-gate 1680Sstevel@tonic-gate /* Auxiliary structure for enum tdesc_t */ 1690Sstevel@tonic-gate typedef struct elist { 1700Sstevel@tonic-gate char *el_name; 1710Sstevel@tonic-gate int el_number; 1720Sstevel@tonic-gate struct elist *el_next; 1730Sstevel@tonic-gate } elist_t; 1740Sstevel@tonic-gate 1750Sstevel@tonic-gate /* Auxiliary structure for intrinsics (integers and reals) */ 1760Sstevel@tonic-gate typedef enum { 1770Sstevel@tonic-gate INTR_INT, 1780Sstevel@tonic-gate INTR_REAL 1790Sstevel@tonic-gate } intrtype_t; 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate typedef struct intr { 1820Sstevel@tonic-gate intrtype_t intr_type; 1830Sstevel@tonic-gate int intr_signed; 1840Sstevel@tonic-gate union { 1850Sstevel@tonic-gate char _iformat; 1860Sstevel@tonic-gate int _fformat; 1870Sstevel@tonic-gate } _u; 1880Sstevel@tonic-gate int intr_offset; 1890Sstevel@tonic-gate int intr_nbits; 1900Sstevel@tonic-gate } intr_t; 1910Sstevel@tonic-gate 1920Sstevel@tonic-gate #define intr_iformat _u._iformat 1930Sstevel@tonic-gate #define intr_fformat _u._fformat 1940Sstevel@tonic-gate 1950Sstevel@tonic-gate typedef struct fnarg { 1960Sstevel@tonic-gate char *fna_name; 1970Sstevel@tonic-gate struct tdesc *fna_type; 1980Sstevel@tonic-gate } fnarg_t; 1990Sstevel@tonic-gate 2000Sstevel@tonic-gate #define FN_F_GLOBAL 0x1 2010Sstevel@tonic-gate #define FN_F_VARARGS 0x2 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate typedef struct fndef { 2040Sstevel@tonic-gate struct tdesc *fn_ret; 2050Sstevel@tonic-gate uint_t fn_nargs; 2060Sstevel@tonic-gate tdesc_t **fn_args; 2070Sstevel@tonic-gate uint_t fn_vargs; 2080Sstevel@tonic-gate } fndef_t; 2090Sstevel@tonic-gate 2100Sstevel@tonic-gate typedef int32_t tid_t; 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* 2130Sstevel@tonic-gate * The tdesc_t (Type DESCription) is the basic node type used in the stabs data 2140Sstevel@tonic-gate * structure. Each data node gets a tdesc structure. Each node is linked into 2150Sstevel@tonic-gate * a directed graph (think of it as a tree with multiple roots and multiple 2160Sstevel@tonic-gate * leaves), with the root nodes at the top, and intrinsics at the bottom. The 2170Sstevel@tonic-gate * root nodes, which are pointed to by iidesc nodes, correspond to the types, 2180Sstevel@tonic-gate * globals, and statics defined by the stabs. 2190Sstevel@tonic-gate */ 2200Sstevel@tonic-gate struct tdesc { 2210Sstevel@tonic-gate char *t_name; 2220Sstevel@tonic-gate tdesc_t *t_next; /* Name hash next pointer */ 2230Sstevel@tonic-gate 2240Sstevel@tonic-gate tid_t t_id; 2250Sstevel@tonic-gate tdesc_t *t_hash; /* ID hash next pointer */ 2260Sstevel@tonic-gate 2270Sstevel@tonic-gate stabtype_t t_type; 2280Sstevel@tonic-gate int t_size; /* Size in bytes of object represented by this node */ 2290Sstevel@tonic-gate 2300Sstevel@tonic-gate union { 2310Sstevel@tonic-gate intr_t *intr; /* int, real */ 2320Sstevel@tonic-gate tdesc_t *tdesc; /* ptr, typedef, vol, const, restr */ 2330Sstevel@tonic-gate ardef_t *ardef; /* array */ 2340Sstevel@tonic-gate mlist_t *members; /* struct, union */ 2350Sstevel@tonic-gate elist_t *emem; /* enum */ 2360Sstevel@tonic-gate fndef_t *fndef; /* function - first is return type */ 2370Sstevel@tonic-gate } t_data; 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate int t_flags; 2400Sstevel@tonic-gate int t_vgen; /* Visitation generation (see traverse.c) */ 2410Sstevel@tonic-gate int t_emark; /* Equality mark (see equiv_cb() in merge.c) */ 2420Sstevel@tonic-gate }; 2430Sstevel@tonic-gate 2440Sstevel@tonic-gate #define t_intr t_data.intr 2450Sstevel@tonic-gate #define t_tdesc t_data.tdesc 2460Sstevel@tonic-gate #define t_ardef t_data.ardef 2470Sstevel@tonic-gate #define t_members t_data.members 2480Sstevel@tonic-gate #define t_emem t_data.emem 2490Sstevel@tonic-gate #define t_fndef t_data.fndef 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate #define TDESC_F_ISROOT 0x1 /* Has an iidesc_t (see below) */ 2520Sstevel@tonic-gate #define TDESC_F_GLOBAL 0x2 2530Sstevel@tonic-gate #define TDESC_F_RESOLVED 0x4 2540Sstevel@tonic-gate 2550Sstevel@tonic-gate /* 2560Sstevel@tonic-gate * iidesc_t (Interesting Item DESCription) nodes point to tdesc_t nodes that 2570Sstevel@tonic-gate * correspond to "interesting" stabs. A stab is interesting if it defines a 2580Sstevel@tonic-gate * global or static variable, a global or static function, or a data type. 2590Sstevel@tonic-gate */ 2600Sstevel@tonic-gate typedef enum iitype { 2610Sstevel@tonic-gate II_NOT = 0, 2620Sstevel@tonic-gate II_GFUN, /* Global function */ 2630Sstevel@tonic-gate II_SFUN, /* Static function */ 2640Sstevel@tonic-gate II_GVAR, /* Global variable */ 2650Sstevel@tonic-gate II_SVAR, /* Static variable */ 2660Sstevel@tonic-gate II_PSYM, /* Function argument */ 2670Sstevel@tonic-gate II_SOU, /* Struct or union */ 2680Sstevel@tonic-gate II_TYPE /* Type (typedef) */ 2690Sstevel@tonic-gate } iitype_t; 2700Sstevel@tonic-gate 2710Sstevel@tonic-gate typedef struct iidesc { 2720Sstevel@tonic-gate iitype_t ii_type; 2730Sstevel@tonic-gate char *ii_name; 2740Sstevel@tonic-gate tdesc_t *ii_dtype; 2750Sstevel@tonic-gate char *ii_owner; /* File that defined this node */ 2760Sstevel@tonic-gate int ii_flags; 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate /* Function arguments (if any) */ 2790Sstevel@tonic-gate int ii_nargs; 2800Sstevel@tonic-gate tdesc_t **ii_args; 2810Sstevel@tonic-gate int ii_vargs; /* Function uses varargs */ 2820Sstevel@tonic-gate } iidesc_t; 2830Sstevel@tonic-gate 2840Sstevel@tonic-gate #define IIDESC_F_USED 0x1 /* Write this iidesc out */ 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate /* 2870Sstevel@tonic-gate * labelent_t nodes identify labels and corresponding type ranges associated 2880Sstevel@tonic-gate * with them. The label in a given labelent_t is associated with types with 2890Sstevel@tonic-gate * ids <= le_idx. 2900Sstevel@tonic-gate */ 2910Sstevel@tonic-gate typedef struct labelent { 2920Sstevel@tonic-gate char *le_name; 2930Sstevel@tonic-gate int le_idx; 2940Sstevel@tonic-gate } labelent_t; 2950Sstevel@tonic-gate 2960Sstevel@tonic-gate /* 2970Sstevel@tonic-gate * The tdata_t (Type DATA) structure contains or references all type data for 2980Sstevel@tonic-gate * a given file or, during merging, several files. 2990Sstevel@tonic-gate */ 3000Sstevel@tonic-gate typedef struct tdata { 3010Sstevel@tonic-gate int td_curemark; /* Equality mark (see merge.c) */ 3020Sstevel@tonic-gate int td_curvgen; /* Visitation generation (see traverse.c) */ 3030Sstevel@tonic-gate int td_nextid; /* The ID for the next tdesc_t created */ 3040Sstevel@tonic-gate hash_t *td_iihash; /* The iidesc_t nodes for this file */ 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate hash_t *td_layouthash; /* The tdesc nodes, hashed by structure */ 3070Sstevel@tonic-gate hash_t *td_idhash; /* The tdesc nodes, hashed by type id */ 3080Sstevel@tonic-gate list_t *td_fwdlist; /* All forward declaration tdesc nodes */ 3090Sstevel@tonic-gate 3100Sstevel@tonic-gate char *td_parlabel; /* Top label uniq'd against in parent */ 3110Sstevel@tonic-gate char *td_parname; /* Basename of parent */ 3120Sstevel@tonic-gate list_t *td_labels; /* Labels and their type ranges */ 3130Sstevel@tonic-gate 3140Sstevel@tonic-gate pthread_mutex_t td_mergelock; 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate int td_ref; 3170Sstevel@tonic-gate } tdata_t; 3180Sstevel@tonic-gate 3190Sstevel@tonic-gate /* 3200Sstevel@tonic-gate * By design, the iidesc hash is heterogeneous. The CTF emitter, on the 3210Sstevel@tonic-gate * other hand, needs to be able to access the elements of the list by type, 3220Sstevel@tonic-gate * and in a specific sorted order. An iiburst holds these elements in that 3230Sstevel@tonic-gate * order. (A burster is a machine that separates carbon-copy forms) 3240Sstevel@tonic-gate */ 3250Sstevel@tonic-gate typedef struct iiburst { 3260Sstevel@tonic-gate int iib_nfuncs; 3270Sstevel@tonic-gate int iib_curfunc; 3280Sstevel@tonic-gate iidesc_t **iib_funcs; 3290Sstevel@tonic-gate 3300Sstevel@tonic-gate int iib_nobjts; 3310Sstevel@tonic-gate int iib_curobjt; 3320Sstevel@tonic-gate iidesc_t **iib_objts; 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate list_t *iib_types; 3350Sstevel@tonic-gate int iib_maxtypeid; 3360Sstevel@tonic-gate 3370Sstevel@tonic-gate tdata_t *iib_td; 3380Sstevel@tonic-gate struct tdtrav_data *iib_tdtd; /* tdtrav_data_t */ 3390Sstevel@tonic-gate } iiburst_t; 3400Sstevel@tonic-gate 3410Sstevel@tonic-gate typedef struct ctf_buf ctf_buf_t; 3420Sstevel@tonic-gate 3430Sstevel@tonic-gate typedef struct symit_data symit_data_t; 3440Sstevel@tonic-gate 345*2722Sjohnlev /* fixup_tdescs.c */ 346*2722Sjohnlev void cvt_fixstabs(tdata_t *); 347*2722Sjohnlev void cvt_fixups(tdata_t *, size_t); 3480Sstevel@tonic-gate 3490Sstevel@tonic-gate /* ctf.c */ 3500Sstevel@tonic-gate caddr_t ctf_gen(iiburst_t *, size_t *, int); 3510Sstevel@tonic-gate tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *); 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate /* iidesc.c */ 3540Sstevel@tonic-gate iidesc_t *iidesc_new(char *); 3550Sstevel@tonic-gate int iidesc_hash(int, void *); 356*2722Sjohnlev void iter_iidescs_by_name(tdata_t *, const char *, 357*2722Sjohnlev int (*)(iidesc_t *, void *), void *); 3580Sstevel@tonic-gate iidesc_t *iidesc_dup(iidesc_t *); 3590Sstevel@tonic-gate iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *); 3600Sstevel@tonic-gate void iidesc_add(hash_t *, iidesc_t *); 3610Sstevel@tonic-gate void iidesc_free(iidesc_t *, void *); 3620Sstevel@tonic-gate int iidesc_count_type(void *, void *); 3630Sstevel@tonic-gate void iidesc_stats(hash_t *); 3640Sstevel@tonic-gate int iidesc_dump(iidesc_t *); 3650Sstevel@tonic-gate 3660Sstevel@tonic-gate /* input.c */ 3670Sstevel@tonic-gate typedef enum source_types { 3680Sstevel@tonic-gate SOURCE_NONE = 0, 3690Sstevel@tonic-gate SOURCE_UNKNOWN = 1, 3700Sstevel@tonic-gate SOURCE_C = 2, 3710Sstevel@tonic-gate SOURCE_S = 4 3720Sstevel@tonic-gate } source_types_t; 3730Sstevel@tonic-gate 3740Sstevel@tonic-gate source_types_t built_source_types(Elf *, const char *); 3750Sstevel@tonic-gate int count_files(char **, int); 3760Sstevel@tonic-gate int read_ctf(char **, int, char *, int (*)(tdata_t *, char *, void *), 3770Sstevel@tonic-gate void *, int); 3780Sstevel@tonic-gate int read_ctf_save_cb(tdata_t *, char *, void *); 3790Sstevel@tonic-gate symit_data_t *symit_new(Elf *, const char *); 3800Sstevel@tonic-gate void symit_reset(symit_data_t *); 3810Sstevel@tonic-gate char *symit_curfile(symit_data_t *); 3820Sstevel@tonic-gate GElf_Sym *symit_next(symit_data_t *, int); 3830Sstevel@tonic-gate char *symit_name(symit_data_t *); 3840Sstevel@tonic-gate void symit_free(symit_data_t *); 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate /* merge.c */ 3870Sstevel@tonic-gate void merge_into_master(tdata_t *, tdata_t *, tdata_t *, int); 3880Sstevel@tonic-gate 3890Sstevel@tonic-gate /* output.c */ 3900Sstevel@tonic-gate #define CTF_FUZZY_MATCH 0x1 /* match local symbols to global CTF */ 3910Sstevel@tonic-gate #define CTF_USE_DYNSYM 0x2 /* use .dynsym not .symtab */ 3920Sstevel@tonic-gate #define CTF_COMPRESS 0x4 /* compress CTF output */ 3930Sstevel@tonic-gate #define CTF_KEEP_STABS 0x8 /* keep .stabs sections */ 3940Sstevel@tonic-gate 3950Sstevel@tonic-gate void write_ctf(tdata_t *, const char *, const char *, int); 3960Sstevel@tonic-gate 3970Sstevel@tonic-gate /* parse.c */ 3980Sstevel@tonic-gate void parse_init(tdata_t *); 3990Sstevel@tonic-gate void parse_finish(tdata_t *); 4000Sstevel@tonic-gate int parse_stab(stab_t *, char *, iidesc_t **); 4010Sstevel@tonic-gate tdesc_t *lookup(int); 402*2722Sjohnlev tdesc_t *lookupname(const char *); 4030Sstevel@tonic-gate void check_hash(void); 4040Sstevel@tonic-gate void resolve_typed_bitfields(void); 4050Sstevel@tonic-gate 4060Sstevel@tonic-gate /* stabs.c */ 4070Sstevel@tonic-gate int stabs_read(tdata_t *, Elf *, const char *); 4080Sstevel@tonic-gate 4090Sstevel@tonic-gate /* dwarf.c */ 4100Sstevel@tonic-gate int dw_read(tdata_t *, Elf *, const char *); 4110Sstevel@tonic-gate const char *dw_tag2str(uint_t); 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate /* tdata.c */ 4140Sstevel@tonic-gate tdata_t *tdata_new(void); 4150Sstevel@tonic-gate void tdata_free(tdata_t *); 4160Sstevel@tonic-gate void tdata_build_hashes(tdata_t *td); 4171882Sjohnlev const char *tdesc_name(tdesc_t *); 4180Sstevel@tonic-gate int tdesc_idhash(int, void *); 4190Sstevel@tonic-gate int tdesc_idcmp(void *, void *); 4200Sstevel@tonic-gate int tdesc_namehash(int, void *); 4210Sstevel@tonic-gate int tdesc_namecmp(void *, void *); 4220Sstevel@tonic-gate int tdesc_layouthash(int, void *); 4230Sstevel@tonic-gate int tdesc_layoutcmp(void *, void *); 4240Sstevel@tonic-gate void tdesc_free(tdesc_t *); 4250Sstevel@tonic-gate void tdata_label_add(tdata_t *, char *, int); 4260Sstevel@tonic-gate labelent_t *tdata_label_top(tdata_t *); 4270Sstevel@tonic-gate int tdata_label_find(tdata_t *, char *); 4280Sstevel@tonic-gate void tdata_label_free(tdata_t *); 4290Sstevel@tonic-gate void tdata_merge(tdata_t *, tdata_t *); 4300Sstevel@tonic-gate void tdata_label_newmax(tdata_t *, int); 4310Sstevel@tonic-gate 4320Sstevel@tonic-gate /* util.c */ 433*2722Sjohnlev int streq(const char *, const char *); 4341951Sjohnlev int findelfsecidx(Elf *, const char *, const char *); 435*2722Sjohnlev size_t elf_ptrsz(Elf *); 4360Sstevel@tonic-gate char *mktmpname(const char *, const char *); 4370Sstevel@tonic-gate void terminate(char *, ...); 4381951Sjohnlev void aborterr(char *, ...); 4390Sstevel@tonic-gate void set_terminate_cleanup(void (*)()); 4400Sstevel@tonic-gate void elfterminate(const char *, const char *, ...); 4410Sstevel@tonic-gate void warning(char *, ...); 4420Sstevel@tonic-gate void vadebug(int, char *, va_list); 4430Sstevel@tonic-gate void debug(int, char *, ...); 4440Sstevel@tonic-gate 4450Sstevel@tonic-gate #ifdef __cplusplus 4460Sstevel@tonic-gate } 4470Sstevel@tonic-gate #endif 4480Sstevel@tonic-gate 4490Sstevel@tonic-gate #endif /* _CTFTOOLS_H */ 450