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