10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51618Srie * Common Development and Distribution License (the "License"). 61618Srie * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211618Srie 220Sstevel@tonic-gate /* 230Sstevel@tonic-gate * Copyright (c) 1988 AT&T 240Sstevel@tonic-gate * All Rights Reserved 250Sstevel@tonic-gate * 261618Srie * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 271618Srie * Use is subject to license terms. 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifndef _CONV_H 310Sstevel@tonic-gate #define _CONV_H 320Sstevel@tonic-gate 330Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 340Sstevel@tonic-gate 350Sstevel@tonic-gate /* 360Sstevel@tonic-gate * Global include file for conversion library. 370Sstevel@tonic-gate */ 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include <stdlib.h> 400Sstevel@tonic-gate #include <libelf.h> 410Sstevel@tonic-gate #include <dlfcn.h> 420Sstevel@tonic-gate #include <libld.h> 430Sstevel@tonic-gate #include <sgs.h> 440Sstevel@tonic-gate #include <machdep.h> 450Sstevel@tonic-gate 460Sstevel@tonic-gate #ifdef __cplusplus 470Sstevel@tonic-gate extern "C" { 480Sstevel@tonic-gate #endif 490Sstevel@tonic-gate 500Sstevel@tonic-gate /* 510Sstevel@tonic-gate * Configuration features available - maintained here (instead of debug.h) 520Sstevel@tonic-gate * to save libconv from having to include debug.h which results in numerous 530Sstevel@tonic-gate * "declared but not used or defined" lint errors. 540Sstevel@tonic-gate */ 550Sstevel@tonic-gate #define CONF_EDLIBPATH 0x000100 /* ELF default library path */ 560Sstevel@tonic-gate #define CONF_ESLIBPATH 0x000200 /* ELF secure library path */ 570Sstevel@tonic-gate #define CONF_ADLIBPATH 0x000400 /* AOUT default library path */ 580Sstevel@tonic-gate #define CONF_ASLIBPATH 0x000800 /* AOUT secure library path */ 590Sstevel@tonic-gate #define CONF_DIRCFG 0x001000 /* directory configuration available */ 600Sstevel@tonic-gate #define CONF_OBJALT 0x002000 /* object alternatives available */ 610Sstevel@tonic-gate #define CONF_MEMRESV 0x004000 /* memory reservation required */ 620Sstevel@tonic-gate #define CONF_ENVS 0x008000 /* environment variables available */ 630Sstevel@tonic-gate #define CONF_FLTR 0x010000 /* filter information available */ 640Sstevel@tonic-gate #define CONF_FEATMSK 0xffff00 650Sstevel@tonic-gate 660Sstevel@tonic-gate /* 671618Srie * Various values that can't be matched to a symbolic definition are converted 681618Srie * to a numeric string. Each function that may require this fallback maintains 691618Srie * its own static string buffer, as many conversion routines may be called for 701618Srie * one final diagnostic. See conv_invalid_val(). 711618Srie * 721618Srie * The string size reflects the largest possible decimal number plus a trailing 731618Srie * null. Typically however, values are hex with a leading "0x". 741618Srie */ 751618Srie #if defined(_ELF64) 761618Srie #define CONV_INV_STRSIZE 22 771618Srie #else 781618Srie #define CONV_INV_STRSIZE 12 791618Srie #endif 801618Srie 811618Srie /* 821976Sab196087 * Flags that alter standard formatting for conversion routines. 831618Srie */ 842352Sab196087 #define CONV_FMT_DECIMAL 0x01 /* conv_invalid_val() should print */ 851976Sab196087 /* integer print as decimal */ 861976Sab196087 /* (default is hex) */ 872352Sab196087 #define CONV_FMT_SPACE 0x02 /* conv_invalid_val() should append */ 881976Sab196087 /* a space after the number. */ 892352Sab196087 #define CONV_FMT_ALTDUMP 0x04 /* Output strings using the versions */ 901976Sab196087 /* used by the dump program. */ 912352Sab196087 #define CONV_FMT_ALTFILE 0x08 /* Output strings in the form used */ 921976Sab196087 /* by the file(1) command */ 932352Sab196087 #define CONV_FMT_ALTCRLE 0x10 /* Output strings in the form used */ 942352Sab196087 /* by the crle(1) command */ 951976Sab196087 961976Sab196087 /* 971976Sab196087 * Mask of CONV_FMT bits that reflect a desire to use alternate strings. 981976Sab196087 */ 991976Sab196087 #define CONV_FMTALTMASK (CONV_FMT_ALTDUMP|CONV_FMT_ALTFILE) 1001618Srie 1011618Srie /* 1021618Srie * The expansion of bit-field data items is driven from a value descriptor and 1031618Srie * the conv_expn_field() routine. 1041618Srie */ 1051618Srie typedef struct { 1061618Srie Xword v_val; /* expansion value */ 1071618Srie const char *v_msg; /* associated message string */ 1081618Srie } Val_desc; 1091618Srie 1101618Srie /* 1112352Sab196087 * conv_expn_field() is willing to supply default strings for the 1122352Sab196087 * prefix, separator, and suffix arguments, if they are passed as NULL. 1132352Sab196087 * The caller needs to know how much room to allow for these items. 1142352Sab196087 * These values supply those sizes. 1152352Sab196087 */ 1162352Sab196087 #define CONV_EXPN_FIELD_DEF_PREFIX_SIZE 2 /* Default is "[ " */ 1172352Sab196087 #define CONV_EXPN_FIELD_DEF_SEP_SIZE 1 /* Default is " " */ 1182352Sab196087 #define CONV_EXPN_FIELD_DEF_SUFFIX_SIZE 2 /* Default is " ]" */ 1192352Sab196087 1202352Sab196087 1212352Sab196087 /* 1222352Sab196087 * conv_expn_field() requires a large number of inputs, many of which 1232352Sab196087 * can be NULL to accept default behavior. An argument of the following 1242352Sab196087 * type is used to supply them. 1252352Sab196087 */ 1262352Sab196087 typedef struct { 1272352Sab196087 char *buf; /* Buffer to receive generated string */ 1282352Sab196087 size_t bufsize; /* sizeof(buf) */ 1292352Sab196087 const Val_desc *vdp; /* Array of value descriptors, giving the */ 1302352Sab196087 /* possible bit values, and their */ 1312352Sab196087 /* corresponding strings. Note that the */ 1322352Sab196087 /* final element must contain only NULL */ 1332352Sab196087 /* values. This terminates the list. */ 1342352Sab196087 const char **lead_str; /* NULL, or array of pointers to strings to */ 1352352Sab196087 /* be output at the head of the list. */ 1362352Sab196087 /* Last entry must be NULL. */ 1372352Sab196087 Xword oflags; /* Bits for which output strings are desired */ 1382352Sab196087 Xword rflags; /* Bits for which a numeric value should be */ 1392352Sab196087 /* output if vdp does not provide str. */ 1402352Sab196087 /* Must be a proper subset of oflags */ 1412352Sab196087 const char *prefix; /* NULL, or string to prefix output with */ 1422352Sab196087 /* If NULL, "[ " is used. */ 1432352Sab196087 const char *sep; /* NULL, or string to separate output items */ 1442352Sab196087 /* with. If NULL, " " is used. */ 1452352Sab196087 const char *suffix; /* NULL, or string to suffix output with */ 1462352Sab196087 /* If NULL, " ]" is used. */ 1472352Sab196087 } CONV_EXPN_FIELD_ARG; 1482352Sab196087 1492352Sab196087 1502352Sab196087 /* 1511618Srie * Define all generic interfaces. 1520Sstevel@tonic-gate */ 153*2647Srie extern uchar_t conv_check_native(char **, char **); 1541618Srie extern const char *conv_config_feat(int); 1550Sstevel@tonic-gate extern const char *conv_config_obj(ushort_t); 1561618Srie extern const char *conv_config_upm(const char *, const char *, 1571618Srie const char *, size_t); 1581618Srie extern const char *conv_def_tag(Symref); 1591618Srie extern const char *conv_demangle_name(const char *); 1601618Srie extern const char *conv_dl_flag(int, int); 1611618Srie extern const char *conv_dl_mode(int, int); 1621618Srie extern const char *conv_dwarf_ehe(uint_t); 1631618Srie extern const char *conv_elfdata_type(Elf_Type); 1641618Srie extern const char *conv_grphdl_flags(uint_t); 1650Sstevel@tonic-gate extern Isa_desc *conv_isalist(void); 1660Sstevel@tonic-gate extern const char *conv_lddstub(int); 1671618Srie extern const char *conv_seg_flags(Half); 1680Sstevel@tonic-gate extern int conv_sys_eclass(); 1690Sstevel@tonic-gate extern Uts_desc *conv_uts(void); 1701618Srie extern const char *conv_ver_flags(Half); 1711618Srie 1721618Srie /* 1731618Srie * Define all class specific routines. 1741618Srie */ 1751618Srie #if defined(_ELF64) 1761618Srie #define conv_bnd_obj conv64_bnd_obj 1771618Srie #define conv_bnd_type conv64_bnd_type 1781618Srie #define conv_cap_tag conv64_cap_tag 1791618Srie #define conv_cap_val conv64_cap_val 1801618Srie #define conv_cap_val_hw1 conv64_cap_val_hw1 1811618Srie #define conv_cap_val_sf1 conv64_cap_val_sf1 1821618Srie #define conv_dyn_feature1 conv64_dyn_feature1 1831618Srie #define conv_dyn_flag1 conv64_dyn_flag1 1841618Srie #define conv_dyn_flag conv64_dyn_flag 1851618Srie #define conv_dyn_posflag1 conv64_dyn_posflag1 1861618Srie #define conv_dyn_tag conv64_dyn_tag 1871618Srie #define conv_ehdr_class conv64_ehdr_class 1881618Srie #define conv_ehdr_data conv64_ehdr_data 1891618Srie #define conv_ehdr_flags conv64_ehdr_flags 1901618Srie #define conv_ehdr_mach conv64_ehdr_mach 1911618Srie #define conv_ehdr_type conv64_ehdr_type 1921618Srie #define conv_ehdr_vers conv64_ehdr_vers 1931618Srie #define conv_expn_field conv64_expn_field 1941618Srie #define conv_invalid_val conv64_invalid_val 1951618Srie #define conv_phdr_flags conv64_phdr_flags 1961618Srie #define conv_phdr_type conv64_phdr_type 1971618Srie #define conv_reject_desc conv64_reject_desc 1981618Srie #define conv_reloc_type conv64_reloc_type 1991618Srie #define conv_reloc_386_type conv64_reloc_386_type 2001618Srie #define conv_reloc_amd64_type conv64_reloc_amd64_type 2011618Srie #define conv_reloc_SPARC_type conv64_reloc_SPARC_type 2021618Srie #define conv_sec_flags conv64_sec_flags 203*2647Srie #define conv_sec_linkinfo conv64_sec_linkinfo 2041618Srie #define conv_sec_type conv64_sec_type 2051618Srie #define conv_sym_info_bind conv64_sym_info_bind 2061618Srie #define conv_sym_info_type conv64_sym_info_type 2071618Srie #define conv_sym_shndx conv64_sym_shndx 2081618Srie #define conv_sym_other conv64_sym_other 2091618Srie #define conv_sym_value conv64_sym_value 2101618Srie #define conv_sym_SPARC_value conv64_sym_SPARC_value 2111618Srie #else 2121618Srie #define conv_bnd_obj conv32_bnd_obj 2131618Srie #define conv_bnd_type conv32_bnd_type 2141618Srie #define conv_cap_tag conv32_cap_tag 2151618Srie #define conv_cap_val conv32_cap_val 2161618Srie #define conv_cap_val_hw1 conv32_cap_val_hw1 2171618Srie #define conv_cap_val_sf1 conv32_cap_val_sf1 2181618Srie #define conv_dyn_feature1 conv32_dyn_feature1 2191618Srie #define conv_dyn_flag1 conv32_dyn_flag1 2201618Srie #define conv_dyn_flag conv32_dyn_flag 2211618Srie #define conv_dyn_posflag1 conv32_dyn_posflag1 2221618Srie #define conv_dyn_tag conv32_dyn_tag 2231618Srie #define conv_ehdr_class conv32_ehdr_class 2241618Srie #define conv_ehdr_data conv32_ehdr_data 2251618Srie #define conv_ehdr_flags conv32_ehdr_flags 2261618Srie #define conv_ehdr_mach conv32_ehdr_mach 2271618Srie #define conv_ehdr_type conv32_ehdr_type 2281618Srie #define conv_ehdr_vers conv32_ehdr_vers 2291618Srie #define conv_expn_field conv32_expn_field 2301618Srie #define conv_invalid_val conv32_invalid_val 2311618Srie #define conv_phdr_flags conv32_phdr_flags 2321618Srie #define conv_phdr_type conv32_phdr_type 2331618Srie #define conv_reject_desc conv32_reject_desc 2341618Srie #define conv_reloc_type conv32_reloc_type 2351618Srie #define conv_reloc_386_type conv32_reloc_386_type 2361618Srie #define conv_reloc_amd64_type conv32_reloc_amd64_type 2371618Srie #define conv_reloc_SPARC_type conv32_reloc_SPARC_type 2381618Srie #define conv_sec_flags conv32_sec_flags 239*2647Srie #define conv_sec_linkinfo conv32_sec_linkinfo 2401618Srie #define conv_sec_type conv32_sec_type 2411618Srie #define conv_sym_info_bind conv32_sym_info_bind 2421618Srie #define conv_sym_info_type conv32_sym_info_type 2431618Srie #define conv_sym_shndx conv32_sym_shndx 2441618Srie #define conv_sym_other conv32_sym_other 2451618Srie #define conv_sym_value conv32_sym_value 2461618Srie #define conv_sym_SPARC_value conv32_sym_SPARC_value 2471618Srie #endif 2481618Srie 2491618Srie extern const char *conv_bnd_obj(uint_t); 2501618Srie extern const char *conv_bnd_type(uint_t); 2511618Srie extern const char *conv_cap_tag(Xword); 2521618Srie extern const char *conv_cap_val(Xword, Xword, Half); 2531618Srie extern const char *conv_cap_val_hw1(Xword, Half); 2541618Srie extern const char *conv_cap_val_sf1(Xword, Half); 2551618Srie extern const char *conv_dyn_flag1(Xword); 2562352Sab196087 extern const char *conv_dyn_flag(Xword, int); 2572352Sab196087 extern const char *conv_dyn_posflag1(Xword, int); 2581976Sab196087 extern const char *conv_dyn_tag(Xword, Half, int); 2592352Sab196087 extern const char *conv_dyn_feature1(Xword, int); 2601976Sab196087 extern const char *conv_ehdr_class(uchar_t, int); 2611976Sab196087 extern const char *conv_ehdr_data(uchar_t, int); 2621618Srie extern const char *conv_ehdr_flags(Half, Word); 2631976Sab196087 extern const char *conv_ehdr_mach(Half, int); 2641976Sab196087 extern const char *conv_ehdr_type(Half, int); 2651976Sab196087 extern const char *conv_ehdr_vers(Word, int); 2662352Sab196087 extern int conv_expn_field(CONV_EXPN_FIELD_ARG *); 2671618Srie extern const char *conv_invalid_val(char *, size_t, Xword, int); 2681618Srie extern const char *conv_phdr_flags(Word); 2691618Srie extern const char *conv_phdr_type(Half, Word); 2701618Srie extern const char *conv_reject_desc(Rej_desc *); 2711976Sab196087 extern const char *conv_reloc_type(Half, Word, int); 2721976Sab196087 extern const char *conv_reloc_386_type(Word, int); 2731976Sab196087 extern const char *conv_reloc_amd64_type(Word, int); 2741976Sab196087 extern const char *conv_reloc_SPARC_type(Word, int); 2751618Srie extern const char *conv_sec_flags(Xword); 276*2647Srie extern const char *conv_sec_linkinfo(Word, Xword); 2771976Sab196087 extern const char *conv_sec_type(Half, Word, int); 2781976Sab196087 extern const char *conv_sym_info_bind(uchar_t, int); 2791976Sab196087 extern const char *conv_sym_info_type(Half, uchar_t, int); 2801618Srie extern const char *conv_sym_shndx(Half); 2811618Srie extern const char *conv_sym_other(uchar_t); 2821618Srie extern const char *conv_sym_value(Half, uchar_t, Addr); 2831976Sab196087 extern const char *conv_sym_SPARC_value(Addr, int); 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate #ifdef __cplusplus 2860Sstevel@tonic-gate } 2870Sstevel@tonic-gate #endif 2880Sstevel@tonic-gate 2890Sstevel@tonic-gate #endif /* _CONV_H */ 290