1*1673e404SJohn Birrell /* 2*1673e404SJohn Birrell * CDDL HEADER START 3*1673e404SJohn Birrell * 4*1673e404SJohn Birrell * The contents of this file are subject to the terms of the 5*1673e404SJohn Birrell * Common Development and Distribution License (the "License"). 6*1673e404SJohn Birrell * You may not use this file except in compliance with the License. 7*1673e404SJohn Birrell * 8*1673e404SJohn Birrell * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9*1673e404SJohn Birrell * or http://www.opensolaris.org/os/licensing. 10*1673e404SJohn Birrell * See the License for the specific language governing permissions 11*1673e404SJohn Birrell * and limitations under the License. 12*1673e404SJohn Birrell * 13*1673e404SJohn Birrell * When distributing Covered Code, include this CDDL HEADER in each 14*1673e404SJohn Birrell * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15*1673e404SJohn Birrell * If applicable, add the following below this CDDL HEADER, with the 16*1673e404SJohn Birrell * fields enclosed by brackets "[]" replaced with your own identifying 17*1673e404SJohn Birrell * information: Portions Copyright [yyyy] [name of copyright owner] 18*1673e404SJohn Birrell * 19*1673e404SJohn Birrell * CDDL HEADER END 20*1673e404SJohn Birrell */ 21*1673e404SJohn Birrell /* 22*1673e404SJohn Birrell * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*1673e404SJohn Birrell * Use is subject to license terms. 24*1673e404SJohn Birrell */ 25*1673e404SJohn Birrell 26*1673e404SJohn Birrell #ifndef _CTFTOOLS_H 27*1673e404SJohn Birrell #define _CTFTOOLS_H 28*1673e404SJohn Birrell 29*1673e404SJohn Birrell #pragma ident "%Z%%M% %I% %E% SMI" 30*1673e404SJohn Birrell 31*1673e404SJohn Birrell /* 32*1673e404SJohn Birrell * Functions and data structures used in the manipulation of stabs and CTF data 33*1673e404SJohn Birrell */ 34*1673e404SJohn Birrell 35*1673e404SJohn Birrell #include <stdio.h> 36*1673e404SJohn Birrell #include <stdlib.h> 37*1673e404SJohn Birrell #include <stdarg.h> 38*1673e404SJohn Birrell #include <libelf.h> 39*1673e404SJohn Birrell #include <gelf.h> 40*1673e404SJohn Birrell #include <pthread.h> 41*1673e404SJohn Birrell 42*1673e404SJohn Birrell #ifdef __cplusplus 43*1673e404SJohn Birrell extern "C" { 44*1673e404SJohn Birrell #endif 45*1673e404SJohn Birrell 46*1673e404SJohn Birrell #include "list.h" 47*1673e404SJohn Birrell #include "hash.h" 48*1673e404SJohn Birrell 49*1673e404SJohn Birrell #ifndef DEBUG_LEVEL 50*1673e404SJohn Birrell #define DEBUG_LEVEL 0 51*1673e404SJohn Birrell #endif 52*1673e404SJohn Birrell #ifndef DEBUG_PARSE 53*1673e404SJohn Birrell #define DEBUG_PARSE 0 54*1673e404SJohn Birrell #endif 55*1673e404SJohn Birrell 56*1673e404SJohn Birrell #ifndef DEBUG_STREAM 57*1673e404SJohn Birrell #define DEBUG_STREAM stderr 58*1673e404SJohn Birrell #endif 59*1673e404SJohn Birrell 60*1673e404SJohn Birrell #ifndef MAX 61*1673e404SJohn Birrell #define MAX(a, b) ((a) < (b) ? (b) : (a)) 62*1673e404SJohn Birrell #endif 63*1673e404SJohn Birrell 64*1673e404SJohn Birrell #ifndef MIN 65*1673e404SJohn Birrell #define MIN(a, b) ((a) > (b) ? (b) : (a)) 66*1673e404SJohn Birrell #endif 67*1673e404SJohn Birrell 68*1673e404SJohn Birrell #define TRUE 1 69*1673e404SJohn Birrell #define FALSE 0 70*1673e404SJohn Birrell 71*1673e404SJohn Birrell #define CTF_ELF_SCN_NAME ".SUNW_ctf" 72*1673e404SJohn Birrell 73*1673e404SJohn Birrell #define CTF_LABEL_LASTIDX -1 74*1673e404SJohn Birrell 75*1673e404SJohn Birrell #define CTF_DEFAULT_LABEL "*** No Label Provided ***" 76*1673e404SJohn Birrell 77*1673e404SJohn Birrell /* 78*1673e404SJohn Birrell * Default hash sizes 79*1673e404SJohn Birrell */ 80*1673e404SJohn Birrell #define TDATA_LAYOUT_HASH_SIZE 8191 /* A tdesc hash based on layout */ 81*1673e404SJohn Birrell #define TDATA_ID_HASH_SIZE 997 /* A tdesc hash based on type id */ 82*1673e404SJohn Birrell #define IIDESC_HASH_SIZE 8191 /* Hash of iidesc's */ 83*1673e404SJohn Birrell 84*1673e404SJohn Birrell /* 85*1673e404SJohn Birrell * The default function argument array size. We'll realloc the array larger 86*1673e404SJohn Birrell * if we need to, but we want a default value that will allow us to avoid 87*1673e404SJohn Birrell * reallocation in the common case. 88*1673e404SJohn Birrell */ 89*1673e404SJohn Birrell #define FUNCARG_DEF 5 90*1673e404SJohn Birrell 91*1673e404SJohn Birrell extern const char *progname; 92*1673e404SJohn Birrell extern int debug_level; 93*1673e404SJohn Birrell extern int debug_parse; 94*1673e404SJohn Birrell extern char *curhdr; 95*1673e404SJohn Birrell 96*1673e404SJohn Birrell /* 97*1673e404SJohn Birrell * This is a partial copy of the stab.h that DevPro includes with their 98*1673e404SJohn Birrell * compiler. 99*1673e404SJohn Birrell */ 100*1673e404SJohn Birrell typedef struct stab { 101*1673e404SJohn Birrell uint32_t n_strx; 102*1673e404SJohn Birrell uint8_t n_type; 103*1673e404SJohn Birrell int8_t n_other; 104*1673e404SJohn Birrell int16_t n_desc; 105*1673e404SJohn Birrell uint32_t n_value; 106*1673e404SJohn Birrell } stab_t; 107*1673e404SJohn Birrell 108*1673e404SJohn Birrell #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ 109*1673e404SJohn Birrell #define N_FUN 0x24 /* procedure: name,,0,linenumber,0 */ 110*1673e404SJohn Birrell #define N_STSYM 0x26 /* static symbol: name,,0,type,0 or section relative */ 111*1673e404SJohn Birrell #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,0 or section relative */ 112*1673e404SJohn Birrell #define N_ROSYM 0x2c /* ro_data: name,,0,type,0 or section relative */ 113*1673e404SJohn Birrell #define N_OPT 0x3c /* compiler options */ 114*1673e404SJohn Birrell #define N_RSYM 0x40 /* register sym: name,,0,type,register */ 115*1673e404SJohn Birrell #define N_SO 0x64 /* source file name: name,,0,0,0 */ 116*1673e404SJohn Birrell #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ 117*1673e404SJohn Birrell #define N_SOL 0x84 /* #included file name: name,,0,0,0 */ 118*1673e404SJohn Birrell #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ 119*1673e404SJohn Birrell #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,function relative */ 120*1673e404SJohn Birrell #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,func relative */ 121*1673e404SJohn Birrell #define N_BINCL 0x82 /* header file: name,,0,0,0 */ 122*1673e404SJohn Birrell #define N_EINCL 0xa2 /* end of include file */ 123*1673e404SJohn Birrell 124*1673e404SJohn Birrell /* 125*1673e404SJohn Birrell * Nodes in the type tree 126*1673e404SJohn Birrell * 127*1673e404SJohn Birrell * Each node consists of a single tdesc_t, with one of several auxiliary 128*1673e404SJohn Birrell * structures linked in via the `data' union. 129*1673e404SJohn Birrell */ 130*1673e404SJohn Birrell 131*1673e404SJohn Birrell /* The type of tdesc_t node */ 132*1673e404SJohn Birrell typedef enum stabtype { 133*1673e404SJohn Birrell STABTYPE_FIRST, /* do not use */ 134*1673e404SJohn Birrell INTRINSIC, 135*1673e404SJohn Birrell POINTER, 136*1673e404SJohn Birrell ARRAY, 137*1673e404SJohn Birrell FUNCTION, 138*1673e404SJohn Birrell STRUCT, 139*1673e404SJohn Birrell UNION, 140*1673e404SJohn Birrell ENUM, 141*1673e404SJohn Birrell FORWARD, 142*1673e404SJohn Birrell TYPEDEF, 143*1673e404SJohn Birrell TYPEDEF_UNRES, 144*1673e404SJohn Birrell VOLATILE, 145*1673e404SJohn Birrell CONST, 146*1673e404SJohn Birrell RESTRICT, 147*1673e404SJohn Birrell STABTYPE_LAST /* do not use */ 148*1673e404SJohn Birrell } stabtype_t; 149*1673e404SJohn Birrell 150*1673e404SJohn Birrell typedef struct tdesc tdesc_t; 151*1673e404SJohn Birrell 152*1673e404SJohn Birrell /* Auxiliary structure for array tdesc_t */ 153*1673e404SJohn Birrell typedef struct ardef { 154*1673e404SJohn Birrell tdesc_t *ad_contents; 155*1673e404SJohn Birrell tdesc_t *ad_idxtype; 156*1673e404SJohn Birrell uint_t ad_nelems; 157*1673e404SJohn Birrell } ardef_t; 158*1673e404SJohn Birrell 159*1673e404SJohn Birrell /* Auxiliary structure for structure/union tdesc_t */ 160*1673e404SJohn Birrell typedef struct mlist { 161*1673e404SJohn Birrell int ml_offset; /* Offset from start of structure (in bits) */ 162*1673e404SJohn Birrell int ml_size; /* Member size (in bits) */ 163*1673e404SJohn Birrell char *ml_name; /* Member name */ 164*1673e404SJohn Birrell struct tdesc *ml_type; /* Member type */ 165*1673e404SJohn Birrell struct mlist *ml_next; /* Next member */ 166*1673e404SJohn Birrell } mlist_t; 167*1673e404SJohn Birrell 168*1673e404SJohn Birrell /* Auxiliary structure for enum tdesc_t */ 169*1673e404SJohn Birrell typedef struct elist { 170*1673e404SJohn Birrell char *el_name; 171*1673e404SJohn Birrell int el_number; 172*1673e404SJohn Birrell struct elist *el_next; 173*1673e404SJohn Birrell } elist_t; 174*1673e404SJohn Birrell 175*1673e404SJohn Birrell /* Auxiliary structure for intrinsics (integers and reals) */ 176*1673e404SJohn Birrell typedef enum { 177*1673e404SJohn Birrell INTR_INT, 178*1673e404SJohn Birrell INTR_REAL 179*1673e404SJohn Birrell } intrtype_t; 180*1673e404SJohn Birrell 181*1673e404SJohn Birrell typedef struct intr { 182*1673e404SJohn Birrell intrtype_t intr_type; 183*1673e404SJohn Birrell int intr_signed; 184*1673e404SJohn Birrell union { 185*1673e404SJohn Birrell char _iformat; 186*1673e404SJohn Birrell int _fformat; 187*1673e404SJohn Birrell } _u; 188*1673e404SJohn Birrell int intr_offset; 189*1673e404SJohn Birrell int intr_nbits; 190*1673e404SJohn Birrell } intr_t; 191*1673e404SJohn Birrell 192*1673e404SJohn Birrell #define intr_iformat _u._iformat 193*1673e404SJohn Birrell #define intr_fformat _u._fformat 194*1673e404SJohn Birrell 195*1673e404SJohn Birrell typedef struct fnarg { 196*1673e404SJohn Birrell char *fna_name; 197*1673e404SJohn Birrell struct tdesc *fna_type; 198*1673e404SJohn Birrell } fnarg_t; 199*1673e404SJohn Birrell 200*1673e404SJohn Birrell #define FN_F_GLOBAL 0x1 201*1673e404SJohn Birrell #define FN_F_VARARGS 0x2 202*1673e404SJohn Birrell 203*1673e404SJohn Birrell typedef struct fndef { 204*1673e404SJohn Birrell struct tdesc *fn_ret; 205*1673e404SJohn Birrell uint_t fn_nargs; 206*1673e404SJohn Birrell tdesc_t **fn_args; 207*1673e404SJohn Birrell uint_t fn_vargs; 208*1673e404SJohn Birrell } fndef_t; 209*1673e404SJohn Birrell 210*1673e404SJohn Birrell typedef int32_t tid_t; 211*1673e404SJohn Birrell 212*1673e404SJohn Birrell /* 213*1673e404SJohn Birrell * The tdesc_t (Type DESCription) is the basic node type used in the stabs data 214*1673e404SJohn Birrell * structure. Each data node gets a tdesc structure. Each node is linked into 215*1673e404SJohn Birrell * a directed graph (think of it as a tree with multiple roots and multiple 216*1673e404SJohn Birrell * leaves), with the root nodes at the top, and intrinsics at the bottom. The 217*1673e404SJohn Birrell * root nodes, which are pointed to by iidesc nodes, correspond to the types, 218*1673e404SJohn Birrell * globals, and statics defined by the stabs. 219*1673e404SJohn Birrell */ 220*1673e404SJohn Birrell struct tdesc { 221*1673e404SJohn Birrell char *t_name; 222*1673e404SJohn Birrell tdesc_t *t_next; /* Name hash next pointer */ 223*1673e404SJohn Birrell 224*1673e404SJohn Birrell tid_t t_id; 225*1673e404SJohn Birrell tdesc_t *t_hash; /* ID hash next pointer */ 226*1673e404SJohn Birrell 227*1673e404SJohn Birrell stabtype_t t_type; 228*1673e404SJohn Birrell int t_size; /* Size in bytes of object represented by this node */ 229*1673e404SJohn Birrell 230*1673e404SJohn Birrell union { 231*1673e404SJohn Birrell intr_t *intr; /* int, real */ 232*1673e404SJohn Birrell tdesc_t *tdesc; /* ptr, typedef, vol, const, restr */ 233*1673e404SJohn Birrell ardef_t *ardef; /* array */ 234*1673e404SJohn Birrell mlist_t *members; /* struct, union */ 235*1673e404SJohn Birrell elist_t *emem; /* enum */ 236*1673e404SJohn Birrell fndef_t *fndef; /* function - first is return type */ 237*1673e404SJohn Birrell } t_data; 238*1673e404SJohn Birrell 239*1673e404SJohn Birrell int t_flags; 240*1673e404SJohn Birrell int t_vgen; /* Visitation generation (see traverse.c) */ 241*1673e404SJohn Birrell int t_emark; /* Equality mark (see equiv_cb() in merge.c) */ 242*1673e404SJohn Birrell }; 243*1673e404SJohn Birrell 244*1673e404SJohn Birrell #define t_intr t_data.intr 245*1673e404SJohn Birrell #define t_tdesc t_data.tdesc 246*1673e404SJohn Birrell #define t_ardef t_data.ardef 247*1673e404SJohn Birrell #define t_members t_data.members 248*1673e404SJohn Birrell #define t_emem t_data.emem 249*1673e404SJohn Birrell #define t_fndef t_data.fndef 250*1673e404SJohn Birrell 251*1673e404SJohn Birrell #define TDESC_F_ISROOT 0x1 /* Has an iidesc_t (see below) */ 252*1673e404SJohn Birrell #define TDESC_F_GLOBAL 0x2 253*1673e404SJohn Birrell #define TDESC_F_RESOLVED 0x4 254*1673e404SJohn Birrell 255*1673e404SJohn Birrell /* 256*1673e404SJohn Birrell * iidesc_t (Interesting Item DESCription) nodes point to tdesc_t nodes that 257*1673e404SJohn Birrell * correspond to "interesting" stabs. A stab is interesting if it defines a 258*1673e404SJohn Birrell * global or static variable, a global or static function, or a data type. 259*1673e404SJohn Birrell */ 260*1673e404SJohn Birrell typedef enum iitype { 261*1673e404SJohn Birrell II_NOT = 0, 262*1673e404SJohn Birrell II_GFUN, /* Global function */ 263*1673e404SJohn Birrell II_SFUN, /* Static function */ 264*1673e404SJohn Birrell II_GVAR, /* Global variable */ 265*1673e404SJohn Birrell II_SVAR, /* Static variable */ 266*1673e404SJohn Birrell II_PSYM, /* Function argument */ 267*1673e404SJohn Birrell II_SOU, /* Struct or union */ 268*1673e404SJohn Birrell II_TYPE /* Type (typedef) */ 269*1673e404SJohn Birrell } iitype_t; 270*1673e404SJohn Birrell 271*1673e404SJohn Birrell typedef struct iidesc { 272*1673e404SJohn Birrell iitype_t ii_type; 273*1673e404SJohn Birrell char *ii_name; 274*1673e404SJohn Birrell tdesc_t *ii_dtype; 275*1673e404SJohn Birrell char *ii_owner; /* File that defined this node */ 276*1673e404SJohn Birrell int ii_flags; 277*1673e404SJohn Birrell 278*1673e404SJohn Birrell /* Function arguments (if any) */ 279*1673e404SJohn Birrell int ii_nargs; 280*1673e404SJohn Birrell tdesc_t **ii_args; 281*1673e404SJohn Birrell int ii_vargs; /* Function uses varargs */ 282*1673e404SJohn Birrell } iidesc_t; 283*1673e404SJohn Birrell 284*1673e404SJohn Birrell #define IIDESC_F_USED 0x1 /* Write this iidesc out */ 285*1673e404SJohn Birrell 286*1673e404SJohn Birrell /* 287*1673e404SJohn Birrell * labelent_t nodes identify labels and corresponding type ranges associated 288*1673e404SJohn Birrell * with them. The label in a given labelent_t is associated with types with 289*1673e404SJohn Birrell * ids <= le_idx. 290*1673e404SJohn Birrell */ 291*1673e404SJohn Birrell typedef struct labelent { 292*1673e404SJohn Birrell char *le_name; 293*1673e404SJohn Birrell int le_idx; 294*1673e404SJohn Birrell } labelent_t; 295*1673e404SJohn Birrell 296*1673e404SJohn Birrell /* 297*1673e404SJohn Birrell * The tdata_t (Type DATA) structure contains or references all type data for 298*1673e404SJohn Birrell * a given file or, during merging, several files. 299*1673e404SJohn Birrell */ 300*1673e404SJohn Birrell typedef struct tdata { 301*1673e404SJohn Birrell int td_curemark; /* Equality mark (see merge.c) */ 302*1673e404SJohn Birrell int td_curvgen; /* Visitation generation (see traverse.c) */ 303*1673e404SJohn Birrell int td_nextid; /* The ID for the next tdesc_t created */ 304*1673e404SJohn Birrell hash_t *td_iihash; /* The iidesc_t nodes for this file */ 305*1673e404SJohn Birrell 306*1673e404SJohn Birrell hash_t *td_layouthash; /* The tdesc nodes, hashed by structure */ 307*1673e404SJohn Birrell hash_t *td_idhash; /* The tdesc nodes, hashed by type id */ 308*1673e404SJohn Birrell list_t *td_fwdlist; /* All forward declaration tdesc nodes */ 309*1673e404SJohn Birrell 310*1673e404SJohn Birrell char *td_parlabel; /* Top label uniq'd against in parent */ 311*1673e404SJohn Birrell char *td_parname; /* Basename of parent */ 312*1673e404SJohn Birrell list_t *td_labels; /* Labels and their type ranges */ 313*1673e404SJohn Birrell 314*1673e404SJohn Birrell pthread_mutex_t td_mergelock; 315*1673e404SJohn Birrell 316*1673e404SJohn Birrell int td_ref; 317*1673e404SJohn Birrell } tdata_t; 318*1673e404SJohn Birrell 319*1673e404SJohn Birrell /* 320*1673e404SJohn Birrell * By design, the iidesc hash is heterogeneous. The CTF emitter, on the 321*1673e404SJohn Birrell * other hand, needs to be able to access the elements of the list by type, 322*1673e404SJohn Birrell * and in a specific sorted order. An iiburst holds these elements in that 323*1673e404SJohn Birrell * order. (A burster is a machine that separates carbon-copy forms) 324*1673e404SJohn Birrell */ 325*1673e404SJohn Birrell typedef struct iiburst { 326*1673e404SJohn Birrell int iib_nfuncs; 327*1673e404SJohn Birrell int iib_curfunc; 328*1673e404SJohn Birrell iidesc_t **iib_funcs; 329*1673e404SJohn Birrell 330*1673e404SJohn Birrell int iib_nobjts; 331*1673e404SJohn Birrell int iib_curobjt; 332*1673e404SJohn Birrell iidesc_t **iib_objts; 333*1673e404SJohn Birrell 334*1673e404SJohn Birrell list_t *iib_types; 335*1673e404SJohn Birrell int iib_maxtypeid; 336*1673e404SJohn Birrell 337*1673e404SJohn Birrell tdata_t *iib_td; 338*1673e404SJohn Birrell struct tdtrav_data *iib_tdtd; /* tdtrav_data_t */ 339*1673e404SJohn Birrell } iiburst_t; 340*1673e404SJohn Birrell 341*1673e404SJohn Birrell typedef struct ctf_buf ctf_buf_t; 342*1673e404SJohn Birrell 343*1673e404SJohn Birrell typedef struct symit_data symit_data_t; 344*1673e404SJohn Birrell 345*1673e404SJohn Birrell /* fixup_tdescs.c */ 346*1673e404SJohn Birrell void cvt_fixstabs(tdata_t *); 347*1673e404SJohn Birrell void cvt_fixups(tdata_t *, size_t); 348*1673e404SJohn Birrell 349*1673e404SJohn Birrell /* ctf.c */ 350*1673e404SJohn Birrell caddr_t ctf_gen(iiburst_t *, size_t *, int); 351*1673e404SJohn Birrell tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *); 352*1673e404SJohn Birrell 353*1673e404SJohn Birrell /* iidesc.c */ 354*1673e404SJohn Birrell iidesc_t *iidesc_new(char *); 355*1673e404SJohn Birrell int iidesc_hash(int, void *); 356*1673e404SJohn Birrell void iter_iidescs_by_name(tdata_t *, const char *, 357*1673e404SJohn Birrell int (*)(void *, void *), void *); 358*1673e404SJohn Birrell iidesc_t *iidesc_dup(iidesc_t *); 359*1673e404SJohn Birrell iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *); 360*1673e404SJohn Birrell void iidesc_add(hash_t *, iidesc_t *); 361*1673e404SJohn Birrell void iidesc_free(void *, void *); 362*1673e404SJohn Birrell int iidesc_count_type(void *, void *); 363*1673e404SJohn Birrell void iidesc_stats(hash_t *); 364*1673e404SJohn Birrell int iidesc_dump(iidesc_t *); 365*1673e404SJohn Birrell 366*1673e404SJohn Birrell /* input.c */ 367*1673e404SJohn Birrell typedef enum source_types { 368*1673e404SJohn Birrell SOURCE_NONE = 0, 369*1673e404SJohn Birrell SOURCE_UNKNOWN = 1, 370*1673e404SJohn Birrell SOURCE_C = 2, 371*1673e404SJohn Birrell SOURCE_S = 4 372*1673e404SJohn Birrell } source_types_t; 373*1673e404SJohn Birrell 374*1673e404SJohn Birrell source_types_t built_source_types(Elf *, const char *); 375*1673e404SJohn Birrell int count_files(char **, int); 376*1673e404SJohn Birrell int read_ctf(char **, int, char *, int (*)(tdata_t *, char *, void *), 377*1673e404SJohn Birrell void *, int); 378*1673e404SJohn Birrell int read_ctf_save_cb(tdata_t *, char *, void *); 379*1673e404SJohn Birrell symit_data_t *symit_new(Elf *, const char *); 380*1673e404SJohn Birrell void symit_reset(symit_data_t *); 381*1673e404SJohn Birrell char *symit_curfile(symit_data_t *); 382*1673e404SJohn Birrell GElf_Sym *symit_next(symit_data_t *, int); 383*1673e404SJohn Birrell char *symit_name(symit_data_t *); 384*1673e404SJohn Birrell void symit_free(symit_data_t *); 385*1673e404SJohn Birrell 386*1673e404SJohn Birrell /* merge.c */ 387*1673e404SJohn Birrell void merge_into_master(tdata_t *, tdata_t *, tdata_t *, int); 388*1673e404SJohn Birrell 389*1673e404SJohn Birrell /* output.c */ 390*1673e404SJohn Birrell #define CTF_FUZZY_MATCH 0x1 /* match local symbols to global CTF */ 391*1673e404SJohn Birrell #define CTF_USE_DYNSYM 0x2 /* use .dynsym not .symtab */ 392*1673e404SJohn Birrell #define CTF_COMPRESS 0x4 /* compress CTF output */ 393*1673e404SJohn Birrell #define CTF_KEEP_STABS 0x8 /* keep .stabs sections */ 394*1673e404SJohn Birrell 395*1673e404SJohn Birrell void write_ctf(tdata_t *, const char *, const char *, int); 396*1673e404SJohn Birrell 397*1673e404SJohn Birrell /* parse.c */ 398*1673e404SJohn Birrell void parse_init(tdata_t *); 399*1673e404SJohn Birrell void parse_finish(tdata_t *); 400*1673e404SJohn Birrell int parse_stab(stab_t *, char *, iidesc_t **); 401*1673e404SJohn Birrell tdesc_t *lookup(int); 402*1673e404SJohn Birrell tdesc_t *lookupname(const char *); 403*1673e404SJohn Birrell void check_hash(void); 404*1673e404SJohn Birrell void resolve_typed_bitfields(void); 405*1673e404SJohn Birrell 406*1673e404SJohn Birrell /* stabs.c */ 407*1673e404SJohn Birrell int stabs_read(tdata_t *, Elf *, char *); 408*1673e404SJohn Birrell 409*1673e404SJohn Birrell /* dwarf.c */ 410*1673e404SJohn Birrell int dw_read(tdata_t *, Elf *, char *); 411*1673e404SJohn Birrell const char *dw_tag2str(uint_t); 412*1673e404SJohn Birrell 413*1673e404SJohn Birrell /* tdata.c */ 414*1673e404SJohn Birrell tdata_t *tdata_new(void); 415*1673e404SJohn Birrell void tdata_free(tdata_t *); 416*1673e404SJohn Birrell void tdata_build_hashes(tdata_t *td); 417*1673e404SJohn Birrell const char *tdesc_name(tdesc_t *); 418*1673e404SJohn Birrell int tdesc_idhash(int, void *); 419*1673e404SJohn Birrell int tdesc_idcmp(void *, void *); 420*1673e404SJohn Birrell int tdesc_namehash(int, void *); 421*1673e404SJohn Birrell int tdesc_namecmp(void *, void *); 422*1673e404SJohn Birrell int tdesc_layouthash(int, void *); 423*1673e404SJohn Birrell int tdesc_layoutcmp(void *, void *); 424*1673e404SJohn Birrell void tdesc_free(tdesc_t *); 425*1673e404SJohn Birrell void tdata_label_add(tdata_t *, const char *, int); 426*1673e404SJohn Birrell labelent_t *tdata_label_top(tdata_t *); 427*1673e404SJohn Birrell int tdata_label_find(tdata_t *, char *); 428*1673e404SJohn Birrell void tdata_label_free(tdata_t *); 429*1673e404SJohn Birrell void tdata_merge(tdata_t *, tdata_t *); 430*1673e404SJohn Birrell void tdata_label_newmax(tdata_t *, int); 431*1673e404SJohn Birrell 432*1673e404SJohn Birrell /* util.c */ 433*1673e404SJohn Birrell int streq(const char *, const char *); 434*1673e404SJohn Birrell int findelfsecidx(Elf *, const char *, const char *); 435*1673e404SJohn Birrell size_t elf_ptrsz(Elf *); 436*1673e404SJohn Birrell char *mktmpname(const char *, const char *); 437*1673e404SJohn Birrell void terminate(const char *, ...); 438*1673e404SJohn Birrell void aborterr(const char *, ...); 439*1673e404SJohn Birrell void set_terminate_cleanup(void (*)(void)); 440*1673e404SJohn Birrell void elfterminate(const char *, const char *, ...); 441*1673e404SJohn Birrell void warning(const char *, ...); 442*1673e404SJohn Birrell void vadebug(int, const char *, va_list); 443*1673e404SJohn Birrell void debug(int, const char *, ...); 444*1673e404SJohn Birrell 445*1673e404SJohn Birrell 446*1673e404SJohn Birrell void watch_dump(int); 447*1673e404SJohn Birrell void watch_set(void *, int); 448*1673e404SJohn Birrell 449*1673e404SJohn Birrell #ifdef __cplusplus 450*1673e404SJohn Birrell } 451*1673e404SJohn Birrell #endif 452*1673e404SJohn Birrell 453*1673e404SJohn Birrell #endif /* _CTFTOOLS_H */ 454