17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 54d232658Sjohnlev * Common Development and Distribution License (the "License"). 64d232658Sjohnlev * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 224d232658Sjohnlev * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _CTFTOOLS_H 277c478bd9Sstevel@tonic-gate #define _CTFTOOLS_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * Functions and data structures used in the manipulation of stabs and CTF data 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <stdio.h> 347c478bd9Sstevel@tonic-gate #include <stdlib.h> 357c478bd9Sstevel@tonic-gate #include <stdarg.h> 367c478bd9Sstevel@tonic-gate #include <libelf.h> 377c478bd9Sstevel@tonic-gate #include <gelf.h> 387c478bd9Sstevel@tonic-gate #include <pthread.h> 397c478bd9Sstevel@tonic-gate 40a6bde1a2SErik Cederstrand #include <sys/ccompile.h> 41a6bde1a2SErik Cederstrand 427c478bd9Sstevel@tonic-gate #ifdef __cplusplus 437c478bd9Sstevel@tonic-gate extern "C" { 447c478bd9Sstevel@tonic-gate #endif 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #include "list.h" 477c478bd9Sstevel@tonic-gate #include "hash.h" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #ifndef DEBUG_LEVEL 507c478bd9Sstevel@tonic-gate #define DEBUG_LEVEL 0 517c478bd9Sstevel@tonic-gate #endif 527c478bd9Sstevel@tonic-gate #ifndef DEBUG_PARSE 537c478bd9Sstevel@tonic-gate #define DEBUG_PARSE 0 547c478bd9Sstevel@tonic-gate #endif 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #ifndef DEBUG_STREAM 577c478bd9Sstevel@tonic-gate #define DEBUG_STREAM stderr 587c478bd9Sstevel@tonic-gate #endif 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #ifndef MAX 617c478bd9Sstevel@tonic-gate #define MAX(a, b) ((a) < (b) ? (b) : (a)) 627c478bd9Sstevel@tonic-gate #endif 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate #ifndef MIN 657c478bd9Sstevel@tonic-gate #define MIN(a, b) ((a) > (b) ? (b) : (a)) 667c478bd9Sstevel@tonic-gate #endif 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate #define TRUE 1 697c478bd9Sstevel@tonic-gate #define FALSE 0 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate #define CTF_ELF_SCN_NAME ".SUNW_ctf" 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define CTF_LABEL_LASTIDX -1 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define CTF_DEFAULT_LABEL "*** No Label Provided ***" 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * Default hash sizes 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate #define TDATA_LAYOUT_HASH_SIZE 8191 /* A tdesc hash based on layout */ 817c478bd9Sstevel@tonic-gate #define TDATA_ID_HASH_SIZE 997 /* A tdesc hash based on type id */ 827c478bd9Sstevel@tonic-gate #define IIDESC_HASH_SIZE 8191 /* Hash of iidesc's */ 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate /* 857c478bd9Sstevel@tonic-gate * The default function argument array size. We'll realloc the array larger 867c478bd9Sstevel@tonic-gate * if we need to, but we want a default value that will allow us to avoid 877c478bd9Sstevel@tonic-gate * reallocation in the common case. 887c478bd9Sstevel@tonic-gate */ 897c478bd9Sstevel@tonic-gate #define FUNCARG_DEF 5 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate extern const char *progname; 927c478bd9Sstevel@tonic-gate extern int debug_level; 937c478bd9Sstevel@tonic-gate extern int debug_parse; 947c478bd9Sstevel@tonic-gate extern const char *curhdr; 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate /* 977c478bd9Sstevel@tonic-gate * This is a partial copy of the stab.h that DevPro includes with their 987c478bd9Sstevel@tonic-gate * compiler. 997c478bd9Sstevel@tonic-gate */ 1007c478bd9Sstevel@tonic-gate typedef struct stab { 1017c478bd9Sstevel@tonic-gate uint32_t n_strx; 1027c478bd9Sstevel@tonic-gate uint8_t n_type; 1037c478bd9Sstevel@tonic-gate int8_t n_other; 1047c478bd9Sstevel@tonic-gate int16_t n_desc; 1057c478bd9Sstevel@tonic-gate uint32_t n_value; 1067c478bd9Sstevel@tonic-gate } stab_t; 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate #define N_GSYM 0x20 /* global symbol: name,,0,type,0 */ 1097c478bd9Sstevel@tonic-gate #define N_FUN 0x24 /* procedure: name,,0,linenumber,0 */ 1107c478bd9Sstevel@tonic-gate #define N_STSYM 0x26 /* static symbol: name,,0,type,0 or section relative */ 1117c478bd9Sstevel@tonic-gate #define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,0 or section relative */ 1127c478bd9Sstevel@tonic-gate #define N_ROSYM 0x2c /* ro_data: name,,0,type,0 or section relative */ 1137c478bd9Sstevel@tonic-gate #define N_OPT 0x3c /* compiler options */ 1147c478bd9Sstevel@tonic-gate #define N_RSYM 0x40 /* register sym: name,,0,type,register */ 1157c478bd9Sstevel@tonic-gate #define N_SO 0x64 /* source file name: name,,0,0,0 */ 1167c478bd9Sstevel@tonic-gate #define N_LSYM 0x80 /* local sym: name,,0,type,offset */ 1177c478bd9Sstevel@tonic-gate #define N_SOL 0x84 /* #included file name: name,,0,0,0 */ 1187c478bd9Sstevel@tonic-gate #define N_PSYM 0xa0 /* parameter: name,,0,type,offset */ 1197c478bd9Sstevel@tonic-gate #define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,function relative */ 1207c478bd9Sstevel@tonic-gate #define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,func relative */ 1217c478bd9Sstevel@tonic-gate #define N_BINCL 0x82 /* header file: name,,0,0,0 */ 1227c478bd9Sstevel@tonic-gate #define N_EINCL 0xa2 /* end of include file */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate /* 1257c478bd9Sstevel@tonic-gate * Nodes in the type tree 1267c478bd9Sstevel@tonic-gate * 1277c478bd9Sstevel@tonic-gate * Each node consists of a single tdesc_t, with one of several auxiliary 1287c478bd9Sstevel@tonic-gate * structures linked in via the `data' union. 1297c478bd9Sstevel@tonic-gate */ 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate /* The type of tdesc_t node */ 1327c478bd9Sstevel@tonic-gate typedef enum stabtype { 1337c478bd9Sstevel@tonic-gate STABTYPE_FIRST, /* do not use */ 1347c478bd9Sstevel@tonic-gate INTRINSIC, 1357c478bd9Sstevel@tonic-gate POINTER, 1367c478bd9Sstevel@tonic-gate ARRAY, 1377c478bd9Sstevel@tonic-gate FUNCTION, 1387c478bd9Sstevel@tonic-gate STRUCT, 1397c478bd9Sstevel@tonic-gate UNION, 1407c478bd9Sstevel@tonic-gate ENUM, 1417c478bd9Sstevel@tonic-gate FORWARD, 1427c478bd9Sstevel@tonic-gate TYPEDEF, 1437c478bd9Sstevel@tonic-gate TYPEDEF_UNRES, 1447c478bd9Sstevel@tonic-gate VOLATILE, 1457c478bd9Sstevel@tonic-gate CONST, 1467c478bd9Sstevel@tonic-gate RESTRICT, 1477c478bd9Sstevel@tonic-gate STABTYPE_LAST /* do not use */ 1487c478bd9Sstevel@tonic-gate } stabtype_t; 1497c478bd9Sstevel@tonic-gate 1507c478bd9Sstevel@tonic-gate typedef struct tdesc tdesc_t; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* Auxiliary structure for array tdesc_t */ 1537c478bd9Sstevel@tonic-gate typedef struct ardef { 1547c478bd9Sstevel@tonic-gate tdesc_t *ad_contents; 1557c478bd9Sstevel@tonic-gate tdesc_t *ad_idxtype; 1567c478bd9Sstevel@tonic-gate uint_t ad_nelems; 1577c478bd9Sstevel@tonic-gate } ardef_t; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* Auxiliary structure for structure/union tdesc_t */ 1607c478bd9Sstevel@tonic-gate typedef struct mlist { 1617c478bd9Sstevel@tonic-gate int ml_offset; /* Offset from start of structure (in bits) */ 1627c478bd9Sstevel@tonic-gate int ml_size; /* Member size (in bits) */ 1637c478bd9Sstevel@tonic-gate char *ml_name; /* Member name */ 1647c478bd9Sstevel@tonic-gate struct tdesc *ml_type; /* Member type */ 1657c478bd9Sstevel@tonic-gate struct mlist *ml_next; /* Next member */ 1667c478bd9Sstevel@tonic-gate } mlist_t; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* Auxiliary structure for enum tdesc_t */ 1697c478bd9Sstevel@tonic-gate typedef struct elist { 1707c478bd9Sstevel@tonic-gate char *el_name; 1717c478bd9Sstevel@tonic-gate int el_number; 1727c478bd9Sstevel@tonic-gate struct elist *el_next; 1737c478bd9Sstevel@tonic-gate } elist_t; 1747c478bd9Sstevel@tonic-gate 1757c478bd9Sstevel@tonic-gate /* Auxiliary structure for intrinsics (integers and reals) */ 1767c478bd9Sstevel@tonic-gate typedef enum { 1777c478bd9Sstevel@tonic-gate INTR_INT, 1787c478bd9Sstevel@tonic-gate INTR_REAL 1797c478bd9Sstevel@tonic-gate } intrtype_t; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate typedef struct intr { 1827c478bd9Sstevel@tonic-gate intrtype_t intr_type; 1837c478bd9Sstevel@tonic-gate int intr_signed; 1847c478bd9Sstevel@tonic-gate union { 1857c478bd9Sstevel@tonic-gate char _iformat; 1867c478bd9Sstevel@tonic-gate int _fformat; 1877c478bd9Sstevel@tonic-gate } _u; 1887c478bd9Sstevel@tonic-gate int intr_offset; 1897c478bd9Sstevel@tonic-gate int intr_nbits; 1907c478bd9Sstevel@tonic-gate } intr_t; 1917c478bd9Sstevel@tonic-gate 1927c478bd9Sstevel@tonic-gate #define intr_iformat _u._iformat 1937c478bd9Sstevel@tonic-gate #define intr_fformat _u._fformat 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate typedef struct fnarg { 1967c478bd9Sstevel@tonic-gate char *fna_name; 1977c478bd9Sstevel@tonic-gate struct tdesc *fna_type; 1987c478bd9Sstevel@tonic-gate } fnarg_t; 1997c478bd9Sstevel@tonic-gate 2007c478bd9Sstevel@tonic-gate #define FN_F_GLOBAL 0x1 2017c478bd9Sstevel@tonic-gate #define FN_F_VARARGS 0x2 2027c478bd9Sstevel@tonic-gate 2037c478bd9Sstevel@tonic-gate typedef struct fndef { 2047c478bd9Sstevel@tonic-gate struct tdesc *fn_ret; 2057c478bd9Sstevel@tonic-gate uint_t fn_nargs; 2067c478bd9Sstevel@tonic-gate tdesc_t **fn_args; 2077c478bd9Sstevel@tonic-gate uint_t fn_vargs; 2087c478bd9Sstevel@tonic-gate } fndef_t; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate typedef int32_t tid_t; 2117c478bd9Sstevel@tonic-gate 2127c478bd9Sstevel@tonic-gate /* 2137c478bd9Sstevel@tonic-gate * The tdesc_t (Type DESCription) is the basic node type used in the stabs data 2147c478bd9Sstevel@tonic-gate * structure. Each data node gets a tdesc structure. Each node is linked into 2157c478bd9Sstevel@tonic-gate * a directed graph (think of it as a tree with multiple roots and multiple 2167c478bd9Sstevel@tonic-gate * leaves), with the root nodes at the top, and intrinsics at the bottom. The 2177c478bd9Sstevel@tonic-gate * root nodes, which are pointed to by iidesc nodes, correspond to the types, 2187c478bd9Sstevel@tonic-gate * globals, and statics defined by the stabs. 2197c478bd9Sstevel@tonic-gate */ 2207c478bd9Sstevel@tonic-gate struct tdesc { 2217c478bd9Sstevel@tonic-gate char *t_name; 2227c478bd9Sstevel@tonic-gate tdesc_t *t_next; /* Name hash next pointer */ 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate tid_t t_id; 2257c478bd9Sstevel@tonic-gate tdesc_t *t_hash; /* ID hash next pointer */ 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate stabtype_t t_type; 2287c478bd9Sstevel@tonic-gate int t_size; /* Size in bytes of object represented by this node */ 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate union { 2317c478bd9Sstevel@tonic-gate intr_t *intr; /* int, real */ 2327c478bd9Sstevel@tonic-gate tdesc_t *tdesc; /* ptr, typedef, vol, const, restr */ 2337c478bd9Sstevel@tonic-gate ardef_t *ardef; /* array */ 2347c478bd9Sstevel@tonic-gate mlist_t *members; /* struct, union */ 2357c478bd9Sstevel@tonic-gate elist_t *emem; /* enum */ 2367c478bd9Sstevel@tonic-gate fndef_t *fndef; /* function - first is return type */ 2377c478bd9Sstevel@tonic-gate } t_data; 2387c478bd9Sstevel@tonic-gate 2397c478bd9Sstevel@tonic-gate int t_flags; 2407c478bd9Sstevel@tonic-gate int t_vgen; /* Visitation generation (see traverse.c) */ 2417c478bd9Sstevel@tonic-gate int t_emark; /* Equality mark (see equiv_cb() in merge.c) */ 2427c478bd9Sstevel@tonic-gate }; 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #define t_intr t_data.intr 2457c478bd9Sstevel@tonic-gate #define t_tdesc t_data.tdesc 2467c478bd9Sstevel@tonic-gate #define t_ardef t_data.ardef 2477c478bd9Sstevel@tonic-gate #define t_members t_data.members 2487c478bd9Sstevel@tonic-gate #define t_emem t_data.emem 2497c478bd9Sstevel@tonic-gate #define t_fndef t_data.fndef 2507c478bd9Sstevel@tonic-gate 2517c478bd9Sstevel@tonic-gate #define TDESC_F_ISROOT 0x1 /* Has an iidesc_t (see below) */ 2527c478bd9Sstevel@tonic-gate #define TDESC_F_GLOBAL 0x2 2537c478bd9Sstevel@tonic-gate #define TDESC_F_RESOLVED 0x4 2547c478bd9Sstevel@tonic-gate 2557c478bd9Sstevel@tonic-gate /* 2567c478bd9Sstevel@tonic-gate * iidesc_t (Interesting Item DESCription) nodes point to tdesc_t nodes that 2577c478bd9Sstevel@tonic-gate * correspond to "interesting" stabs. A stab is interesting if it defines a 2587c478bd9Sstevel@tonic-gate * global or static variable, a global or static function, or a data type. 2597c478bd9Sstevel@tonic-gate */ 2607c478bd9Sstevel@tonic-gate typedef enum iitype { 2617c478bd9Sstevel@tonic-gate II_NOT = 0, 2627c478bd9Sstevel@tonic-gate II_GFUN, /* Global function */ 2637c478bd9Sstevel@tonic-gate II_SFUN, /* Static function */ 2647c478bd9Sstevel@tonic-gate II_GVAR, /* Global variable */ 2657c478bd9Sstevel@tonic-gate II_SVAR, /* Static variable */ 2667c478bd9Sstevel@tonic-gate II_PSYM, /* Function argument */ 2677c478bd9Sstevel@tonic-gate II_SOU, /* Struct or union */ 2687c478bd9Sstevel@tonic-gate II_TYPE /* Type (typedef) */ 2697c478bd9Sstevel@tonic-gate } iitype_t; 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate typedef struct iidesc { 2727c478bd9Sstevel@tonic-gate iitype_t ii_type; 2737c478bd9Sstevel@tonic-gate char *ii_name; 2747c478bd9Sstevel@tonic-gate tdesc_t *ii_dtype; 2757c478bd9Sstevel@tonic-gate char *ii_owner; /* File that defined this node */ 2767c478bd9Sstevel@tonic-gate int ii_flags; 2777c478bd9Sstevel@tonic-gate 2787c478bd9Sstevel@tonic-gate /* Function arguments (if any) */ 2797c478bd9Sstevel@tonic-gate int ii_nargs; 2807c478bd9Sstevel@tonic-gate tdesc_t **ii_args; 2817c478bd9Sstevel@tonic-gate int ii_vargs; /* Function uses varargs */ 2827c478bd9Sstevel@tonic-gate } iidesc_t; 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate #define IIDESC_F_USED 0x1 /* Write this iidesc out */ 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate /* 2877c478bd9Sstevel@tonic-gate * labelent_t nodes identify labels and corresponding type ranges associated 2887c478bd9Sstevel@tonic-gate * with them. The label in a given labelent_t is associated with types with 2897c478bd9Sstevel@tonic-gate * ids <= le_idx. 2907c478bd9Sstevel@tonic-gate */ 2917c478bd9Sstevel@tonic-gate typedef struct labelent { 2927c478bd9Sstevel@tonic-gate char *le_name; 2937c478bd9Sstevel@tonic-gate int le_idx; 2947c478bd9Sstevel@tonic-gate } labelent_t; 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate /* 2977c478bd9Sstevel@tonic-gate * The tdata_t (Type DATA) structure contains or references all type data for 2987c478bd9Sstevel@tonic-gate * a given file or, during merging, several files. 2997c478bd9Sstevel@tonic-gate */ 3007c478bd9Sstevel@tonic-gate typedef struct tdata { 3017c478bd9Sstevel@tonic-gate int td_curemark; /* Equality mark (see merge.c) */ 3027c478bd9Sstevel@tonic-gate int td_curvgen; /* Visitation generation (see traverse.c) */ 3037c478bd9Sstevel@tonic-gate int td_nextid; /* The ID for the next tdesc_t created */ 3047c478bd9Sstevel@tonic-gate hash_t *td_iihash; /* The iidesc_t nodes for this file */ 3057c478bd9Sstevel@tonic-gate 3067c478bd9Sstevel@tonic-gate hash_t *td_layouthash; /* The tdesc nodes, hashed by structure */ 3077c478bd9Sstevel@tonic-gate hash_t *td_idhash; /* The tdesc nodes, hashed by type id */ 3087c478bd9Sstevel@tonic-gate list_t *td_fwdlist; /* All forward declaration tdesc nodes */ 3097c478bd9Sstevel@tonic-gate 3107c478bd9Sstevel@tonic-gate char *td_parlabel; /* Top label uniq'd against in parent */ 3117c478bd9Sstevel@tonic-gate char *td_parname; /* Basename of parent */ 3127c478bd9Sstevel@tonic-gate list_t *td_labels; /* Labels and their type ranges */ 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate pthread_mutex_t td_mergelock; 3157c478bd9Sstevel@tonic-gate 3167c478bd9Sstevel@tonic-gate int td_ref; 3177c478bd9Sstevel@tonic-gate } tdata_t; 3187c478bd9Sstevel@tonic-gate 3197c478bd9Sstevel@tonic-gate /* 3207c478bd9Sstevel@tonic-gate * By design, the iidesc hash is heterogeneous. The CTF emitter, on the 3217c478bd9Sstevel@tonic-gate * other hand, needs to be able to access the elements of the list by type, 3227c478bd9Sstevel@tonic-gate * and in a specific sorted order. An iiburst holds these elements in that 3237c478bd9Sstevel@tonic-gate * order. (A burster is a machine that separates carbon-copy forms) 3247c478bd9Sstevel@tonic-gate */ 3257c478bd9Sstevel@tonic-gate typedef struct iiburst { 3267c478bd9Sstevel@tonic-gate int iib_nfuncs; 3277c478bd9Sstevel@tonic-gate int iib_curfunc; 3287c478bd9Sstevel@tonic-gate iidesc_t **iib_funcs; 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate int iib_nobjts; 3317c478bd9Sstevel@tonic-gate int iib_curobjt; 3327c478bd9Sstevel@tonic-gate iidesc_t **iib_objts; 3337c478bd9Sstevel@tonic-gate 3347c478bd9Sstevel@tonic-gate list_t *iib_types; 3357c478bd9Sstevel@tonic-gate int iib_maxtypeid; 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate tdata_t *iib_td; 3387c478bd9Sstevel@tonic-gate struct tdtrav_data *iib_tdtd; /* tdtrav_data_t */ 3397c478bd9Sstevel@tonic-gate } iiburst_t; 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate typedef struct ctf_buf ctf_buf_t; 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate typedef struct symit_data symit_data_t; 3447c478bd9Sstevel@tonic-gate 345e824d57fSjohnlev /* fixup_tdescs.c */ 346e824d57fSjohnlev void cvt_fixstabs(tdata_t *); 347e824d57fSjohnlev void cvt_fixups(tdata_t *, size_t); 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate /* ctf.c */ 3507c478bd9Sstevel@tonic-gate caddr_t ctf_gen(iiburst_t *, size_t *, int); 3517c478bd9Sstevel@tonic-gate tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *); 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate /* iidesc.c */ 3547c478bd9Sstevel@tonic-gate iidesc_t *iidesc_new(char *); 3557c478bd9Sstevel@tonic-gate int iidesc_hash(int, void *); 356e824d57fSjohnlev void iter_iidescs_by_name(tdata_t *, const char *, 357e824d57fSjohnlev int (*)(iidesc_t *, void *), void *); 3587c478bd9Sstevel@tonic-gate iidesc_t *iidesc_dup(iidesc_t *); 3597c478bd9Sstevel@tonic-gate iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *); 3607c478bd9Sstevel@tonic-gate void iidesc_add(hash_t *, iidesc_t *); 3617c478bd9Sstevel@tonic-gate void iidesc_free(iidesc_t *, void *); 3627c478bd9Sstevel@tonic-gate int iidesc_count_type(void *, void *); 3637c478bd9Sstevel@tonic-gate void iidesc_stats(hash_t *); 3647c478bd9Sstevel@tonic-gate int iidesc_dump(iidesc_t *); 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate /* input.c */ 3677c478bd9Sstevel@tonic-gate typedef enum source_types { 3687c478bd9Sstevel@tonic-gate SOURCE_NONE = 0, 3697c478bd9Sstevel@tonic-gate SOURCE_UNKNOWN = 1, 3707c478bd9Sstevel@tonic-gate SOURCE_C = 2, 3717c478bd9Sstevel@tonic-gate SOURCE_S = 4 3727c478bd9Sstevel@tonic-gate } source_types_t; 3737c478bd9Sstevel@tonic-gate 3747c478bd9Sstevel@tonic-gate source_types_t built_source_types(Elf *, const char *); 3757c478bd9Sstevel@tonic-gate int count_files(char **, int); 3767c478bd9Sstevel@tonic-gate int read_ctf(char **, int, char *, int (*)(tdata_t *, char *, void *), 3777c478bd9Sstevel@tonic-gate void *, int); 3787c478bd9Sstevel@tonic-gate int read_ctf_save_cb(tdata_t *, char *, void *); 3797c478bd9Sstevel@tonic-gate symit_data_t *symit_new(Elf *, const char *); 3807c478bd9Sstevel@tonic-gate void symit_reset(symit_data_t *); 3817c478bd9Sstevel@tonic-gate char *symit_curfile(symit_data_t *); 3827c478bd9Sstevel@tonic-gate GElf_Sym *symit_next(symit_data_t *, int); 3837c478bd9Sstevel@tonic-gate char *symit_name(symit_data_t *); 3847c478bd9Sstevel@tonic-gate void symit_free(symit_data_t *); 3857c478bd9Sstevel@tonic-gate 3867c478bd9Sstevel@tonic-gate /* merge.c */ 3877c478bd9Sstevel@tonic-gate void merge_into_master(tdata_t *, tdata_t *, tdata_t *, int); 3887c478bd9Sstevel@tonic-gate 3897c478bd9Sstevel@tonic-gate /* output.c */ 3907c478bd9Sstevel@tonic-gate #define CTF_FUZZY_MATCH 0x1 /* match local symbols to global CTF */ 3917c478bd9Sstevel@tonic-gate #define CTF_USE_DYNSYM 0x2 /* use .dynsym not .symtab */ 3927c478bd9Sstevel@tonic-gate #define CTF_COMPRESS 0x4 /* compress CTF output */ 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate void write_ctf(tdata_t *, const char *, const char *, int); 3957c478bd9Sstevel@tonic-gate 3967c478bd9Sstevel@tonic-gate /* parse.c */ 3977c478bd9Sstevel@tonic-gate void parse_init(tdata_t *); 3987c478bd9Sstevel@tonic-gate void parse_finish(tdata_t *); 3997c478bd9Sstevel@tonic-gate int parse_stab(stab_t *, char *, iidesc_t **); 4007c478bd9Sstevel@tonic-gate tdesc_t *lookup(int); 401e824d57fSjohnlev tdesc_t *lookupname(const char *); 4027c478bd9Sstevel@tonic-gate void check_hash(void); 4037c478bd9Sstevel@tonic-gate void resolve_typed_bitfields(void); 4047c478bd9Sstevel@tonic-gate 4057c478bd9Sstevel@tonic-gate /* stabs.c */ 4067c478bd9Sstevel@tonic-gate int stabs_read(tdata_t *, Elf *, const char *); 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate /* dwarf.c */ 4097c478bd9Sstevel@tonic-gate int dw_read(tdata_t *, Elf *, const char *); 4107c478bd9Sstevel@tonic-gate const char *dw_tag2str(uint_t); 4117c478bd9Sstevel@tonic-gate 4127c478bd9Sstevel@tonic-gate /* tdata.c */ 4137c478bd9Sstevel@tonic-gate tdata_t *tdata_new(void); 4147c478bd9Sstevel@tonic-gate void tdata_free(tdata_t *); 4157c478bd9Sstevel@tonic-gate void tdata_build_hashes(tdata_t *td); 4164d232658Sjohnlev const char *tdesc_name(tdesc_t *); 4177c478bd9Sstevel@tonic-gate int tdesc_idhash(int, void *); 4187c478bd9Sstevel@tonic-gate int tdesc_idcmp(void *, void *); 4197c478bd9Sstevel@tonic-gate int tdesc_namehash(int, void *); 4207c478bd9Sstevel@tonic-gate int tdesc_namecmp(void *, void *); 4217c478bd9Sstevel@tonic-gate int tdesc_layouthash(int, void *); 4227c478bd9Sstevel@tonic-gate int tdesc_layoutcmp(void *, void *); 4237c478bd9Sstevel@tonic-gate void tdesc_free(tdesc_t *); 4247c478bd9Sstevel@tonic-gate void tdata_label_add(tdata_t *, char *, int); 4257c478bd9Sstevel@tonic-gate labelent_t *tdata_label_top(tdata_t *); 4267c478bd9Sstevel@tonic-gate int tdata_label_find(tdata_t *, char *); 4277c478bd9Sstevel@tonic-gate void tdata_label_free(tdata_t *); 4287c478bd9Sstevel@tonic-gate void tdata_merge(tdata_t *, tdata_t *); 4297c478bd9Sstevel@tonic-gate void tdata_label_newmax(tdata_t *, int); 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate /* util.c */ 432e824d57fSjohnlev int streq(const char *, const char *); 433c168da27Sjohnlev int findelfsecidx(Elf *, const char *, const char *); 434e824d57fSjohnlev size_t elf_ptrsz(Elf *); 4357c478bd9Sstevel@tonic-gate char *mktmpname(const char *, const char *); 436a6bde1a2SErik Cederstrand void terminate(char *, ...) __NORETURN; 437a6bde1a2SErik Cederstrand void aborterr(char *, ...) __NORETURN; 4387c478bd9Sstevel@tonic-gate void set_terminate_cleanup(void (*)()); 4397c478bd9Sstevel@tonic-gate void elfterminate(const char *, const char *, ...); 4407c478bd9Sstevel@tonic-gate void warning(char *, ...); 4417c478bd9Sstevel@tonic-gate void vadebug(int, char *, va_list); 4427c478bd9Sstevel@tonic-gate void debug(int, char *, ...); 4437c478bd9Sstevel@tonic-gate 444*7fd79137SRobert Mustacchi /* altexec.c */ 445*7fd79137SRobert Mustacchi void ctf_altexec(const char *, int argc, char **); 446*7fd79137SRobert Mustacchi 4477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate #endif 4507c478bd9Sstevel@tonic-gate 4517c478bd9Sstevel@tonic-gate #endif /* _CTFTOOLS_H */ 452