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 55aefb655Srie * Common Development and Distribution License (the "License"). 65aefb655Srie * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 215aefb655Srie 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1988 AT&T 247c478bd9Sstevel@tonic-gate * All Rights Reserved 257c478bd9Sstevel@tonic-gate * 265aefb655Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 277c478bd9Sstevel@tonic-gate * Use is subject to license terms. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifndef _CONV_H 317c478bd9Sstevel@tonic-gate #define _CONV_H 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * Global include file for conversion library. 377c478bd9Sstevel@tonic-gate */ 387c478bd9Sstevel@tonic-gate 397c478bd9Sstevel@tonic-gate #include <stdlib.h> 407c478bd9Sstevel@tonic-gate #include <libelf.h> 417c478bd9Sstevel@tonic-gate #include <dlfcn.h> 427c478bd9Sstevel@tonic-gate #include <libld.h> 437c478bd9Sstevel@tonic-gate #include <sgs.h> 447c478bd9Sstevel@tonic-gate #include <machdep.h> 457c478bd9Sstevel@tonic-gate 467c478bd9Sstevel@tonic-gate #ifdef __cplusplus 477c478bd9Sstevel@tonic-gate extern "C" { 487c478bd9Sstevel@tonic-gate #endif 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Configuration features available - maintained here (instead of debug.h) 527c478bd9Sstevel@tonic-gate * to save libconv from having to include debug.h which results in numerous 537c478bd9Sstevel@tonic-gate * "declared but not used or defined" lint errors. 547c478bd9Sstevel@tonic-gate */ 557c478bd9Sstevel@tonic-gate #define CONF_EDLIBPATH 0x000100 /* ELF default library path */ 567c478bd9Sstevel@tonic-gate #define CONF_ESLIBPATH 0x000200 /* ELF secure library path */ 577c478bd9Sstevel@tonic-gate #define CONF_ADLIBPATH 0x000400 /* AOUT default library path */ 587c478bd9Sstevel@tonic-gate #define CONF_ASLIBPATH 0x000800 /* AOUT secure library path */ 597c478bd9Sstevel@tonic-gate #define CONF_DIRCFG 0x001000 /* directory configuration available */ 607c478bd9Sstevel@tonic-gate #define CONF_OBJALT 0x002000 /* object alternatives available */ 617c478bd9Sstevel@tonic-gate #define CONF_MEMRESV 0x004000 /* memory reservation required */ 627c478bd9Sstevel@tonic-gate #define CONF_ENVS 0x008000 /* environment variables available */ 637c478bd9Sstevel@tonic-gate #define CONF_FLTR 0x010000 /* filter information available */ 647c478bd9Sstevel@tonic-gate #define CONF_FEATMSK 0xffff00 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* 675aefb655Srie * Various values that can't be matched to a symbolic definition are converted 685aefb655Srie * to a numeric string. Each function that may require this fallback maintains 695aefb655Srie * its own static string buffer, as many conversion routines may be called for 705aefb655Srie * one final diagnostic. See conv_invalid_val(). 715aefb655Srie * 725aefb655Srie * The string size reflects the largest possible decimal number plus a trailing 735aefb655Srie * null. Typically however, values are hex with a leading "0x". 745aefb655Srie */ 755aefb655Srie #if defined(_ELF64) 765aefb655Srie #define CONV_INV_STRSIZE 22 775aefb655Srie #else 785aefb655Srie #define CONV_INV_STRSIZE 12 795aefb655Srie #endif 805aefb655Srie 815aefb655Srie /* 82c13de8f6Sab196087 * Flags that alter standard formatting for conversion routines. 835aefb655Srie */ 84ba4e3c84Sab196087 #define CONV_FMT_DECIMAL 0x01 /* conv_invalid_val() should print */ 85c13de8f6Sab196087 /* integer print as decimal */ 86c13de8f6Sab196087 /* (default is hex) */ 87ba4e3c84Sab196087 #define CONV_FMT_SPACE 0x02 /* conv_invalid_val() should append */ 88c13de8f6Sab196087 /* a space after the number. */ 89ba4e3c84Sab196087 #define CONV_FMT_ALTDUMP 0x04 /* Output strings using the versions */ 90c13de8f6Sab196087 /* used by the dump program. */ 91ba4e3c84Sab196087 #define CONV_FMT_ALTFILE 0x08 /* Output strings in the form used */ 92c13de8f6Sab196087 /* by the file(1) command */ 93ba4e3c84Sab196087 #define CONV_FMT_ALTCRLE 0x10 /* Output strings in the form used */ 94ba4e3c84Sab196087 /* by the crle(1) command */ 95c13de8f6Sab196087 96c13de8f6Sab196087 /* 97c13de8f6Sab196087 * Mask of CONV_FMT bits that reflect a desire to use alternate strings. 98c13de8f6Sab196087 */ 99c13de8f6Sab196087 #define CONV_FMTALTMASK (CONV_FMT_ALTDUMP|CONV_FMT_ALTFILE) 1005aefb655Srie 1015aefb655Srie /* 1025aefb655Srie * The expansion of bit-field data items is driven from a value descriptor and 1035aefb655Srie * the conv_expn_field() routine. 1045aefb655Srie */ 1055aefb655Srie typedef struct { 1065aefb655Srie Xword v_val; /* expansion value */ 1075aefb655Srie const char *v_msg; /* associated message string */ 1085aefb655Srie } Val_desc; 1095aefb655Srie 1105aefb655Srie /* 111ba4e3c84Sab196087 * conv_expn_field() is willing to supply default strings for the 112ba4e3c84Sab196087 * prefix, separator, and suffix arguments, if they are passed as NULL. 113ba4e3c84Sab196087 * The caller needs to know how much room to allow for these items. 114ba4e3c84Sab196087 * These values supply those sizes. 115ba4e3c84Sab196087 */ 116ba4e3c84Sab196087 #define CONV_EXPN_FIELD_DEF_PREFIX_SIZE 2 /* Default is "[ " */ 117ba4e3c84Sab196087 #define CONV_EXPN_FIELD_DEF_SEP_SIZE 1 /* Default is " " */ 118ba4e3c84Sab196087 #define CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 2 /* Default is " ]" */ 119ba4e3c84Sab196087 120ba4e3c84Sab196087 121ba4e3c84Sab196087 /* 122ba4e3c84Sab196087 * conv_expn_field() requires a large number of inputs, many of which 123ba4e3c84Sab196087 * can be NULL to accept default behavior. An argument of the following 124ba4e3c84Sab196087 * type is used to supply them. 125ba4e3c84Sab196087 */ 126ba4e3c84Sab196087 typedef struct { 127ba4e3c84Sab196087 char *buf; /* Buffer to receive generated string */ 128ba4e3c84Sab196087 size_t bufsize; /* sizeof(buf) */ 129ba4e3c84Sab196087 const Val_desc *vdp; /* Array of value descriptors, giving the */ 130ba4e3c84Sab196087 /* possible bit values, and their */ 131ba4e3c84Sab196087 /* corresponding strings. Note that the */ 132ba4e3c84Sab196087 /* final element must contain only NULL */ 133ba4e3c84Sab196087 /* values. This terminates the list. */ 134ba4e3c84Sab196087 const char **lead_str; /* NULL, or array of pointers to strings to */ 135ba4e3c84Sab196087 /* be output at the head of the list. */ 136ba4e3c84Sab196087 /* Last entry must be NULL. */ 137ba4e3c84Sab196087 Xword oflags; /* Bits for which output strings are desired */ 138ba4e3c84Sab196087 Xword rflags; /* Bits for which a numeric value should be */ 139ba4e3c84Sab196087 /* output if vdp does not provide str. */ 140ba4e3c84Sab196087 /* Must be a proper subset of oflags */ 141ba4e3c84Sab196087 const char *prefix; /* NULL, or string to prefix output with */ 142ba4e3c84Sab196087 /* If NULL, "[ " is used. */ 143ba4e3c84Sab196087 const char *sep; /* NULL, or string to separate output items */ 144ba4e3c84Sab196087 /* with. If NULL, " " is used. */ 145ba4e3c84Sab196087 const char *suffix; /* NULL, or string to suffix output with */ 146ba4e3c84Sab196087 /* If NULL, " ]" is used. */ 147ba4e3c84Sab196087 } CONV_EXPN_FIELD_ARG; 148ba4e3c84Sab196087 149ba4e3c84Sab196087 150ba4e3c84Sab196087 /* 1515aefb655Srie * Define all generic interfaces. 1527c478bd9Sstevel@tonic-gate */ 153*7010c12aSrie extern uchar_t conv_check_native(char **, char **); 1545aefb655Srie extern const char *conv_config_feat(int); 1557c478bd9Sstevel@tonic-gate extern const char *conv_config_obj(ushort_t); 1565aefb655Srie extern const char *conv_config_upm(const char *, const char *, 1575aefb655Srie const char *, size_t); 1585aefb655Srie extern const char *conv_def_tag(Symref); 1595aefb655Srie extern const char *conv_demangle_name(const char *); 1605aefb655Srie extern const char *conv_dl_flag(int, int); 1615aefb655Srie extern const char *conv_dl_mode(int, int); 1625aefb655Srie extern const char *conv_dwarf_ehe(uint_t); 1635aefb655Srie extern const char *conv_elfdata_type(Elf_Type); 1645aefb655Srie extern const char *conv_grphdl_flags(uint_t); 1657c478bd9Sstevel@tonic-gate extern Isa_desc *conv_isalist(void); 1667c478bd9Sstevel@tonic-gate extern const char *conv_lddstub(int); 1675aefb655Srie extern const char *conv_seg_flags(Half); 1687c478bd9Sstevel@tonic-gate extern int conv_sys_eclass(); 1697c478bd9Sstevel@tonic-gate extern Uts_desc *conv_uts(void); 1705aefb655Srie extern const char *conv_ver_flags(Half); 1715aefb655Srie 1725aefb655Srie /* 1735aefb655Srie * Define all class specific routines. 1745aefb655Srie */ 1755aefb655Srie #if defined(_ELF64) 1765aefb655Srie #define conv_bnd_obj conv64_bnd_obj 1775aefb655Srie #define conv_bnd_type conv64_bnd_type 1785aefb655Srie #define conv_cap_tag conv64_cap_tag 1795aefb655Srie #define conv_cap_val conv64_cap_val 1805aefb655Srie #define conv_cap_val_hw1 conv64_cap_val_hw1 1815aefb655Srie #define conv_cap_val_sf1 conv64_cap_val_sf1 1825aefb655Srie #define conv_dyn_feature1 conv64_dyn_feature1 1835aefb655Srie #define conv_dyn_flag1 conv64_dyn_flag1 1845aefb655Srie #define conv_dyn_flag conv64_dyn_flag 1855aefb655Srie #define conv_dyn_posflag1 conv64_dyn_posflag1 1865aefb655Srie #define conv_dyn_tag conv64_dyn_tag 1875aefb655Srie #define conv_ehdr_class conv64_ehdr_class 1885aefb655Srie #define conv_ehdr_data conv64_ehdr_data 1895aefb655Srie #define conv_ehdr_flags conv64_ehdr_flags 1905aefb655Srie #define conv_ehdr_mach conv64_ehdr_mach 1915aefb655Srie #define conv_ehdr_type conv64_ehdr_type 1925aefb655Srie #define conv_ehdr_vers conv64_ehdr_vers 1935aefb655Srie #define conv_expn_field conv64_expn_field 1945aefb655Srie #define conv_invalid_val conv64_invalid_val 1955aefb655Srie #define conv_phdr_flags conv64_phdr_flags 1965aefb655Srie #define conv_phdr_type conv64_phdr_type 1975aefb655Srie #define conv_reject_desc conv64_reject_desc 1985aefb655Srie #define conv_reloc_type conv64_reloc_type 1995aefb655Srie #define conv_reloc_386_type conv64_reloc_386_type 2005aefb655Srie #define conv_reloc_amd64_type conv64_reloc_amd64_type 2015aefb655Srie #define conv_reloc_SPARC_type conv64_reloc_SPARC_type 2025aefb655Srie #define conv_sec_flags conv64_sec_flags 203*7010c12aSrie #define conv_sec_linkinfo conv64_sec_linkinfo 2045aefb655Srie #define conv_sec_type conv64_sec_type 2055aefb655Srie #define conv_sym_info_bind conv64_sym_info_bind 2065aefb655Srie #define conv_sym_info_type conv64_sym_info_type 2075aefb655Srie #define conv_sym_shndx conv64_sym_shndx 2085aefb655Srie #define conv_sym_other conv64_sym_other 2095aefb655Srie #define conv_sym_value conv64_sym_value 2105aefb655Srie #define conv_sym_SPARC_value conv64_sym_SPARC_value 2115aefb655Srie #else 2125aefb655Srie #define conv_bnd_obj conv32_bnd_obj 2135aefb655Srie #define conv_bnd_type conv32_bnd_type 2145aefb655Srie #define conv_cap_tag conv32_cap_tag 2155aefb655Srie #define conv_cap_val conv32_cap_val 2165aefb655Srie #define conv_cap_val_hw1 conv32_cap_val_hw1 2175aefb655Srie #define conv_cap_val_sf1 conv32_cap_val_sf1 2185aefb655Srie #define conv_dyn_feature1 conv32_dyn_feature1 2195aefb655Srie #define conv_dyn_flag1 conv32_dyn_flag1 2205aefb655Srie #define conv_dyn_flag conv32_dyn_flag 2215aefb655Srie #define conv_dyn_posflag1 conv32_dyn_posflag1 2225aefb655Srie #define conv_dyn_tag conv32_dyn_tag 2235aefb655Srie #define conv_ehdr_class conv32_ehdr_class 2245aefb655Srie #define conv_ehdr_data conv32_ehdr_data 2255aefb655Srie #define conv_ehdr_flags conv32_ehdr_flags 2265aefb655Srie #define conv_ehdr_mach conv32_ehdr_mach 2275aefb655Srie #define conv_ehdr_type conv32_ehdr_type 2285aefb655Srie #define conv_ehdr_vers conv32_ehdr_vers 2295aefb655Srie #define conv_expn_field conv32_expn_field 2305aefb655Srie #define conv_invalid_val conv32_invalid_val 2315aefb655Srie #define conv_phdr_flags conv32_phdr_flags 2325aefb655Srie #define conv_phdr_type conv32_phdr_type 2335aefb655Srie #define conv_reject_desc conv32_reject_desc 2345aefb655Srie #define conv_reloc_type conv32_reloc_type 2355aefb655Srie #define conv_reloc_386_type conv32_reloc_386_type 2365aefb655Srie #define conv_reloc_amd64_type conv32_reloc_amd64_type 2375aefb655Srie #define conv_reloc_SPARC_type conv32_reloc_SPARC_type 2385aefb655Srie #define conv_sec_flags conv32_sec_flags 239*7010c12aSrie #define conv_sec_linkinfo conv32_sec_linkinfo 2405aefb655Srie #define conv_sec_type conv32_sec_type 2415aefb655Srie #define conv_sym_info_bind conv32_sym_info_bind 2425aefb655Srie #define conv_sym_info_type conv32_sym_info_type 2435aefb655Srie #define conv_sym_shndx conv32_sym_shndx 2445aefb655Srie #define conv_sym_other conv32_sym_other 2455aefb655Srie #define conv_sym_value conv32_sym_value 2465aefb655Srie #define conv_sym_SPARC_value conv32_sym_SPARC_value 2475aefb655Srie #endif 2485aefb655Srie 2495aefb655Srie extern const char *conv_bnd_obj(uint_t); 2505aefb655Srie extern const char *conv_bnd_type(uint_t); 2515aefb655Srie extern const char *conv_cap_tag(Xword); 2525aefb655Srie extern const char *conv_cap_val(Xword, Xword, Half); 2535aefb655Srie extern const char *conv_cap_val_hw1(Xword, Half); 2545aefb655Srie extern const char *conv_cap_val_sf1(Xword, Half); 2555aefb655Srie extern const char *conv_dyn_flag1(Xword); 256ba4e3c84Sab196087 extern const char *conv_dyn_flag(Xword, int); 257ba4e3c84Sab196087 extern const char *conv_dyn_posflag1(Xword, int); 258c13de8f6Sab196087 extern const char *conv_dyn_tag(Xword, Half, int); 259ba4e3c84Sab196087 extern const char *conv_dyn_feature1(Xword, int); 260c13de8f6Sab196087 extern const char *conv_ehdr_class(uchar_t, int); 261c13de8f6Sab196087 extern const char *conv_ehdr_data(uchar_t, int); 2625aefb655Srie extern const char *conv_ehdr_flags(Half, Word); 263c13de8f6Sab196087 extern const char *conv_ehdr_mach(Half, int); 264c13de8f6Sab196087 extern const char *conv_ehdr_type(Half, int); 265c13de8f6Sab196087 extern const char *conv_ehdr_vers(Word, int); 266ba4e3c84Sab196087 extern int conv_expn_field(CONV_EXPN_FIELD_ARG *); 2675aefb655Srie extern const char *conv_invalid_val(char *, size_t, Xword, int); 2685aefb655Srie extern const char *conv_phdr_flags(Word); 2695aefb655Srie extern const char *conv_phdr_type(Half, Word); 2705aefb655Srie extern const char *conv_reject_desc(Rej_desc *); 271c13de8f6Sab196087 extern const char *conv_reloc_type(Half, Word, int); 272c13de8f6Sab196087 extern const char *conv_reloc_386_type(Word, int); 273c13de8f6Sab196087 extern const char *conv_reloc_amd64_type(Word, int); 274c13de8f6Sab196087 extern const char *conv_reloc_SPARC_type(Word, int); 2755aefb655Srie extern const char *conv_sec_flags(Xword); 276*7010c12aSrie extern const char *conv_sec_linkinfo(Word, Xword); 277c13de8f6Sab196087 extern const char *conv_sec_type(Half, Word, int); 278c13de8f6Sab196087 extern const char *conv_sym_info_bind(uchar_t, int); 279c13de8f6Sab196087 extern const char *conv_sym_info_type(Half, uchar_t, int); 2805aefb655Srie extern const char *conv_sym_shndx(Half); 2815aefb655Srie extern const char *conv_sym_other(uchar_t); 2825aefb655Srie extern const char *conv_sym_value(Half, uchar_t, Addr); 283c13de8f6Sab196087 extern const char *conv_sym_SPARC_value(Addr, int); 2847c478bd9Sstevel@tonic-gate 2857c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2867c478bd9Sstevel@tonic-gate } 2877c478bd9Sstevel@tonic-gate #endif 2887c478bd9Sstevel@tonic-gate 2897c478bd9Sstevel@tonic-gate #endif /* _CONV_H */ 290