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 /* 82*c13de8f6Sab196087 * Flags that alter standard formatting for conversion routines. 835aefb655Srie */ 84*c13de8f6Sab196087 #define CONV_FMT_DECIMAL 0x1 /* conv_invalid_val() should print */ 85*c13de8f6Sab196087 /* integer print as decimal */ 86*c13de8f6Sab196087 /* (default is hex) */ 87*c13de8f6Sab196087 #define CONV_FMT_SPACE 0x2 /* conv_invalid_val() should append */ 88*c13de8f6Sab196087 /* a space after the number. */ 89*c13de8f6Sab196087 #define CONV_FMT_ALTDUMP 0x4 /* Output strings using the versions */ 90*c13de8f6Sab196087 /* used by the dump program. */ 91*c13de8f6Sab196087 #define CONV_FMT_ALTFILE 0x8 /* Output strings in the form used */ 92*c13de8f6Sab196087 /* by the file(1) command */ 93*c13de8f6Sab196087 94*c13de8f6Sab196087 /* 95*c13de8f6Sab196087 * Mask of CONV_FMT bits that reflect a desire to use alternate strings. 96*c13de8f6Sab196087 */ 97*c13de8f6Sab196087 #define CONV_FMTALTMASK (CONV_FMT_ALTDUMP|CONV_FMT_ALTFILE) 985aefb655Srie 995aefb655Srie /* 1005aefb655Srie * The expansion of bit-field data items is driven from a value descriptor and 1015aefb655Srie * the conv_expn_field() routine. 1025aefb655Srie */ 1035aefb655Srie typedef struct { 1045aefb655Srie Xword v_val; /* expansion value */ 1055aefb655Srie const char *v_msg; /* associated message string */ 1065aefb655Srie } Val_desc; 1075aefb655Srie 1085aefb655Srie /* 1095aefb655Srie * Define all generic interfaces. 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate extern void conv_check_native(char **, char **); 1125aefb655Srie extern const char *conv_config_feat(int); 1137c478bd9Sstevel@tonic-gate extern const char *conv_config_obj(ushort_t); 1145aefb655Srie extern const char *conv_config_upm(const char *, const char *, 1155aefb655Srie const char *, size_t); 1165aefb655Srie extern const char *conv_def_tag(Symref); 1175aefb655Srie extern const char *conv_demangle_name(const char *); 1185aefb655Srie extern const char *conv_dl_flag(int, int); 1195aefb655Srie extern const char *conv_dl_mode(int, int); 1205aefb655Srie extern const char *conv_dwarf_ehe(uint_t); 1215aefb655Srie extern const char *conv_elfdata_type(Elf_Type); 1225aefb655Srie extern const char *conv_grphdl_flags(uint_t); 1237c478bd9Sstevel@tonic-gate extern Isa_desc *conv_isalist(void); 1247c478bd9Sstevel@tonic-gate extern const char *conv_lddstub(int); 1255aefb655Srie extern const char *conv_seg_flags(Half); 1267c478bd9Sstevel@tonic-gate extern int conv_sys_eclass(); 1277c478bd9Sstevel@tonic-gate extern Uts_desc *conv_uts(void); 1285aefb655Srie extern const char *conv_ver_flags(Half); 1295aefb655Srie 1305aefb655Srie /* 1315aefb655Srie * Define all class specific routines. 1325aefb655Srie */ 1335aefb655Srie #if defined(_ELF64) 1345aefb655Srie #define conv_bnd_obj conv64_bnd_obj 1355aefb655Srie #define conv_bnd_type conv64_bnd_type 1365aefb655Srie #define conv_cap_tag conv64_cap_tag 1375aefb655Srie #define conv_cap_val conv64_cap_val 1385aefb655Srie #define conv_cap_val_hw1 conv64_cap_val_hw1 1395aefb655Srie #define conv_cap_val_sf1 conv64_cap_val_sf1 1405aefb655Srie #define conv_dyn_feature1 conv64_dyn_feature1 1415aefb655Srie #define conv_dyn_flag1 conv64_dyn_flag1 1425aefb655Srie #define conv_dyn_flag conv64_dyn_flag 1435aefb655Srie #define conv_dyn_posflag1 conv64_dyn_posflag1 1445aefb655Srie #define conv_dyn_tag conv64_dyn_tag 1455aefb655Srie #define conv_ehdr_class conv64_ehdr_class 1465aefb655Srie #define conv_ehdr_data conv64_ehdr_data 1475aefb655Srie #define conv_ehdr_flags conv64_ehdr_flags 1485aefb655Srie #define conv_ehdr_mach conv64_ehdr_mach 1495aefb655Srie #define conv_ehdr_type conv64_ehdr_type 1505aefb655Srie #define conv_ehdr_vers conv64_ehdr_vers 1515aefb655Srie #define conv_expn_field conv64_expn_field 1525aefb655Srie #define conv_invalid_val conv64_invalid_val 1535aefb655Srie #define conv_phdr_flags conv64_phdr_flags 1545aefb655Srie #define conv_phdr_type conv64_phdr_type 1555aefb655Srie #define conv_reject_desc conv64_reject_desc 1565aefb655Srie #define conv_reloc_type conv64_reloc_type 1575aefb655Srie #define conv_reloc_386_type conv64_reloc_386_type 1585aefb655Srie #define conv_reloc_amd64_type conv64_reloc_amd64_type 1595aefb655Srie #define conv_reloc_SPARC_type conv64_reloc_SPARC_type 1605aefb655Srie #define conv_sec_flags conv64_sec_flags 1615aefb655Srie #define conv_sec_info conv64_sec_info 1625aefb655Srie #define conv_sec_type conv64_sec_type 1635aefb655Srie #define conv_sym_info_bind conv64_sym_info_bind 1645aefb655Srie #define conv_sym_info_type conv64_sym_info_type 1655aefb655Srie #define conv_sym_shndx conv64_sym_shndx 1665aefb655Srie #define conv_sym_other conv64_sym_other 1675aefb655Srie #define conv_sym_value conv64_sym_value 1685aefb655Srie #define conv_sym_SPARC_value conv64_sym_SPARC_value 1695aefb655Srie #else 1705aefb655Srie #define conv_bnd_obj conv32_bnd_obj 1715aefb655Srie #define conv_bnd_type conv32_bnd_type 1725aefb655Srie #define conv_cap_tag conv32_cap_tag 1735aefb655Srie #define conv_cap_val conv32_cap_val 1745aefb655Srie #define conv_cap_val_hw1 conv32_cap_val_hw1 1755aefb655Srie #define conv_cap_val_sf1 conv32_cap_val_sf1 1765aefb655Srie #define conv_dyn_feature1 conv32_dyn_feature1 1775aefb655Srie #define conv_dyn_flag1 conv32_dyn_flag1 1785aefb655Srie #define conv_dyn_flag conv32_dyn_flag 1795aefb655Srie #define conv_dyn_posflag1 conv32_dyn_posflag1 1805aefb655Srie #define conv_dyn_tag conv32_dyn_tag 1815aefb655Srie #define conv_ehdr_class conv32_ehdr_class 1825aefb655Srie #define conv_ehdr_data conv32_ehdr_data 1835aefb655Srie #define conv_ehdr_flags conv32_ehdr_flags 1845aefb655Srie #define conv_ehdr_mach conv32_ehdr_mach 1855aefb655Srie #define conv_ehdr_type conv32_ehdr_type 1865aefb655Srie #define conv_ehdr_vers conv32_ehdr_vers 1875aefb655Srie #define conv_expn_field conv32_expn_field 1885aefb655Srie #define conv_invalid_val conv32_invalid_val 1895aefb655Srie #define conv_phdr_flags conv32_phdr_flags 1905aefb655Srie #define conv_phdr_type conv32_phdr_type 1915aefb655Srie #define conv_reject_desc conv32_reject_desc 1925aefb655Srie #define conv_reloc_type conv32_reloc_type 1935aefb655Srie #define conv_reloc_386_type conv32_reloc_386_type 1945aefb655Srie #define conv_reloc_amd64_type conv32_reloc_amd64_type 1955aefb655Srie #define conv_reloc_SPARC_type conv32_reloc_SPARC_type 1965aefb655Srie #define conv_sec_flags conv32_sec_flags 1975aefb655Srie #define conv_sec_info conv32_sec_info 1985aefb655Srie #define conv_sec_type conv32_sec_type 1995aefb655Srie #define conv_sym_info_bind conv32_sym_info_bind 2005aefb655Srie #define conv_sym_info_type conv32_sym_info_type 2015aefb655Srie #define conv_sym_shndx conv32_sym_shndx 2025aefb655Srie #define conv_sym_other conv32_sym_other 2035aefb655Srie #define conv_sym_value conv32_sym_value 2045aefb655Srie #define conv_sym_SPARC_value conv32_sym_SPARC_value 2055aefb655Srie #endif 2065aefb655Srie 2075aefb655Srie extern const char *conv_bnd_obj(uint_t); 2085aefb655Srie extern const char *conv_bnd_type(uint_t); 2095aefb655Srie extern const char *conv_cap_tag(Xword); 2105aefb655Srie extern const char *conv_cap_val(Xword, Xword, Half); 2115aefb655Srie extern const char *conv_cap_val_hw1(Xword, Half); 2125aefb655Srie extern const char *conv_cap_val_sf1(Xword, Half); 2135aefb655Srie extern const char *conv_dyn_flag1(Xword); 2145aefb655Srie extern const char *conv_dyn_flag(Xword); 2155aefb655Srie extern const char *conv_dyn_posflag1(Xword); 216*c13de8f6Sab196087 extern const char *conv_dyn_tag(Xword, Half, int); 2175aefb655Srie extern const char *conv_dyn_feature1(Xword); 218*c13de8f6Sab196087 extern const char *conv_ehdr_class(uchar_t, int); 219*c13de8f6Sab196087 extern const char *conv_ehdr_data(uchar_t, int); 2205aefb655Srie extern const char *conv_ehdr_flags(Half, Word); 221*c13de8f6Sab196087 extern const char *conv_ehdr_mach(Half, int); 222*c13de8f6Sab196087 extern const char *conv_ehdr_type(Half, int); 223*c13de8f6Sab196087 extern const char *conv_ehdr_vers(Word, int); 2245aefb655Srie extern int conv_expn_field(char *, size_t, const Val_desc *, 2255aefb655Srie Xword, Xword, const char *, int); 2265aefb655Srie extern const char *conv_invalid_val(char *, size_t, Xword, int); 2275aefb655Srie extern const char *conv_phdr_flags(Word); 2285aefb655Srie extern const char *conv_phdr_type(Half, Word); 2295aefb655Srie extern const char *conv_reject_desc(Rej_desc *); 230*c13de8f6Sab196087 extern const char *conv_reloc_type(Half, Word, int); 231*c13de8f6Sab196087 extern const char *conv_reloc_386_type(Word, int); 232*c13de8f6Sab196087 extern const char *conv_reloc_amd64_type(Word, int); 233*c13de8f6Sab196087 extern const char *conv_reloc_SPARC_type(Word, int); 2345aefb655Srie extern const char *conv_sec_flags(Xword); 2355aefb655Srie extern const char *conv_sec_info(Word, Xword); 236*c13de8f6Sab196087 extern const char *conv_sec_type(Half, Word, int); 237*c13de8f6Sab196087 extern const char *conv_sym_info_bind(uchar_t, int); 238*c13de8f6Sab196087 extern const char *conv_sym_info_type(Half, uchar_t, int); 2395aefb655Srie extern const char *conv_sym_shndx(Half); 2405aefb655Srie extern const char *conv_sym_other(uchar_t); 2415aefb655Srie extern const char *conv_sym_value(Half, uchar_t, Addr); 242*c13de8f6Sab196087 extern const char *conv_sym_SPARC_value(Addr, int); 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #ifdef __cplusplus 2457c478bd9Sstevel@tonic-gate } 2467c478bd9Sstevel@tonic-gate #endif 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate #endif /* _CONV_H */ 249