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