1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _CTF_IMPL_H 28*7c478bd9Sstevel@tonic-gate #define _CTF_IMPL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 33*7c478bd9Sstevel@tonic-gate #include <sys/errno.h> 34*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 35*7c478bd9Sstevel@tonic-gate #include <sys/ctf_api.h> 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate #include <sys/systm.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 41*7c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 42*7c478bd9Sstevel@tonic-gate 43*7c478bd9Sstevel@tonic-gate #define isspace(c) \ 44*7c478bd9Sstevel@tonic-gate ((c) == ' ' || (c) == '\t' || (c) == '\n' || \ 45*7c478bd9Sstevel@tonic-gate (c) == '\r' || (c) == '\f' || (c) == '\v') 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #define MAP_FAILED ((void *)-1) 48*7c478bd9Sstevel@tonic-gate 49*7c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate #include <strings.h> 52*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 53*7c478bd9Sstevel@tonic-gate #include <stdarg.h> 54*7c478bd9Sstevel@tonic-gate #include <stdio.h> 55*7c478bd9Sstevel@tonic-gate #include <limits.h> 56*7c478bd9Sstevel@tonic-gate #include <ctype.h> 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 61*7c478bd9Sstevel@tonic-gate extern "C" { 62*7c478bd9Sstevel@tonic-gate #endif 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate typedef struct ctf_helem { 65*7c478bd9Sstevel@tonic-gate uint_t h_name; /* reference to name in string table */ 66*7c478bd9Sstevel@tonic-gate ushort_t h_type; /* corresponding type ID number */ 67*7c478bd9Sstevel@tonic-gate ushort_t h_next; /* index of next element in hash chain */ 68*7c478bd9Sstevel@tonic-gate } ctf_helem_t; 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate typedef struct ctf_hash { 71*7c478bd9Sstevel@tonic-gate ushort_t *h_buckets; /* hash bucket array (chain indices) */ 72*7c478bd9Sstevel@tonic-gate ctf_helem_t *h_chains; /* hash chains buffer */ 73*7c478bd9Sstevel@tonic-gate ushort_t h_nbuckets; /* number of elements in bucket array */ 74*7c478bd9Sstevel@tonic-gate ushort_t h_nelems; /* number of elements in hash table */ 75*7c478bd9Sstevel@tonic-gate uint_t h_free; /* index of next free hash element */ 76*7c478bd9Sstevel@tonic-gate } ctf_hash_t; 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate typedef struct ctf_strs { 79*7c478bd9Sstevel@tonic-gate const char *cts_strs; /* base address of string table */ 80*7c478bd9Sstevel@tonic-gate size_t cts_len; /* size of string table in bytes */ 81*7c478bd9Sstevel@tonic-gate } ctf_strs_t; 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate typedef struct ctf_dmodel { 84*7c478bd9Sstevel@tonic-gate const char *ctd_name; /* data model name */ 85*7c478bd9Sstevel@tonic-gate int ctd_code; /* data model code */ 86*7c478bd9Sstevel@tonic-gate size_t ctd_pointer; /* size of void * in bytes */ 87*7c478bd9Sstevel@tonic-gate size_t ctd_char; /* size of char in bytes */ 88*7c478bd9Sstevel@tonic-gate size_t ctd_short; /* size of short in bytes */ 89*7c478bd9Sstevel@tonic-gate size_t ctd_int; /* size of int in bytes */ 90*7c478bd9Sstevel@tonic-gate size_t ctd_long; /* size of long in bytes */ 91*7c478bd9Sstevel@tonic-gate } ctf_dmodel_t; 92*7c478bd9Sstevel@tonic-gate 93*7c478bd9Sstevel@tonic-gate typedef struct ctf_lookup { 94*7c478bd9Sstevel@tonic-gate const char *ctl_prefix; /* string prefix for this lookup */ 95*7c478bd9Sstevel@tonic-gate size_t ctl_len; /* length of prefix string in bytes */ 96*7c478bd9Sstevel@tonic-gate ctf_hash_t *ctl_hash; /* pointer to hash table for lookup */ 97*7c478bd9Sstevel@tonic-gate } ctf_lookup_t; 98*7c478bd9Sstevel@tonic-gate 99*7c478bd9Sstevel@tonic-gate typedef struct ctf_fileops { 100*7c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_kind)(ushort_t); 101*7c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_root)(ushort_t); 102*7c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_vlen)(ushort_t); 103*7c478bd9Sstevel@tonic-gate } ctf_fileops_t; 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate typedef struct ctf_list { 106*7c478bd9Sstevel@tonic-gate struct ctf_list *l_prev; /* previous pointer or tail pointer */ 107*7c478bd9Sstevel@tonic-gate struct ctf_list *l_next; /* next pointer or head pointer */ 108*7c478bd9Sstevel@tonic-gate } ctf_list_t; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate typedef enum { 111*7c478bd9Sstevel@tonic-gate CTF_PREC_BASE, 112*7c478bd9Sstevel@tonic-gate CTF_PREC_POINTER, 113*7c478bd9Sstevel@tonic-gate CTF_PREC_ARRAY, 114*7c478bd9Sstevel@tonic-gate CTF_PREC_FUNCTION, 115*7c478bd9Sstevel@tonic-gate CTF_PREC_MAX 116*7c478bd9Sstevel@tonic-gate } ctf_decl_prec_t; 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate typedef struct ctf_decl_node { 119*7c478bd9Sstevel@tonic-gate ctf_list_t cd_list; /* linked list pointers */ 120*7c478bd9Sstevel@tonic-gate ctf_id_t cd_type; /* type identifier */ 121*7c478bd9Sstevel@tonic-gate uint_t cd_kind; /* type kind */ 122*7c478bd9Sstevel@tonic-gate uint_t cd_n; /* type dimension if array */ 123*7c478bd9Sstevel@tonic-gate } ctf_decl_node_t; 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate typedef struct ctf_decl { 126*7c478bd9Sstevel@tonic-gate ctf_list_t cd_nodes[CTF_PREC_MAX]; /* declaration node stacks */ 127*7c478bd9Sstevel@tonic-gate int cd_order[CTF_PREC_MAX]; /* storage order of decls */ 128*7c478bd9Sstevel@tonic-gate ctf_decl_prec_t cd_qualp; /* qualifier precision */ 129*7c478bd9Sstevel@tonic-gate ctf_decl_prec_t cd_ordp; /* ordered precision */ 130*7c478bd9Sstevel@tonic-gate char *cd_buf; /* buffer for output */ 131*7c478bd9Sstevel@tonic-gate char *cd_ptr; /* buffer location */ 132*7c478bd9Sstevel@tonic-gate char *cd_end; /* buffer limit */ 133*7c478bd9Sstevel@tonic-gate size_t cd_len; /* buffer space required */ 134*7c478bd9Sstevel@tonic-gate int cd_err; /* saved error value */ 135*7c478bd9Sstevel@tonic-gate } ctf_decl_t; 136*7c478bd9Sstevel@tonic-gate 137*7c478bd9Sstevel@tonic-gate typedef struct ctf_dmdef { 138*7c478bd9Sstevel@tonic-gate ctf_list_t dmd_list; /* list forward/back pointers */ 139*7c478bd9Sstevel@tonic-gate char *dmd_name; /* name of this member */ 140*7c478bd9Sstevel@tonic-gate ctf_id_t dmd_type; /* type of this member (for sou) */ 141*7c478bd9Sstevel@tonic-gate ulong_t dmd_offset; /* offset of this member in bits (for sou) */ 142*7c478bd9Sstevel@tonic-gate int dmd_value; /* value of this member (for enum) */ 143*7c478bd9Sstevel@tonic-gate } ctf_dmdef_t; 144*7c478bd9Sstevel@tonic-gate 145*7c478bd9Sstevel@tonic-gate typedef struct ctf_dtdef { 146*7c478bd9Sstevel@tonic-gate ctf_list_t dtd_list; /* list forward/back pointers */ 147*7c478bd9Sstevel@tonic-gate char *dtd_name; /* name associated with definition (if any) */ 148*7c478bd9Sstevel@tonic-gate ctf_id_t dtd_type; /* type identifier for this definition */ 149*7c478bd9Sstevel@tonic-gate ctf_type_t dtd_data; /* type node (see <sys/ctf.h>) */ 150*7c478bd9Sstevel@tonic-gate union { 151*7c478bd9Sstevel@tonic-gate ctf_list_t dtu_members; /* struct, union, or enum */ 152*7c478bd9Sstevel@tonic-gate ctf_arinfo_t dtu_arr; /* array */ 153*7c478bd9Sstevel@tonic-gate ctf_encoding_t dtu_enc; /* integer or float */ 154*7c478bd9Sstevel@tonic-gate ctf_id_t *dtu_argv; /* function */ 155*7c478bd9Sstevel@tonic-gate } dtd_u; 156*7c478bd9Sstevel@tonic-gate } ctf_dtdef_t; 157*7c478bd9Sstevel@tonic-gate 158*7c478bd9Sstevel@tonic-gate typedef struct ctf_bundle { 159*7c478bd9Sstevel@tonic-gate ctf_file_t *ctb_file; /* CTF container handle */ 160*7c478bd9Sstevel@tonic-gate ctf_id_t ctb_type; /* CTF type identifier */ 161*7c478bd9Sstevel@tonic-gate ctf_dtdef_t *ctb_dtd; /* CTF dynamic type definition (if any) */ 162*7c478bd9Sstevel@tonic-gate } ctf_bundle_t; 163*7c478bd9Sstevel@tonic-gate 164*7c478bd9Sstevel@tonic-gate /* 165*7c478bd9Sstevel@tonic-gate * The ctf_file is the structure used to represent a CTF container to library 166*7c478bd9Sstevel@tonic-gate * clients, who see it only as an opaque pointer. Modifications can therefore 167*7c478bd9Sstevel@tonic-gate * be made freely to this structure without regard to client versioning. The 168*7c478bd9Sstevel@tonic-gate * ctf_file_t typedef appears in <sys/ctf_api.h> and declares a forward tag. 169*7c478bd9Sstevel@tonic-gate * 170*7c478bd9Sstevel@tonic-gate * NOTE: ctf_update() requires that everything inside of ctf_file either be an 171*7c478bd9Sstevel@tonic-gate * immediate value, a pointer to dynamically allocated data *outside* of the 172*7c478bd9Sstevel@tonic-gate * ctf_file itself, or a pointer to statically allocated data. If you add a 173*7c478bd9Sstevel@tonic-gate * pointer to ctf_file that points to something within the ctf_file itself, 174*7c478bd9Sstevel@tonic-gate * you must make corresponding changes to ctf_update(). 175*7c478bd9Sstevel@tonic-gate */ 176*7c478bd9Sstevel@tonic-gate struct ctf_file { 177*7c478bd9Sstevel@tonic-gate const ctf_fileops_t *ctf_fileops; /* version-specific file operations */ 178*7c478bd9Sstevel@tonic-gate ctf_sect_t ctf_data; /* CTF data from object file */ 179*7c478bd9Sstevel@tonic-gate ctf_sect_t ctf_symtab; /* symbol table from object file */ 180*7c478bd9Sstevel@tonic-gate ctf_sect_t ctf_strtab; /* string table from object file */ 181*7c478bd9Sstevel@tonic-gate ctf_hash_t ctf_structs; /* hash table of struct types */ 182*7c478bd9Sstevel@tonic-gate ctf_hash_t ctf_unions; /* hash table of union types */ 183*7c478bd9Sstevel@tonic-gate ctf_hash_t ctf_enums; /* hash table of enum types */ 184*7c478bd9Sstevel@tonic-gate ctf_hash_t ctf_names; /* hash table of remaining type names */ 185*7c478bd9Sstevel@tonic-gate ctf_lookup_t ctf_lookups[5]; /* pointers to hashes for name lookup */ 186*7c478bd9Sstevel@tonic-gate ctf_strs_t ctf_str[2]; /* array of string table base and bounds */ 187*7c478bd9Sstevel@tonic-gate const uchar_t *ctf_base; /* base of CTF header + uncompressed buffer */ 188*7c478bd9Sstevel@tonic-gate const uchar_t *ctf_buf; /* uncompressed CTF data buffer */ 189*7c478bd9Sstevel@tonic-gate size_t ctf_size; /* size of CTF header + uncompressed data */ 190*7c478bd9Sstevel@tonic-gate uint_t *ctf_sxlate; /* translation table for symtab entries */ 191*7c478bd9Sstevel@tonic-gate ulong_t ctf_nsyms; /* number of entries in symtab xlate table */ 192*7c478bd9Sstevel@tonic-gate uint_t *ctf_txlate; /* translation table for type IDs */ 193*7c478bd9Sstevel@tonic-gate ushort_t *ctf_ptrtab; /* translation table for pointer-to lookups */ 194*7c478bd9Sstevel@tonic-gate ulong_t ctf_typemax; /* maximum valid type ID number */ 195*7c478bd9Sstevel@tonic-gate const ctf_dmodel_t *ctf_dmodel; /* data model pointer (see above) */ 196*7c478bd9Sstevel@tonic-gate struct ctf_file *ctf_parent; /* parent CTF container (if any) */ 197*7c478bd9Sstevel@tonic-gate const char *ctf_parlabel; /* label in parent container (if any) */ 198*7c478bd9Sstevel@tonic-gate const char *ctf_parname; /* basename of parent (if any) */ 199*7c478bd9Sstevel@tonic-gate uint_t ctf_refcnt; /* reference count (for parent links) */ 200*7c478bd9Sstevel@tonic-gate uint_t ctf_flags; /* libctf flags (see below) */ 201*7c478bd9Sstevel@tonic-gate int ctf_errno; /* error code for most recent error */ 202*7c478bd9Sstevel@tonic-gate int ctf_version; /* CTF data version */ 203*7c478bd9Sstevel@tonic-gate ctf_list_t ctf_dtdefs; /* list of dynamic type definitions */ 204*7c478bd9Sstevel@tonic-gate size_t ctf_dtstrlen; /* total length of dynamic type strings */ 205*7c478bd9Sstevel@tonic-gate ulong_t ctf_dtnextid; /* next dynamic type id to assign */ 206*7c478bd9Sstevel@tonic-gate ulong_t ctf_dtoldid; /* oldest id that has been committed */ 207*7c478bd9Sstevel@tonic-gate void *ctf_specific; /* data for ctf_get/setspecific */ 208*7c478bd9Sstevel@tonic-gate }; 209*7c478bd9Sstevel@tonic-gate 210*7c478bd9Sstevel@tonic-gate #define LCTF_INDEX_TO_TYPEPTR(fp, i) \ 211*7c478bd9Sstevel@tonic-gate ((ctf_type_t *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)])) 212*7c478bd9Sstevel@tonic-gate 213*7c478bd9Sstevel@tonic-gate #define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info)) 214*7c478bd9Sstevel@tonic-gate #define LCTF_INFO_ROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info)) 215*7c478bd9Sstevel@tonic-gate #define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info)) 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate #define LCTF_MMAP 0x0001 /* libctf should munmap buffers on close */ 218*7c478bd9Sstevel@tonic-gate #define LCTF_CHILD 0x0002 /* CTF container is a child */ 219*7c478bd9Sstevel@tonic-gate #define LCTF_RDWR 0x0004 /* CTF container is writable */ 220*7c478bd9Sstevel@tonic-gate #define LCTF_DIRTY 0x0008 /* CTF container has been modified */ 221*7c478bd9Sstevel@tonic-gate 222*7c478bd9Sstevel@tonic-gate #define ECTF_BASE 1000 /* base value for libctf errnos */ 223*7c478bd9Sstevel@tonic-gate 224*7c478bd9Sstevel@tonic-gate enum { 225*7c478bd9Sstevel@tonic-gate ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */ 226*7c478bd9Sstevel@tonic-gate ECTF_ELFVERS, /* ELF version is more recent than libctf */ 227*7c478bd9Sstevel@tonic-gate ECTF_CTFVERS, /* CTF version is more recent than libctf */ 228*7c478bd9Sstevel@tonic-gate ECTF_ENDIAN, /* data is different endian-ness than lib */ 229*7c478bd9Sstevel@tonic-gate ECTF_SYMTAB, /* symbol table uses invalid entry size */ 230*7c478bd9Sstevel@tonic-gate ECTF_SYMBAD, /* symbol table data buffer invalid */ 231*7c478bd9Sstevel@tonic-gate ECTF_STRBAD, /* string table data buffer invalid */ 232*7c478bd9Sstevel@tonic-gate ECTF_CORRUPT, /* file data corruption detected */ 233*7c478bd9Sstevel@tonic-gate ECTF_NOCTFDATA, /* ELF file does not contain CTF data */ 234*7c478bd9Sstevel@tonic-gate ECTF_NOCTFBUF, /* buffer does not contain CTF data */ 235*7c478bd9Sstevel@tonic-gate ECTF_NOSYMTAB, /* symbol table data is not available */ 236*7c478bd9Sstevel@tonic-gate ECTF_NOPARENT, /* parent CTF container is not available */ 237*7c478bd9Sstevel@tonic-gate ECTF_DMODEL, /* data model mismatch */ 238*7c478bd9Sstevel@tonic-gate ECTF_MMAP, /* failed to mmap a data section */ 239*7c478bd9Sstevel@tonic-gate ECTF_ZMISSING, /* decompression library not installed */ 240*7c478bd9Sstevel@tonic-gate ECTF_ZINIT, /* failed to initialize decompression library */ 241*7c478bd9Sstevel@tonic-gate ECTF_ZALLOC, /* failed to allocate decompression buffer */ 242*7c478bd9Sstevel@tonic-gate ECTF_DECOMPRESS, /* failed to decompress CTF data */ 243*7c478bd9Sstevel@tonic-gate ECTF_STRTAB, /* string table for this string is missing */ 244*7c478bd9Sstevel@tonic-gate ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */ 245*7c478bd9Sstevel@tonic-gate ECTF_BADID, /* invalid type ID number */ 246*7c478bd9Sstevel@tonic-gate ECTF_NOTSOU, /* type is not a struct or union */ 247*7c478bd9Sstevel@tonic-gate ECTF_NOTENUM, /* type is not an enum */ 248*7c478bd9Sstevel@tonic-gate ECTF_NOTSUE, /* type is not a struct, union, or enum */ 249*7c478bd9Sstevel@tonic-gate ECTF_NOTINTFP, /* type is not an integer or float */ 250*7c478bd9Sstevel@tonic-gate ECTF_NOTARRAY, /* type is not an array */ 251*7c478bd9Sstevel@tonic-gate ECTF_NOTREF, /* type does not reference another type */ 252*7c478bd9Sstevel@tonic-gate ECTF_NAMELEN, /* buffer is too small to hold type name */ 253*7c478bd9Sstevel@tonic-gate ECTF_NOTYPE, /* no type found corresponding to name */ 254*7c478bd9Sstevel@tonic-gate ECTF_SYNTAX, /* syntax error in type name */ 255*7c478bd9Sstevel@tonic-gate ECTF_NOTFUNC, /* symtab entry does not refer to a function */ 256*7c478bd9Sstevel@tonic-gate ECTF_NOFUNCDAT, /* no func info available for function */ 257*7c478bd9Sstevel@tonic-gate ECTF_NOTDATA, /* symtab entry does not refer to a data obj */ 258*7c478bd9Sstevel@tonic-gate ECTF_NOTYPEDAT, /* no type info available for object */ 259*7c478bd9Sstevel@tonic-gate ECTF_NOLABEL, /* no label found corresponding to name */ 260*7c478bd9Sstevel@tonic-gate ECTF_NOLABELDATA, /* file does not contain any labels */ 261*7c478bd9Sstevel@tonic-gate ECTF_NOTSUP, /* feature not supported */ 262*7c478bd9Sstevel@tonic-gate ECTF_NOENUMNAM, /* enum element name not found */ 263*7c478bd9Sstevel@tonic-gate ECTF_NOMEMBNAM, /* member name not found */ 264*7c478bd9Sstevel@tonic-gate ECTF_RDONLY, /* CTF container is read-only */ 265*7c478bd9Sstevel@tonic-gate ECTF_DTFULL, /* CTF type is full (no more members allowed) */ 266*7c478bd9Sstevel@tonic-gate ECTF_FULL, /* CTF container is full */ 267*7c478bd9Sstevel@tonic-gate ECTF_DUPMEMBER, /* duplicate member name definition */ 268*7c478bd9Sstevel@tonic-gate ECTF_CONFLICT /* conflicting type definition present */ 269*7c478bd9Sstevel@tonic-gate }; 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const ctf_type_t *, 272*7c478bd9Sstevel@tonic-gate ssize_t *, ssize_t *); 273*7c478bd9Sstevel@tonic-gate 274*7c478bd9Sstevel@tonic-gate extern const ctf_type_t *ctf_lookup_by_id(ctf_file_t **, ctf_id_t); 275*7c478bd9Sstevel@tonic-gate 276*7c478bd9Sstevel@tonic-gate extern int ctf_hash_create(ctf_hash_t *, ulong_t); 277*7c478bd9Sstevel@tonic-gate extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t); 278*7c478bd9Sstevel@tonic-gate extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *, 279*7c478bd9Sstevel@tonic-gate const char *, size_t); 280*7c478bd9Sstevel@tonic-gate extern uint_t ctf_hash_size(const ctf_hash_t *); 281*7c478bd9Sstevel@tonic-gate extern void ctf_hash_destroy(ctf_hash_t *); 282*7c478bd9Sstevel@tonic-gate 283*7c478bd9Sstevel@tonic-gate #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) 284*7c478bd9Sstevel@tonic-gate #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) 285*7c478bd9Sstevel@tonic-gate 286*7c478bd9Sstevel@tonic-gate extern void ctf_list_append(ctf_list_t *, void *); 287*7c478bd9Sstevel@tonic-gate extern void ctf_list_prepend(ctf_list_t *, void *); 288*7c478bd9Sstevel@tonic-gate extern void ctf_list_delete(ctf_list_t *, void *); 289*7c478bd9Sstevel@tonic-gate 290*7c478bd9Sstevel@tonic-gate extern void ctf_decl_init(ctf_decl_t *, char *, size_t); 291*7c478bd9Sstevel@tonic-gate extern void ctf_decl_fini(ctf_decl_t *); 292*7c478bd9Sstevel@tonic-gate extern void ctf_decl_push(ctf_decl_t *, ctf_file_t *, ctf_id_t); 293*7c478bd9Sstevel@tonic-gate extern void ctf_decl_sprintf(ctf_decl_t *, const char *, ...); 294*7c478bd9Sstevel@tonic-gate 295*7c478bd9Sstevel@tonic-gate extern const char *ctf_strraw(ctf_file_t *, uint_t); 296*7c478bd9Sstevel@tonic-gate extern const char *ctf_strptr(ctf_file_t *, uint_t); 297*7c478bd9Sstevel@tonic-gate 298*7c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_set_open_errno(int *, int); 299*7c478bd9Sstevel@tonic-gate extern long ctf_set_errno(ctf_file_t *, int); 300*7c478bd9Sstevel@tonic-gate 301*7c478bd9Sstevel@tonic-gate extern const void *ctf_sect_mmap(ctf_sect_t *, int); 302*7c478bd9Sstevel@tonic-gate extern void ctf_sect_munmap(const ctf_sect_t *); 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate extern void *ctf_data_alloc(size_t); 305*7c478bd9Sstevel@tonic-gate extern void ctf_data_free(void *, size_t); 306*7c478bd9Sstevel@tonic-gate extern void ctf_data_protect(void *, size_t); 307*7c478bd9Sstevel@tonic-gate 308*7c478bd9Sstevel@tonic-gate extern void *ctf_alloc(size_t); 309*7c478bd9Sstevel@tonic-gate extern void ctf_free(void *, size_t); 310*7c478bd9Sstevel@tonic-gate 311*7c478bd9Sstevel@tonic-gate extern char *ctf_strdup(const char *); 312*7c478bd9Sstevel@tonic-gate extern const char *ctf_strerror(int); 313*7c478bd9Sstevel@tonic-gate extern void ctf_dprintf(const char *, ...); 314*7c478bd9Sstevel@tonic-gate 315*7c478bd9Sstevel@tonic-gate extern void *ctf_zopen(int *); 316*7c478bd9Sstevel@tonic-gate 317*7c478bd9Sstevel@tonic-gate extern const char _CTF_SECTION[]; /* name of CTF ELF section */ 318*7c478bd9Sstevel@tonic-gate extern const char _CTF_NULLSTR[]; /* empty string */ 319*7c478bd9Sstevel@tonic-gate 320*7c478bd9Sstevel@tonic-gate extern int _libctf_version; /* library client version */ 321*7c478bd9Sstevel@tonic-gate extern int _libctf_debug; /* debugging messages enabled */ 322*7c478bd9Sstevel@tonic-gate 323*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 324*7c478bd9Sstevel@tonic-gate } 325*7c478bd9Sstevel@tonic-gate #endif 326*7c478bd9Sstevel@tonic-gate 327*7c478bd9Sstevel@tonic-gate #endif /* _CTF_IMPL_H */ 328