17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 22e4586ebfSmws 237c478bd9Sstevel@tonic-gate /* 24e4586ebfSmws * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 257c478bd9Sstevel@tonic-gate * Use is subject to license terms. 267c478bd9Sstevel@tonic-gate */ 27*0a47c91cSRobert Mustacchi /* 28*0a47c91cSRobert Mustacchi * Copyright (c) 2012, Joyent, Inc. All rights reserved. 29*0a47c91cSRobert Mustacchi */ 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifndef _CTF_IMPL_H 327c478bd9Sstevel@tonic-gate #define _CTF_IMPL_H 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #include <sys/types.h> 357c478bd9Sstevel@tonic-gate #include <sys/errno.h> 367c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 377c478bd9Sstevel@tonic-gate #include <sys/ctf_api.h> 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #ifdef _KERNEL 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #include <sys/systm.h> 427c478bd9Sstevel@tonic-gate #include <sys/cmn_err.h> 437c478bd9Sstevel@tonic-gate #include <sys/varargs.h> 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define isspace(c) \ 467c478bd9Sstevel@tonic-gate ((c) == ' ' || (c) == '\t' || (c) == '\n' || \ 477c478bd9Sstevel@tonic-gate (c) == '\r' || (c) == '\f' || (c) == '\v') 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define MAP_FAILED ((void *)-1) 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate #else /* _KERNEL */ 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #include <strings.h> 547c478bd9Sstevel@tonic-gate #include <stdlib.h> 557c478bd9Sstevel@tonic-gate #include <stdarg.h> 567c478bd9Sstevel@tonic-gate #include <stdio.h> 577c478bd9Sstevel@tonic-gate #include <limits.h> 587c478bd9Sstevel@tonic-gate #include <ctype.h> 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #ifdef __cplusplus 637c478bd9Sstevel@tonic-gate extern "C" { 647c478bd9Sstevel@tonic-gate #endif 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate typedef struct ctf_helem { 677c478bd9Sstevel@tonic-gate uint_t h_name; /* reference to name in string table */ 687c478bd9Sstevel@tonic-gate ushort_t h_type; /* corresponding type ID number */ 697c478bd9Sstevel@tonic-gate ushort_t h_next; /* index of next element in hash chain */ 707c478bd9Sstevel@tonic-gate } ctf_helem_t; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate typedef struct ctf_hash { 737c478bd9Sstevel@tonic-gate ushort_t *h_buckets; /* hash bucket array (chain indices) */ 747c478bd9Sstevel@tonic-gate ctf_helem_t *h_chains; /* hash chains buffer */ 757c478bd9Sstevel@tonic-gate ushort_t h_nbuckets; /* number of elements in bucket array */ 767c478bd9Sstevel@tonic-gate ushort_t h_nelems; /* number of elements in hash table */ 777c478bd9Sstevel@tonic-gate uint_t h_free; /* index of next free hash element */ 787c478bd9Sstevel@tonic-gate } ctf_hash_t; 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate typedef struct ctf_strs { 817c478bd9Sstevel@tonic-gate const char *cts_strs; /* base address of string table */ 827c478bd9Sstevel@tonic-gate size_t cts_len; /* size of string table in bytes */ 837c478bd9Sstevel@tonic-gate } ctf_strs_t; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate typedef struct ctf_dmodel { 867c478bd9Sstevel@tonic-gate const char *ctd_name; /* data model name */ 877c478bd9Sstevel@tonic-gate int ctd_code; /* data model code */ 887c478bd9Sstevel@tonic-gate size_t ctd_pointer; /* size of void * in bytes */ 897c478bd9Sstevel@tonic-gate size_t ctd_char; /* size of char in bytes */ 907c478bd9Sstevel@tonic-gate size_t ctd_short; /* size of short in bytes */ 917c478bd9Sstevel@tonic-gate size_t ctd_int; /* size of int in bytes */ 927c478bd9Sstevel@tonic-gate size_t ctd_long; /* size of long in bytes */ 937c478bd9Sstevel@tonic-gate } ctf_dmodel_t; 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate typedef struct ctf_lookup { 967c478bd9Sstevel@tonic-gate const char *ctl_prefix; /* string prefix for this lookup */ 977c478bd9Sstevel@tonic-gate size_t ctl_len; /* length of prefix string in bytes */ 987c478bd9Sstevel@tonic-gate ctf_hash_t *ctl_hash; /* pointer to hash table for lookup */ 997c478bd9Sstevel@tonic-gate } ctf_lookup_t; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate typedef struct ctf_fileops { 1027c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_kind)(ushort_t); 1037c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_root)(ushort_t); 1047c478bd9Sstevel@tonic-gate ushort_t (*ctfo_get_vlen)(ushort_t); 1057c478bd9Sstevel@tonic-gate } ctf_fileops_t; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate typedef struct ctf_list { 1087c478bd9Sstevel@tonic-gate struct ctf_list *l_prev; /* previous pointer or tail pointer */ 1097c478bd9Sstevel@tonic-gate struct ctf_list *l_next; /* next pointer or head pointer */ 1107c478bd9Sstevel@tonic-gate } ctf_list_t; 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate typedef enum { 1137c478bd9Sstevel@tonic-gate CTF_PREC_BASE, 1147c478bd9Sstevel@tonic-gate CTF_PREC_POINTER, 1157c478bd9Sstevel@tonic-gate CTF_PREC_ARRAY, 1167c478bd9Sstevel@tonic-gate CTF_PREC_FUNCTION, 1177c478bd9Sstevel@tonic-gate CTF_PREC_MAX 1187c478bd9Sstevel@tonic-gate } ctf_decl_prec_t; 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate typedef struct ctf_decl_node { 1217c478bd9Sstevel@tonic-gate ctf_list_t cd_list; /* linked list pointers */ 1227c478bd9Sstevel@tonic-gate ctf_id_t cd_type; /* type identifier */ 1237c478bd9Sstevel@tonic-gate uint_t cd_kind; /* type kind */ 1247c478bd9Sstevel@tonic-gate uint_t cd_n; /* type dimension if array */ 1257c478bd9Sstevel@tonic-gate } ctf_decl_node_t; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate typedef struct ctf_decl { 1287c478bd9Sstevel@tonic-gate ctf_list_t cd_nodes[CTF_PREC_MAX]; /* declaration node stacks */ 1297c478bd9Sstevel@tonic-gate int cd_order[CTF_PREC_MAX]; /* storage order of decls */ 1307c478bd9Sstevel@tonic-gate ctf_decl_prec_t cd_qualp; /* qualifier precision */ 1317c478bd9Sstevel@tonic-gate ctf_decl_prec_t cd_ordp; /* ordered precision */ 1327c478bd9Sstevel@tonic-gate char *cd_buf; /* buffer for output */ 1337c478bd9Sstevel@tonic-gate char *cd_ptr; /* buffer location */ 1347c478bd9Sstevel@tonic-gate char *cd_end; /* buffer limit */ 1357c478bd9Sstevel@tonic-gate size_t cd_len; /* buffer space required */ 1367c478bd9Sstevel@tonic-gate int cd_err; /* saved error value */ 1377c478bd9Sstevel@tonic-gate } ctf_decl_t; 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate typedef struct ctf_dmdef { 1407c478bd9Sstevel@tonic-gate ctf_list_t dmd_list; /* list forward/back pointers */ 1417c478bd9Sstevel@tonic-gate char *dmd_name; /* name of this member */ 1427c478bd9Sstevel@tonic-gate ctf_id_t dmd_type; /* type of this member (for sou) */ 1437c478bd9Sstevel@tonic-gate ulong_t dmd_offset; /* offset of this member in bits (for sou) */ 1447c478bd9Sstevel@tonic-gate int dmd_value; /* value of this member (for enum) */ 1457c478bd9Sstevel@tonic-gate } ctf_dmdef_t; 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate typedef struct ctf_dtdef { 1487c478bd9Sstevel@tonic-gate ctf_list_t dtd_list; /* list forward/back pointers */ 149e4586ebfSmws struct ctf_dtdef *dtd_hash; /* hash chain pointer for ctf_dthash */ 1507c478bd9Sstevel@tonic-gate char *dtd_name; /* name associated with definition (if any) */ 1517c478bd9Sstevel@tonic-gate ctf_id_t dtd_type; /* type identifier for this definition */ 1527c478bd9Sstevel@tonic-gate ctf_type_t dtd_data; /* type node (see <sys/ctf.h>) */ 153*0a47c91cSRobert Mustacchi int dtd_ref; /* recfount for dyanmic types */ 1547c478bd9Sstevel@tonic-gate union { 1557c478bd9Sstevel@tonic-gate ctf_list_t dtu_members; /* struct, union, or enum */ 1567c478bd9Sstevel@tonic-gate ctf_arinfo_t dtu_arr; /* array */ 1577c478bd9Sstevel@tonic-gate ctf_encoding_t dtu_enc; /* integer or float */ 1587c478bd9Sstevel@tonic-gate ctf_id_t *dtu_argv; /* function */ 1597c478bd9Sstevel@tonic-gate } dtd_u; 1607c478bd9Sstevel@tonic-gate } ctf_dtdef_t; 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate typedef struct ctf_bundle { 1637c478bd9Sstevel@tonic-gate ctf_file_t *ctb_file; /* CTF container handle */ 1647c478bd9Sstevel@tonic-gate ctf_id_t ctb_type; /* CTF type identifier */ 1657c478bd9Sstevel@tonic-gate ctf_dtdef_t *ctb_dtd; /* CTF dynamic type definition (if any) */ 1667c478bd9Sstevel@tonic-gate } ctf_bundle_t; 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * The ctf_file is the structure used to represent a CTF container to library 1707c478bd9Sstevel@tonic-gate * clients, who see it only as an opaque pointer. Modifications can therefore 1717c478bd9Sstevel@tonic-gate * be made freely to this structure without regard to client versioning. The 1727c478bd9Sstevel@tonic-gate * ctf_file_t typedef appears in <sys/ctf_api.h> and declares a forward tag. 1737c478bd9Sstevel@tonic-gate * 1747c478bd9Sstevel@tonic-gate * NOTE: ctf_update() requires that everything inside of ctf_file either be an 1757c478bd9Sstevel@tonic-gate * immediate value, a pointer to dynamically allocated data *outside* of the 1767c478bd9Sstevel@tonic-gate * ctf_file itself, or a pointer to statically allocated data. If you add a 1777c478bd9Sstevel@tonic-gate * pointer to ctf_file that points to something within the ctf_file itself, 1787c478bd9Sstevel@tonic-gate * you must make corresponding changes to ctf_update(). 1797c478bd9Sstevel@tonic-gate */ 1807c478bd9Sstevel@tonic-gate struct ctf_file { 1817c478bd9Sstevel@tonic-gate const ctf_fileops_t *ctf_fileops; /* version-specific file operations */ 1827c478bd9Sstevel@tonic-gate ctf_sect_t ctf_data; /* CTF data from object file */ 1837c478bd9Sstevel@tonic-gate ctf_sect_t ctf_symtab; /* symbol table from object file */ 1847c478bd9Sstevel@tonic-gate ctf_sect_t ctf_strtab; /* string table from object file */ 1857c478bd9Sstevel@tonic-gate ctf_hash_t ctf_structs; /* hash table of struct types */ 1867c478bd9Sstevel@tonic-gate ctf_hash_t ctf_unions; /* hash table of union types */ 1877c478bd9Sstevel@tonic-gate ctf_hash_t ctf_enums; /* hash table of enum types */ 1887c478bd9Sstevel@tonic-gate ctf_hash_t ctf_names; /* hash table of remaining type names */ 1897c478bd9Sstevel@tonic-gate ctf_lookup_t ctf_lookups[5]; /* pointers to hashes for name lookup */ 1907c478bd9Sstevel@tonic-gate ctf_strs_t ctf_str[2]; /* array of string table base and bounds */ 1917c478bd9Sstevel@tonic-gate const uchar_t *ctf_base; /* base of CTF header + uncompressed buffer */ 1927c478bd9Sstevel@tonic-gate const uchar_t *ctf_buf; /* uncompressed CTF data buffer */ 1937c478bd9Sstevel@tonic-gate size_t ctf_size; /* size of CTF header + uncompressed data */ 1947c478bd9Sstevel@tonic-gate uint_t *ctf_sxlate; /* translation table for symtab entries */ 1957c478bd9Sstevel@tonic-gate ulong_t ctf_nsyms; /* number of entries in symtab xlate table */ 1967c478bd9Sstevel@tonic-gate uint_t *ctf_txlate; /* translation table for type IDs */ 1977c478bd9Sstevel@tonic-gate ushort_t *ctf_ptrtab; /* translation table for pointer-to lookups */ 1987c478bd9Sstevel@tonic-gate ulong_t ctf_typemax; /* maximum valid type ID number */ 1997c478bd9Sstevel@tonic-gate const ctf_dmodel_t *ctf_dmodel; /* data model pointer (see above) */ 2007c478bd9Sstevel@tonic-gate struct ctf_file *ctf_parent; /* parent CTF container (if any) */ 2017c478bd9Sstevel@tonic-gate const char *ctf_parlabel; /* label in parent container (if any) */ 2027c478bd9Sstevel@tonic-gate const char *ctf_parname; /* basename of parent (if any) */ 2037c478bd9Sstevel@tonic-gate uint_t ctf_refcnt; /* reference count (for parent links) */ 2047c478bd9Sstevel@tonic-gate uint_t ctf_flags; /* libctf flags (see below) */ 2057c478bd9Sstevel@tonic-gate int ctf_errno; /* error code for most recent error */ 2067c478bd9Sstevel@tonic-gate int ctf_version; /* CTF data version */ 207e4586ebfSmws ctf_dtdef_t **ctf_dthash; /* hash of dynamic type definitions */ 208e4586ebfSmws ulong_t ctf_dthashlen; /* size of dynamic type hash bucket array */ 2097c478bd9Sstevel@tonic-gate ctf_list_t ctf_dtdefs; /* list of dynamic type definitions */ 2107c478bd9Sstevel@tonic-gate size_t ctf_dtstrlen; /* total length of dynamic type strings */ 2117c478bd9Sstevel@tonic-gate ulong_t ctf_dtnextid; /* next dynamic type id to assign */ 2127c478bd9Sstevel@tonic-gate ulong_t ctf_dtoldid; /* oldest id that has been committed */ 2137c478bd9Sstevel@tonic-gate void *ctf_specific; /* data for ctf_get/setspecific */ 2147c478bd9Sstevel@tonic-gate }; 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate #define LCTF_INDEX_TO_TYPEPTR(fp, i) \ 2177c478bd9Sstevel@tonic-gate ((ctf_type_t *)((uintptr_t)(fp)->ctf_buf + (fp)->ctf_txlate[(i)])) 2187c478bd9Sstevel@tonic-gate 2197c478bd9Sstevel@tonic-gate #define LCTF_INFO_KIND(fp, info) ((fp)->ctf_fileops->ctfo_get_kind(info)) 2207c478bd9Sstevel@tonic-gate #define LCTF_INFO_ROOT(fp, info) ((fp)->ctf_fileops->ctfo_get_root(info)) 2217c478bd9Sstevel@tonic-gate #define LCTF_INFO_VLEN(fp, info) ((fp)->ctf_fileops->ctfo_get_vlen(info)) 2227c478bd9Sstevel@tonic-gate 2237c478bd9Sstevel@tonic-gate #define LCTF_MMAP 0x0001 /* libctf should munmap buffers on close */ 2247c478bd9Sstevel@tonic-gate #define LCTF_CHILD 0x0002 /* CTF container is a child */ 2257c478bd9Sstevel@tonic-gate #define LCTF_RDWR 0x0004 /* CTF container is writable */ 2267c478bd9Sstevel@tonic-gate #define LCTF_DIRTY 0x0008 /* CTF container has been modified */ 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate #define ECTF_BASE 1000 /* base value for libctf errnos */ 2297c478bd9Sstevel@tonic-gate 2307c478bd9Sstevel@tonic-gate enum { 2317c478bd9Sstevel@tonic-gate ECTF_FMT = ECTF_BASE, /* file is not in CTF or ELF format */ 2327c478bd9Sstevel@tonic-gate ECTF_ELFVERS, /* ELF version is more recent than libctf */ 2337c478bd9Sstevel@tonic-gate ECTF_CTFVERS, /* CTF version is more recent than libctf */ 2347c478bd9Sstevel@tonic-gate ECTF_ENDIAN, /* data is different endian-ness than lib */ 2357c478bd9Sstevel@tonic-gate ECTF_SYMTAB, /* symbol table uses invalid entry size */ 2367c478bd9Sstevel@tonic-gate ECTF_SYMBAD, /* symbol table data buffer invalid */ 2377c478bd9Sstevel@tonic-gate ECTF_STRBAD, /* string table data buffer invalid */ 2387c478bd9Sstevel@tonic-gate ECTF_CORRUPT, /* file data corruption detected */ 2397c478bd9Sstevel@tonic-gate ECTF_NOCTFDATA, /* ELF file does not contain CTF data */ 2407c478bd9Sstevel@tonic-gate ECTF_NOCTFBUF, /* buffer does not contain CTF data */ 2417c478bd9Sstevel@tonic-gate ECTF_NOSYMTAB, /* symbol table data is not available */ 2427c478bd9Sstevel@tonic-gate ECTF_NOPARENT, /* parent CTF container is not available */ 2437c478bd9Sstevel@tonic-gate ECTF_DMODEL, /* data model mismatch */ 2447c478bd9Sstevel@tonic-gate ECTF_MMAP, /* failed to mmap a data section */ 2457c478bd9Sstevel@tonic-gate ECTF_ZMISSING, /* decompression library not installed */ 2467c478bd9Sstevel@tonic-gate ECTF_ZINIT, /* failed to initialize decompression library */ 2477c478bd9Sstevel@tonic-gate ECTF_ZALLOC, /* failed to allocate decompression buffer */ 2487c478bd9Sstevel@tonic-gate ECTF_DECOMPRESS, /* failed to decompress CTF data */ 2497c478bd9Sstevel@tonic-gate ECTF_STRTAB, /* string table for this string is missing */ 2507c478bd9Sstevel@tonic-gate ECTF_BADNAME, /* string offset is corrupt w.r.t. strtab */ 2517c478bd9Sstevel@tonic-gate ECTF_BADID, /* invalid type ID number */ 2527c478bd9Sstevel@tonic-gate ECTF_NOTSOU, /* type is not a struct or union */ 2537c478bd9Sstevel@tonic-gate ECTF_NOTENUM, /* type is not an enum */ 2547c478bd9Sstevel@tonic-gate ECTF_NOTSUE, /* type is not a struct, union, or enum */ 2557c478bd9Sstevel@tonic-gate ECTF_NOTINTFP, /* type is not an integer or float */ 2567c478bd9Sstevel@tonic-gate ECTF_NOTARRAY, /* type is not an array */ 2577c478bd9Sstevel@tonic-gate ECTF_NOTREF, /* type does not reference another type */ 2587c478bd9Sstevel@tonic-gate ECTF_NAMELEN, /* buffer is too small to hold type name */ 2597c478bd9Sstevel@tonic-gate ECTF_NOTYPE, /* no type found corresponding to name */ 2607c478bd9Sstevel@tonic-gate ECTF_SYNTAX, /* syntax error in type name */ 2617c478bd9Sstevel@tonic-gate ECTF_NOTFUNC, /* symtab entry does not refer to a function */ 2627c478bd9Sstevel@tonic-gate ECTF_NOFUNCDAT, /* no func info available for function */ 2637c478bd9Sstevel@tonic-gate ECTF_NOTDATA, /* symtab entry does not refer to a data obj */ 2647c478bd9Sstevel@tonic-gate ECTF_NOTYPEDAT, /* no type info available for object */ 2657c478bd9Sstevel@tonic-gate ECTF_NOLABEL, /* no label found corresponding to name */ 2667c478bd9Sstevel@tonic-gate ECTF_NOLABELDATA, /* file does not contain any labels */ 2677c478bd9Sstevel@tonic-gate ECTF_NOTSUP, /* feature not supported */ 2687c478bd9Sstevel@tonic-gate ECTF_NOENUMNAM, /* enum element name not found */ 2697c478bd9Sstevel@tonic-gate ECTF_NOMEMBNAM, /* member name not found */ 2707c478bd9Sstevel@tonic-gate ECTF_RDONLY, /* CTF container is read-only */ 2717c478bd9Sstevel@tonic-gate ECTF_DTFULL, /* CTF type is full (no more members allowed) */ 2727c478bd9Sstevel@tonic-gate ECTF_FULL, /* CTF container is full */ 2737c478bd9Sstevel@tonic-gate ECTF_DUPMEMBER, /* duplicate member name definition */ 274*0a47c91cSRobert Mustacchi ECTF_CONFLICT, /* conflicting type definition present */ 275*0a47c91cSRobert Mustacchi ECTF_REFERENCED, /* type has outstanding references */ 276*0a47c91cSRobert Mustacchi ECTF_NOTDYN /* type is not a dynamic type */ 2777c478bd9Sstevel@tonic-gate }; 2787c478bd9Sstevel@tonic-gate 2797c478bd9Sstevel@tonic-gate extern ssize_t ctf_get_ctt_size(const ctf_file_t *, const ctf_type_t *, 2807c478bd9Sstevel@tonic-gate ssize_t *, ssize_t *); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate extern const ctf_type_t *ctf_lookup_by_id(ctf_file_t **, ctf_id_t); 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate extern int ctf_hash_create(ctf_hash_t *, ulong_t); 2857c478bd9Sstevel@tonic-gate extern int ctf_hash_insert(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t); 286e4586ebfSmws extern int ctf_hash_define(ctf_hash_t *, ctf_file_t *, ushort_t, uint_t); 2877c478bd9Sstevel@tonic-gate extern ctf_helem_t *ctf_hash_lookup(ctf_hash_t *, ctf_file_t *, 2887c478bd9Sstevel@tonic-gate const char *, size_t); 2897c478bd9Sstevel@tonic-gate extern uint_t ctf_hash_size(const ctf_hash_t *); 2907c478bd9Sstevel@tonic-gate extern void ctf_hash_destroy(ctf_hash_t *); 2917c478bd9Sstevel@tonic-gate 2927c478bd9Sstevel@tonic-gate #define ctf_list_prev(elem) ((void *)(((ctf_list_t *)(elem))->l_prev)) 2937c478bd9Sstevel@tonic-gate #define ctf_list_next(elem) ((void *)(((ctf_list_t *)(elem))->l_next)) 2947c478bd9Sstevel@tonic-gate 2957c478bd9Sstevel@tonic-gate extern void ctf_list_append(ctf_list_t *, void *); 2967c478bd9Sstevel@tonic-gate extern void ctf_list_prepend(ctf_list_t *, void *); 2977c478bd9Sstevel@tonic-gate extern void ctf_list_delete(ctf_list_t *, void *); 2987c478bd9Sstevel@tonic-gate 299e4586ebfSmws extern void ctf_dtd_insert(ctf_file_t *, ctf_dtdef_t *); 300e4586ebfSmws extern void ctf_dtd_delete(ctf_file_t *, ctf_dtdef_t *); 301e4586ebfSmws extern ctf_dtdef_t *ctf_dtd_lookup(ctf_file_t *, ctf_id_t); 302e4586ebfSmws 3037c478bd9Sstevel@tonic-gate extern void ctf_decl_init(ctf_decl_t *, char *, size_t); 3047c478bd9Sstevel@tonic-gate extern void ctf_decl_fini(ctf_decl_t *); 3057c478bd9Sstevel@tonic-gate extern void ctf_decl_push(ctf_decl_t *, ctf_file_t *, ctf_id_t); 3067c478bd9Sstevel@tonic-gate extern void ctf_decl_sprintf(ctf_decl_t *, const char *, ...); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate extern const char *ctf_strraw(ctf_file_t *, uint_t); 3097c478bd9Sstevel@tonic-gate extern const char *ctf_strptr(ctf_file_t *, uint_t); 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate extern ctf_file_t *ctf_set_open_errno(int *, int); 3127c478bd9Sstevel@tonic-gate extern long ctf_set_errno(ctf_file_t *, int); 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate extern const void *ctf_sect_mmap(ctf_sect_t *, int); 3157c478bd9Sstevel@tonic-gate extern void ctf_sect_munmap(const ctf_sect_t *); 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate extern void *ctf_data_alloc(size_t); 3187c478bd9Sstevel@tonic-gate extern void ctf_data_free(void *, size_t); 3197c478bd9Sstevel@tonic-gate extern void ctf_data_protect(void *, size_t); 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate extern void *ctf_alloc(size_t); 3227c478bd9Sstevel@tonic-gate extern void ctf_free(void *, size_t); 3237c478bd9Sstevel@tonic-gate 3247c478bd9Sstevel@tonic-gate extern char *ctf_strdup(const char *); 3257c478bd9Sstevel@tonic-gate extern const char *ctf_strerror(int); 3267c478bd9Sstevel@tonic-gate extern void ctf_dprintf(const char *, ...); 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate extern void *ctf_zopen(int *); 3297c478bd9Sstevel@tonic-gate 3307c478bd9Sstevel@tonic-gate extern const char _CTF_SECTION[]; /* name of CTF ELF section */ 3317c478bd9Sstevel@tonic-gate extern const char _CTF_NULLSTR[]; /* empty string */ 3327c478bd9Sstevel@tonic-gate 3337c478bd9Sstevel@tonic-gate extern int _libctf_version; /* library client version */ 3347c478bd9Sstevel@tonic-gate extern int _libctf_debug; /* debugging messages enabled */ 3357c478bd9Sstevel@tonic-gate 3367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate #endif 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate #endif /* _CTF_IMPL_H */ 341