xref: /freebsd/cddl/contrib/opensolaris/tools/ctf/cvt/ctftools.h (revision 1673e4046da975ab0e2bf67d45499930ebab0dbe)
11673e404SJohn Birrell /*
21673e404SJohn Birrell  * CDDL HEADER START
31673e404SJohn Birrell  *
41673e404SJohn Birrell  * The contents of this file are subject to the terms of the
51673e404SJohn Birrell  * Common Development and Distribution License (the "License").
61673e404SJohn Birrell  * You may not use this file except in compliance with the License.
71673e404SJohn Birrell  *
81673e404SJohn Birrell  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91673e404SJohn Birrell  * or http://www.opensolaris.org/os/licensing.
101673e404SJohn Birrell  * See the License for the specific language governing permissions
111673e404SJohn Birrell  * and limitations under the License.
121673e404SJohn Birrell  *
131673e404SJohn Birrell  * When distributing Covered Code, include this CDDL HEADER in each
141673e404SJohn Birrell  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151673e404SJohn Birrell  * If applicable, add the following below this CDDL HEADER, with the
161673e404SJohn Birrell  * fields enclosed by brackets "[]" replaced with your own identifying
171673e404SJohn Birrell  * information: Portions Copyright [yyyy] [name of copyright owner]
181673e404SJohn Birrell  *
191673e404SJohn Birrell  * CDDL HEADER END
201673e404SJohn Birrell  */
211673e404SJohn Birrell /*
221673e404SJohn Birrell  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
231673e404SJohn Birrell  * Use is subject to license terms.
241673e404SJohn Birrell  */
251673e404SJohn Birrell 
261673e404SJohn Birrell #ifndef _CTFTOOLS_H
271673e404SJohn Birrell #define	_CTFTOOLS_H
281673e404SJohn Birrell 
291673e404SJohn Birrell #pragma ident	"%Z%%M%	%I%	%E% SMI"
301673e404SJohn Birrell 
311673e404SJohn Birrell /*
321673e404SJohn Birrell  * Functions and data structures used in the manipulation of stabs and CTF data
331673e404SJohn Birrell  */
341673e404SJohn Birrell 
351673e404SJohn Birrell #include <stdio.h>
361673e404SJohn Birrell #include <stdlib.h>
371673e404SJohn Birrell #include <stdarg.h>
381673e404SJohn Birrell #include <libelf.h>
391673e404SJohn Birrell #include <gelf.h>
401673e404SJohn Birrell #include <pthread.h>
411673e404SJohn Birrell 
421673e404SJohn Birrell #ifdef __cplusplus
431673e404SJohn Birrell extern "C" {
441673e404SJohn Birrell #endif
451673e404SJohn Birrell 
461673e404SJohn Birrell #include "list.h"
471673e404SJohn Birrell #include "hash.h"
481673e404SJohn Birrell 
491673e404SJohn Birrell #ifndef DEBUG_LEVEL
501673e404SJohn Birrell #define	DEBUG_LEVEL 0
511673e404SJohn Birrell #endif
521673e404SJohn Birrell #ifndef DEBUG_PARSE
531673e404SJohn Birrell #define	DEBUG_PARSE 0
541673e404SJohn Birrell #endif
551673e404SJohn Birrell 
561673e404SJohn Birrell #ifndef DEBUG_STREAM
571673e404SJohn Birrell #define	DEBUG_STREAM stderr
581673e404SJohn Birrell #endif
591673e404SJohn Birrell 
601673e404SJohn Birrell #ifndef MAX
611673e404SJohn Birrell #define	MAX(a, b) 		((a) < (b) ? (b) : (a))
621673e404SJohn Birrell #endif
631673e404SJohn Birrell 
641673e404SJohn Birrell #ifndef MIN
651673e404SJohn Birrell #define	MIN(a, b) 		((a) > (b) ? (b) : (a))
661673e404SJohn Birrell #endif
671673e404SJohn Birrell 
681673e404SJohn Birrell #define	TRUE	1
691673e404SJohn Birrell #define	FALSE	0
701673e404SJohn Birrell 
711673e404SJohn Birrell #define	CTF_ELF_SCN_NAME	".SUNW_ctf"
721673e404SJohn Birrell 
731673e404SJohn Birrell #define	CTF_LABEL_LASTIDX	-1
741673e404SJohn Birrell 
751673e404SJohn Birrell #define	CTF_DEFAULT_LABEL	"*** No Label Provided ***"
761673e404SJohn Birrell 
771673e404SJohn Birrell /*
781673e404SJohn Birrell  * Default hash sizes
791673e404SJohn Birrell  */
801673e404SJohn Birrell #define	TDATA_LAYOUT_HASH_SIZE	8191	/* A tdesc hash based on layout */
811673e404SJohn Birrell #define	TDATA_ID_HASH_SIZE	997	/* A tdesc hash based on type id */
821673e404SJohn Birrell #define	IIDESC_HASH_SIZE	8191	/* Hash of iidesc's */
831673e404SJohn Birrell 
841673e404SJohn Birrell /*
851673e404SJohn Birrell  * The default function argument array size.  We'll realloc the array larger
861673e404SJohn Birrell  * if we need to, but we want a default value that will allow us to avoid
871673e404SJohn Birrell  * reallocation in the common case.
881673e404SJohn Birrell  */
891673e404SJohn Birrell #define	FUNCARG_DEF	5
901673e404SJohn Birrell 
911673e404SJohn Birrell extern const char *progname;
921673e404SJohn Birrell extern int debug_level;
931673e404SJohn Birrell extern int debug_parse;
941673e404SJohn Birrell extern char *curhdr;
951673e404SJohn Birrell 
961673e404SJohn Birrell /*
971673e404SJohn Birrell  * This is a partial copy of the stab.h that DevPro includes with their
981673e404SJohn Birrell  * compiler.
991673e404SJohn Birrell  */
1001673e404SJohn Birrell typedef struct stab {
1011673e404SJohn Birrell 	uint32_t	n_strx;
1021673e404SJohn Birrell 	uint8_t		n_type;
1031673e404SJohn Birrell 	int8_t		n_other;
1041673e404SJohn Birrell 	int16_t		n_desc;
1051673e404SJohn Birrell 	uint32_t	n_value;
1061673e404SJohn Birrell } stab_t;
1071673e404SJohn Birrell 
1081673e404SJohn Birrell #define	N_GSYM	0x20	/* global symbol: name,,0,type,0 */
1091673e404SJohn Birrell #define	N_FUN	0x24	/* procedure: name,,0,linenumber,0 */
1101673e404SJohn Birrell #define	N_STSYM	0x26	/* static symbol: name,,0,type,0 or section relative */
1111673e404SJohn Birrell #define	N_LCSYM	0x28	/* .lcomm symbol: name,,0,type,0 or section relative */
1121673e404SJohn Birrell #define	N_ROSYM	0x2c	/* ro_data: name,,0,type,0 or section relative */
1131673e404SJohn Birrell #define	N_OPT	0x3c	/* compiler options */
1141673e404SJohn Birrell #define	N_RSYM	0x40	/* register sym: name,,0,type,register */
1151673e404SJohn Birrell #define	N_SO	0x64	/* source file name: name,,0,0,0 */
1161673e404SJohn Birrell #define	N_LSYM	0x80	/* local sym: name,,0,type,offset */
1171673e404SJohn Birrell #define	N_SOL	0x84	/* #included file name: name,,0,0,0 */
1181673e404SJohn Birrell #define	N_PSYM	0xa0	/* parameter: name,,0,type,offset */
1191673e404SJohn Birrell #define	N_LBRAC	0xc0	/* left bracket: 0,,0,nesting level,function relative */
1201673e404SJohn Birrell #define	N_RBRAC	0xe0	/* right bracket: 0,,0,nesting level,func relative */
1211673e404SJohn Birrell #define	N_BINCL 0x82	/* header file: name,,0,0,0 */
1221673e404SJohn Birrell #define	N_EINCL 0xa2	/* end of include file */
1231673e404SJohn Birrell 
1241673e404SJohn Birrell /*
1251673e404SJohn Birrell  * Nodes in the type tree
1261673e404SJohn Birrell  *
1271673e404SJohn Birrell  * Each node consists of a single tdesc_t, with one of several auxiliary
1281673e404SJohn Birrell  * structures linked in via the `data' union.
1291673e404SJohn Birrell  */
1301673e404SJohn Birrell 
1311673e404SJohn Birrell /* The type of tdesc_t node */
1321673e404SJohn Birrell typedef enum stabtype {
1331673e404SJohn Birrell 	STABTYPE_FIRST, /* do not use */
1341673e404SJohn Birrell 	INTRINSIC,
1351673e404SJohn Birrell 	POINTER,
1361673e404SJohn Birrell 	ARRAY,
1371673e404SJohn Birrell 	FUNCTION,
1381673e404SJohn Birrell 	STRUCT,
1391673e404SJohn Birrell 	UNION,
1401673e404SJohn Birrell 	ENUM,
1411673e404SJohn Birrell 	FORWARD,
1421673e404SJohn Birrell 	TYPEDEF,
1431673e404SJohn Birrell 	TYPEDEF_UNRES,
1441673e404SJohn Birrell 	VOLATILE,
1451673e404SJohn Birrell 	CONST,
1461673e404SJohn Birrell 	RESTRICT,
1471673e404SJohn Birrell 	STABTYPE_LAST /* do not use */
1481673e404SJohn Birrell } stabtype_t;
1491673e404SJohn Birrell 
1501673e404SJohn Birrell typedef struct tdesc tdesc_t;
1511673e404SJohn Birrell 
1521673e404SJohn Birrell /* Auxiliary structure for array tdesc_t */
1531673e404SJohn Birrell typedef struct ardef {
1541673e404SJohn Birrell 	tdesc_t	*ad_contents;
1551673e404SJohn Birrell 	tdesc_t *ad_idxtype;
1561673e404SJohn Birrell 	uint_t	ad_nelems;
1571673e404SJohn Birrell } ardef_t;
1581673e404SJohn Birrell 
1591673e404SJohn Birrell /* Auxiliary structure for structure/union tdesc_t */
1601673e404SJohn Birrell typedef struct mlist {
1611673e404SJohn Birrell 	int	ml_offset;	/* Offset from start of structure (in bits) */
1621673e404SJohn Birrell 	int	ml_size;	/* Member size (in bits) */
1631673e404SJohn Birrell 	char	*ml_name;	/* Member name */
1641673e404SJohn Birrell 	struct	tdesc *ml_type;	/* Member type */
1651673e404SJohn Birrell 	struct	mlist *ml_next;	/* Next member */
1661673e404SJohn Birrell } mlist_t;
1671673e404SJohn Birrell 
1681673e404SJohn Birrell /* Auxiliary structure for enum tdesc_t */
1691673e404SJohn Birrell typedef struct elist {
1701673e404SJohn Birrell 	char	*el_name;
1711673e404SJohn Birrell 	int	el_number;
1721673e404SJohn Birrell 	struct elist *el_next;
1731673e404SJohn Birrell } elist_t;
1741673e404SJohn Birrell 
1751673e404SJohn Birrell /* Auxiliary structure for intrinsics (integers and reals) */
1761673e404SJohn Birrell typedef enum {
1771673e404SJohn Birrell 	INTR_INT,
1781673e404SJohn Birrell 	INTR_REAL
1791673e404SJohn Birrell } intrtype_t;
1801673e404SJohn Birrell 
1811673e404SJohn Birrell typedef struct intr {
1821673e404SJohn Birrell 	intrtype_t	intr_type;
1831673e404SJohn Birrell 	int		intr_signed;
1841673e404SJohn Birrell 	union {
1851673e404SJohn Birrell 			char _iformat;
1861673e404SJohn Birrell 			int _fformat;
1871673e404SJohn Birrell 	} _u;
1881673e404SJohn Birrell 	int		intr_offset;
1891673e404SJohn Birrell 	int		intr_nbits;
1901673e404SJohn Birrell } intr_t;
1911673e404SJohn Birrell 
1921673e404SJohn Birrell #define	intr_iformat _u._iformat
1931673e404SJohn Birrell #define	intr_fformat _u._fformat
1941673e404SJohn Birrell 
1951673e404SJohn Birrell typedef struct fnarg {
1961673e404SJohn Birrell 	char *fna_name;
1971673e404SJohn Birrell 	struct tdesc *fna_type;
1981673e404SJohn Birrell } fnarg_t;
1991673e404SJohn Birrell 
2001673e404SJohn Birrell #define	FN_F_GLOBAL	0x1
2011673e404SJohn Birrell #define	FN_F_VARARGS	0x2
2021673e404SJohn Birrell 
2031673e404SJohn Birrell typedef struct fndef {
2041673e404SJohn Birrell 	struct tdesc *fn_ret;
2051673e404SJohn Birrell 	uint_t fn_nargs;
2061673e404SJohn Birrell 	tdesc_t **fn_args;
2071673e404SJohn Birrell 	uint_t fn_vargs;
2081673e404SJohn Birrell } fndef_t;
2091673e404SJohn Birrell 
2101673e404SJohn Birrell typedef int32_t tid_t;
2111673e404SJohn Birrell 
2121673e404SJohn Birrell /*
2131673e404SJohn Birrell  * The tdesc_t (Type DESCription) is the basic node type used in the stabs data
2141673e404SJohn Birrell  * structure.  Each data node gets a tdesc structure.  Each node is linked into
2151673e404SJohn Birrell  * a directed graph (think of it as a tree with multiple roots and multiple
2161673e404SJohn Birrell  * leaves), with the root nodes at the top, and intrinsics at the bottom.  The
2171673e404SJohn Birrell  * root nodes, which are pointed to by iidesc nodes, correspond to the types,
2181673e404SJohn Birrell  * globals, and statics defined by the stabs.
2191673e404SJohn Birrell  */
2201673e404SJohn Birrell struct tdesc {
2211673e404SJohn Birrell 	char	*t_name;
2221673e404SJohn Birrell 	tdesc_t *t_next;	/* Name hash next pointer */
2231673e404SJohn Birrell 
2241673e404SJohn Birrell 	tid_t t_id;
2251673e404SJohn Birrell 	tdesc_t *t_hash;	/* ID hash next pointer */
2261673e404SJohn Birrell 
2271673e404SJohn Birrell 	stabtype_t t_type;
2281673e404SJohn Birrell 	int	t_size;	/* Size in bytes of object represented by this node */
2291673e404SJohn Birrell 
2301673e404SJohn Birrell 	union {
2311673e404SJohn Birrell 		intr_t	*intr;		/* int, real */
2321673e404SJohn Birrell 		tdesc_t *tdesc;		/* ptr, typedef, vol, const, restr */
2331673e404SJohn Birrell 		ardef_t *ardef;		/* array */
2341673e404SJohn Birrell 		mlist_t *members;	/* struct, union */
2351673e404SJohn Birrell 		elist_t *emem;		/* enum */
2361673e404SJohn Birrell 		fndef_t *fndef;		/* function - first is return type */
2371673e404SJohn Birrell 	} t_data;
2381673e404SJohn Birrell 
2391673e404SJohn Birrell 	int t_flags;
2401673e404SJohn Birrell 	int t_vgen;	/* Visitation generation (see traverse.c) */
2411673e404SJohn Birrell 	int t_emark;	/* Equality mark (see equiv_cb() in merge.c) */
2421673e404SJohn Birrell };
2431673e404SJohn Birrell 
2441673e404SJohn Birrell #define	t_intr		t_data.intr
2451673e404SJohn Birrell #define	t_tdesc		t_data.tdesc
2461673e404SJohn Birrell #define	t_ardef		t_data.ardef
2471673e404SJohn Birrell #define	t_members	t_data.members
2481673e404SJohn Birrell #define	t_emem		t_data.emem
2491673e404SJohn Birrell #define	t_fndef		t_data.fndef
2501673e404SJohn Birrell 
2511673e404SJohn Birrell #define	TDESC_F_ISROOT		0x1	/* Has an iidesc_t (see below) */
2521673e404SJohn Birrell #define	TDESC_F_GLOBAL		0x2
2531673e404SJohn Birrell #define	TDESC_F_RESOLVED	0x4
2541673e404SJohn Birrell 
2551673e404SJohn Birrell /*
2561673e404SJohn Birrell  * iidesc_t (Interesting Item DESCription) nodes point to tdesc_t nodes that
2571673e404SJohn Birrell  * correspond to "interesting" stabs.  A stab is interesting if it defines a
2581673e404SJohn Birrell  * global or static variable, a global or static function, or a data type.
2591673e404SJohn Birrell  */
2601673e404SJohn Birrell typedef enum iitype {
2611673e404SJohn Birrell 	II_NOT = 0,
2621673e404SJohn Birrell 	II_GFUN,	/* Global function */
2631673e404SJohn Birrell 	II_SFUN,	/* Static function */
2641673e404SJohn Birrell 	II_GVAR,	/* Global variable */
2651673e404SJohn Birrell 	II_SVAR,	/* Static variable */
2661673e404SJohn Birrell 	II_PSYM,	/* Function argument */
2671673e404SJohn Birrell 	II_SOU,		/* Struct or union */
2681673e404SJohn Birrell 	II_TYPE		/* Type (typedef) */
2691673e404SJohn Birrell } iitype_t;
2701673e404SJohn Birrell 
2711673e404SJohn Birrell typedef struct iidesc {
2721673e404SJohn Birrell 	iitype_t	ii_type;
2731673e404SJohn Birrell 	char		*ii_name;
2741673e404SJohn Birrell 	tdesc_t 	*ii_dtype;
2751673e404SJohn Birrell 	char		*ii_owner;	/* File that defined this node */
2761673e404SJohn Birrell 	int		ii_flags;
2771673e404SJohn Birrell 
2781673e404SJohn Birrell 	/* Function arguments (if any) */
2791673e404SJohn Birrell 	int		ii_nargs;
2801673e404SJohn Birrell 	tdesc_t 	**ii_args;
2811673e404SJohn Birrell 	int		ii_vargs;	/* Function uses varargs */
2821673e404SJohn Birrell } iidesc_t;
2831673e404SJohn Birrell 
2841673e404SJohn Birrell #define	IIDESC_F_USED	0x1	/* Write this iidesc out */
2851673e404SJohn Birrell 
2861673e404SJohn Birrell /*
2871673e404SJohn Birrell  * labelent_t nodes identify labels and corresponding type ranges associated
2881673e404SJohn Birrell  * with them.  The label in a given labelent_t is associated with types with
2891673e404SJohn Birrell  * ids <= le_idx.
2901673e404SJohn Birrell  */
2911673e404SJohn Birrell typedef struct labelent {
2921673e404SJohn Birrell 	char *le_name;
2931673e404SJohn Birrell 	int le_idx;
2941673e404SJohn Birrell } labelent_t;
2951673e404SJohn Birrell 
2961673e404SJohn Birrell /*
2971673e404SJohn Birrell  * The tdata_t (Type DATA) structure contains or references all type data for
2981673e404SJohn Birrell  * a given file or, during merging, several files.
2991673e404SJohn Birrell  */
3001673e404SJohn Birrell typedef struct tdata {
3011673e404SJohn Birrell 	int	td_curemark;	/* Equality mark (see merge.c) */
3021673e404SJohn Birrell 	int	td_curvgen;	/* Visitation generation (see traverse.c) */
3031673e404SJohn Birrell 	int	td_nextid;	/* The ID for the next tdesc_t created */
3041673e404SJohn Birrell 	hash_t	*td_iihash;	/* The iidesc_t nodes for this file */
3051673e404SJohn Birrell 
3061673e404SJohn Birrell 	hash_t	*td_layouthash;	/* The tdesc nodes, hashed by structure */
3071673e404SJohn Birrell 	hash_t	*td_idhash;	/* The tdesc nodes, hashed by type id */
3081673e404SJohn Birrell 	list_t	*td_fwdlist;	/* All forward declaration tdesc nodes */
3091673e404SJohn Birrell 
3101673e404SJohn Birrell 	char	*td_parlabel;	/* Top label uniq'd against in parent */
3111673e404SJohn Birrell 	char	*td_parname;	/* Basename of parent */
3121673e404SJohn Birrell 	list_t	*td_labels;	/* Labels and their type ranges */
3131673e404SJohn Birrell 
3141673e404SJohn Birrell 	pthread_mutex_t td_mergelock;
3151673e404SJohn Birrell 
3161673e404SJohn Birrell 	int	td_ref;
3171673e404SJohn Birrell } tdata_t;
3181673e404SJohn Birrell 
3191673e404SJohn Birrell /*
3201673e404SJohn Birrell  * By design, the iidesc hash is heterogeneous.  The CTF emitter, on the
3211673e404SJohn Birrell  * other hand, needs to be able to access the elements of the list by type,
3221673e404SJohn Birrell  * and in a specific sorted order.  An iiburst holds these elements in that
3231673e404SJohn Birrell  * order.  (A burster is a machine that separates carbon-copy forms)
3241673e404SJohn Birrell  */
3251673e404SJohn Birrell typedef struct iiburst {
3261673e404SJohn Birrell 	int iib_nfuncs;
3271673e404SJohn Birrell 	int iib_curfunc;
3281673e404SJohn Birrell 	iidesc_t **iib_funcs;
3291673e404SJohn Birrell 
3301673e404SJohn Birrell 	int iib_nobjts;
3311673e404SJohn Birrell 	int iib_curobjt;
3321673e404SJohn Birrell 	iidesc_t **iib_objts;
3331673e404SJohn Birrell 
3341673e404SJohn Birrell 	list_t *iib_types;
3351673e404SJohn Birrell 	int iib_maxtypeid;
3361673e404SJohn Birrell 
3371673e404SJohn Birrell 	tdata_t *iib_td;
3381673e404SJohn Birrell 	struct tdtrav_data *iib_tdtd; /* tdtrav_data_t */
3391673e404SJohn Birrell } iiburst_t;
3401673e404SJohn Birrell 
3411673e404SJohn Birrell typedef struct ctf_buf ctf_buf_t;
3421673e404SJohn Birrell 
3431673e404SJohn Birrell typedef struct symit_data symit_data_t;
3441673e404SJohn Birrell 
3451673e404SJohn Birrell /* fixup_tdescs.c */
3461673e404SJohn Birrell void cvt_fixstabs(tdata_t *);
3471673e404SJohn Birrell void cvt_fixups(tdata_t *, size_t);
3481673e404SJohn Birrell 
3491673e404SJohn Birrell /* ctf.c */
3501673e404SJohn Birrell caddr_t ctf_gen(iiburst_t *, size_t *, int);
3511673e404SJohn Birrell tdata_t *ctf_load(char *, caddr_t, size_t, symit_data_t *, char *);
3521673e404SJohn Birrell 
3531673e404SJohn Birrell /* iidesc.c */
3541673e404SJohn Birrell iidesc_t *iidesc_new(char *);
3551673e404SJohn Birrell int iidesc_hash(int, void *);
3561673e404SJohn Birrell void iter_iidescs_by_name(tdata_t *, const char *,
3571673e404SJohn Birrell     int (*)(void *, void *), void *);
3581673e404SJohn Birrell iidesc_t *iidesc_dup(iidesc_t *);
3591673e404SJohn Birrell iidesc_t *iidesc_dup_rename(iidesc_t *, char const *, char const *);
3601673e404SJohn Birrell void iidesc_add(hash_t *, iidesc_t *);
3611673e404SJohn Birrell void iidesc_free(void *, void *);
3621673e404SJohn Birrell int iidesc_count_type(void *, void *);
3631673e404SJohn Birrell void iidesc_stats(hash_t *);
3641673e404SJohn Birrell int iidesc_dump(iidesc_t *);
3651673e404SJohn Birrell 
3661673e404SJohn Birrell /* input.c */
3671673e404SJohn Birrell typedef enum source_types {
3681673e404SJohn Birrell 	SOURCE_NONE 	= 0,
3691673e404SJohn Birrell 	SOURCE_UNKNOWN	= 1,
3701673e404SJohn Birrell 	SOURCE_C	= 2,
3711673e404SJohn Birrell 	SOURCE_S	= 4
3721673e404SJohn Birrell } source_types_t;
3731673e404SJohn Birrell 
3741673e404SJohn Birrell source_types_t built_source_types(Elf *, const char *);
3751673e404SJohn Birrell int count_files(char **, int);
3761673e404SJohn Birrell int read_ctf(char **, int, char *, int (*)(tdata_t *, char *, void *),
3771673e404SJohn Birrell     void *, int);
3781673e404SJohn Birrell int read_ctf_save_cb(tdata_t *, char *, void *);
3791673e404SJohn Birrell symit_data_t *symit_new(Elf *, const char *);
3801673e404SJohn Birrell void symit_reset(symit_data_t *);
3811673e404SJohn Birrell char *symit_curfile(symit_data_t *);
3821673e404SJohn Birrell GElf_Sym *symit_next(symit_data_t *, int);
3831673e404SJohn Birrell char *symit_name(symit_data_t *);
3841673e404SJohn Birrell void symit_free(symit_data_t *);
3851673e404SJohn Birrell 
3861673e404SJohn Birrell /* merge.c */
3871673e404SJohn Birrell void merge_into_master(tdata_t *, tdata_t *, tdata_t *, int);
3881673e404SJohn Birrell 
3891673e404SJohn Birrell /* output.c */
3901673e404SJohn Birrell #define	CTF_FUZZY_MATCH	0x1 /* match local symbols to global CTF */
3911673e404SJohn Birrell #define	CTF_USE_DYNSYM	0x2 /* use .dynsym not .symtab */
3921673e404SJohn Birrell #define	CTF_COMPRESS	0x4 /* compress CTF output */
3931673e404SJohn Birrell #define	CTF_KEEP_STABS	0x8 /* keep .stabs sections */
3941673e404SJohn Birrell 
3951673e404SJohn Birrell void write_ctf(tdata_t *, const char *, const char *, int);
3961673e404SJohn Birrell 
3971673e404SJohn Birrell /* parse.c */
3981673e404SJohn Birrell void parse_init(tdata_t *);
3991673e404SJohn Birrell void parse_finish(tdata_t *);
4001673e404SJohn Birrell int parse_stab(stab_t *, char *, iidesc_t **);
4011673e404SJohn Birrell tdesc_t *lookup(int);
4021673e404SJohn Birrell tdesc_t *lookupname(const char *);
4031673e404SJohn Birrell void check_hash(void);
4041673e404SJohn Birrell void resolve_typed_bitfields(void);
4051673e404SJohn Birrell 
4061673e404SJohn Birrell /* stabs.c */
4071673e404SJohn Birrell int stabs_read(tdata_t *, Elf *, char *);
4081673e404SJohn Birrell 
4091673e404SJohn Birrell /* dwarf.c */
4101673e404SJohn Birrell int dw_read(tdata_t *, Elf *, char *);
4111673e404SJohn Birrell const char *dw_tag2str(uint_t);
4121673e404SJohn Birrell 
4131673e404SJohn Birrell /* tdata.c */
4141673e404SJohn Birrell tdata_t *tdata_new(void);
4151673e404SJohn Birrell void tdata_free(tdata_t *);
4161673e404SJohn Birrell void tdata_build_hashes(tdata_t *td);
4171673e404SJohn Birrell const char *tdesc_name(tdesc_t *);
4181673e404SJohn Birrell int tdesc_idhash(int, void *);
4191673e404SJohn Birrell int tdesc_idcmp(void *, void *);
4201673e404SJohn Birrell int tdesc_namehash(int, void *);
4211673e404SJohn Birrell int tdesc_namecmp(void *, void *);
4221673e404SJohn Birrell int tdesc_layouthash(int, void *);
4231673e404SJohn Birrell int tdesc_layoutcmp(void *, void *);
4241673e404SJohn Birrell void tdesc_free(tdesc_t *);
4251673e404SJohn Birrell void tdata_label_add(tdata_t *, const char *, int);
4261673e404SJohn Birrell labelent_t *tdata_label_top(tdata_t *);
4271673e404SJohn Birrell int tdata_label_find(tdata_t *, char *);
4281673e404SJohn Birrell void tdata_label_free(tdata_t *);
4291673e404SJohn Birrell void tdata_merge(tdata_t *, tdata_t *);
4301673e404SJohn Birrell void tdata_label_newmax(tdata_t *, int);
4311673e404SJohn Birrell 
4321673e404SJohn Birrell /* util.c */
4331673e404SJohn Birrell int streq(const char *, const char *);
4341673e404SJohn Birrell int findelfsecidx(Elf *, const char *, const char *);
4351673e404SJohn Birrell size_t elf_ptrsz(Elf *);
4361673e404SJohn Birrell char *mktmpname(const char *, const char *);
4371673e404SJohn Birrell void terminate(const char *, ...);
4381673e404SJohn Birrell void aborterr(const char *, ...);
4391673e404SJohn Birrell void set_terminate_cleanup(void (*)(void));
4401673e404SJohn Birrell void elfterminate(const char *, const char *, ...);
4411673e404SJohn Birrell void warning(const char *, ...);
4421673e404SJohn Birrell void vadebug(int, const char *, va_list);
4431673e404SJohn Birrell void debug(int, const char *, ...);
4441673e404SJohn Birrell 
4451673e404SJohn Birrell 
4461673e404SJohn Birrell void watch_dump(int);
4471673e404SJohn Birrell void watch_set(void *, int);
4481673e404SJohn Birrell 
4491673e404SJohn Birrell #ifdef __cplusplus
4501673e404SJohn Birrell }
4511673e404SJohn Birrell #endif
4521673e404SJohn Birrell 
4531673e404SJohn Birrell #endif /* _CTFTOOLS_H */
454