xref: /onnv-gate/usr/src/cmd/sgs/include/conv.h (revision 9963:d23f520cfd07)
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  *
269085SAli.Bahrami@Sun.COM  * Copyright 2009 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 /*
340Sstevel@tonic-gate  * Global include file for conversion library.
350Sstevel@tonic-gate  */
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #include <stdlib.h>
380Sstevel@tonic-gate #include <libelf.h>
390Sstevel@tonic-gate #include <dlfcn.h>
400Sstevel@tonic-gate #include <libld.h>
410Sstevel@tonic-gate #include <sgs.h>
429273SAli.Bahrami@Sun.COM #include <sgsmsg.h>
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #ifdef	__cplusplus
450Sstevel@tonic-gate extern "C" {
460Sstevel@tonic-gate #endif
470Sstevel@tonic-gate 
480Sstevel@tonic-gate /*
490Sstevel@tonic-gate  * Configuration features available - maintained here (instead of debug.h)
500Sstevel@tonic-gate  * to save libconv from having to include debug.h which results in numerous
510Sstevel@tonic-gate  * "declared but not used or defined" lint errors.
520Sstevel@tonic-gate  */
530Sstevel@tonic-gate #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
540Sstevel@tonic-gate #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
550Sstevel@tonic-gate #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
560Sstevel@tonic-gate #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
570Sstevel@tonic-gate #define	CONF_DIRCFG	0x001000	/* directory configuration available */
580Sstevel@tonic-gate #define	CONF_OBJALT	0x002000	/* object alternatives available */
590Sstevel@tonic-gate #define	CONF_MEMRESV	0x004000	/* memory reservation required */
600Sstevel@tonic-gate #define	CONF_ENVS	0x008000	/* environment variables available */
610Sstevel@tonic-gate #define	CONF_FLTR	0x010000	/* filter information available */
620Sstevel@tonic-gate #define	CONF_FEATMSK	0xffff00
630Sstevel@tonic-gate 
649406SAli.Bahrami@Sun.COM 
659406SAli.Bahrami@Sun.COM /*
669406SAli.Bahrami@Sun.COM  * Valid flags for conv_strproc_extract_value().
679406SAli.Bahrami@Sun.COM  */
689406SAli.Bahrami@Sun.COM #define	CONV_SPEXV_F_NOTRIM	0x0001	/* Do not trim whitespace around '=' */
699406SAli.Bahrami@Sun.COM #define	CONV_SPEXV_F_UCASE	0x0002	/* Convert value to uppercase */
709406SAli.Bahrami@Sun.COM #define	CONV_SPEXV_F_NULLOK	0x0004	 /* Empty ("") value is OK */
719406SAli.Bahrami@Sun.COM 
720Sstevel@tonic-gate /*
734734Sab196087  * Buffer types:
744734Sab196087  *
754734Sab196087  * Many of the routines in this module require the user to supply a
764734Sab196087  * buffer into which the desired strings may be written. These are
774734Sab196087  * all arrays of characters, and might be defined as simple arrays
784734Sab196087  * of char. The problem with that approach is that when such an array
794734Sab196087  * is passed to a function, the C language considers it to have the
804734Sab196087  * type (char *), without any regard to its length. Not all of our
814734Sab196087  * buffers have the same length, and we want to ensure that the compiler
824734Sab196087  * will refuse to compile code that passes the wrong type of buffer to
834734Sab196087  * a given routine. The solution is to define the buffers as unions
844734Sab196087  * that contain the needed array, and then to pass the given union
854734Sab196087  * by address. The compiler will catch attempts to pass the wrong type
864734Sab196087  * of pointer, and the size of a structure/union is implicit in its type.
874734Sab196087  *
884734Sab196087  * A nice side effect of this approach is that we can use a union with
894734Sab196087  * multiple buffers to handle the cases where a given routine needs
904734Sab196087  * more than one type of buffer. The end result is a single buffer large
914734Sab196087  * enough to handle any of the subcases, but no larger.
924734Sab196087  */
934734Sab196087 
944734Sab196087 /*
954734Sab196087  * Size of buffer used by conv_invalid_val():
964734Sab196087  *
971618Srie  * Various values that can't be matched to a symbolic definition are converted
984734Sab196087  * to a numeric string.
994734Sab196087  *
1004734Sab196087  * The buffer size reflects the maximum number of digits needed to
1014734Sab196087  * display an integer as text, plus a trailing null, and with room for
1024734Sab196087  * a leading "0x" if hexidecimal display is selected.
1039273SAli.Bahrami@Sun.COM  *
1049273SAli.Bahrami@Sun.COM  * The 32-bit version of this requires 12 characters, and the 64-bit version
1059273SAli.Bahrami@Sun.COM  * needs 22. By using the larger value for both, we can have a single
1069273SAli.Bahrami@Sun.COM  * definition, which is necessary for code that is ELFCLASS independent. A
1079273SAli.Bahrami@Sun.COM  * nice side benefit is that it lets us dispense with a large number of 32/64
1089273SAli.Bahrami@Sun.COM  * buffer size definitions that build off CONV_INV_BUFSIZE, and the macros
1099273SAli.Bahrami@Sun.COM  * that would then be needed.
1104734Sab196087  */
1119273SAli.Bahrami@Sun.COM #define	CONV_INV_BUFSIZE		22
1124734Sab196087 typedef union {
1139273SAli.Bahrami@Sun.COM 	char				buf[CONV_INV_BUFSIZE];
1149273SAli.Bahrami@Sun.COM } Conv_inv_buf_t;
1154734Sab196087 
1164734Sab196087 /* conv_ehdr_flags() */
1179273SAli.Bahrami@Sun.COM #define	CONV_EHDR_FLAGS_BUFSIZE		91
1184734Sab196087 typedef union {
1199273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1209273SAli.Bahrami@Sun.COM 	char				buf[CONV_EHDR_FLAGS_BUFSIZE];
1219273SAli.Bahrami@Sun.COM } Conv_ehdr_flags_buf_t;
1224734Sab196087 
1234734Sab196087 /* conv_reject_desc() */
1244734Sab196087 typedef union {
1259273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1269273SAli.Bahrami@Sun.COM 	Conv_ehdr_flags_buf_t		flags_buf;
1279273SAli.Bahrami@Sun.COM } Conv_reject_desc_buf_t;
1284734Sab196087 
1294734Sab196087 /*
1304734Sab196087  * conv_cap_val_hw1()
1314734Sab196087  *
1324734Sab196087  * This size is based on the maximum number of hardware capabilities
1334734Sab196087  * that exist.  See common/elfcap.
1344734Sab196087  */
1354734Sab196087 #define	CONV_CAP_VAL_HW1_BUFSIZE	195
1364734Sab196087 typedef union {
1379273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1389273SAli.Bahrami@Sun.COM 	char				buf[CONV_CAP_VAL_HW1_BUFSIZE];
1399273SAli.Bahrami@Sun.COM } Conv_cap_val_hw1_buf_t;
1404734Sab196087 
1414734Sab196087 /*
1424734Sab196087  * conv_cap_val_sf1()
1431618Srie  *
1444734Sab196087  * This size is based on the maximum number of software capabilities
1454734Sab196087  * that exist.  See common/elfcap.
1464734Sab196087  */
1474734Sab196087 #define	CONV_CAP_VAL_SF1_BUFSIZE	45
1484734Sab196087 typedef union {
1499273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1509273SAli.Bahrami@Sun.COM 	char				buf[CONV_CAP_VAL_SF1_BUFSIZE];
1519273SAli.Bahrami@Sun.COM } Conv_cap_val_sf1_buf_t;
1524734Sab196087 
1534734Sab196087 /* conv_cap_val_buf() */
1544734Sab196087 typedef union {
1559273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1569273SAli.Bahrami@Sun.COM 	Conv_cap_val_hw1_buf_t		cap_val_hw1_buf;
1579273SAli.Bahrami@Sun.COM 	Conv_cap_val_sf1_buf_t		cap_val_sf1_buf;
1589273SAli.Bahrami@Sun.COM } Conv_cap_val_buf_t;
1594734Sab196087 
1604734Sab196087 /* conv_config_feat() */
1619273SAli.Bahrami@Sun.COM #define	CONV_CONFIG_FEAT_BUFSIZE	204
1624734Sab196087 typedef union {
1639273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1649273SAli.Bahrami@Sun.COM 	char				buf[CONV_CONFIG_FEAT_BUFSIZE];
1659273SAli.Bahrami@Sun.COM } Conv_config_feat_buf_t;
1664734Sab196087 
1674734Sab196087 /* conv_config_obj() */
1689273SAli.Bahrami@Sun.COM #define	CONV_CONFIG_OBJ_BUFSIZE		164
1694734Sab196087 typedef union {
1709273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1719273SAli.Bahrami@Sun.COM 	char				buf[CONV_CONFIG_OBJ_BUFSIZE];
1729273SAli.Bahrami@Sun.COM } Conv_config_obj_buf_t;
1734734Sab196087 
1744734Sab196087 /* conv_dl_mode() */
1759273SAli.Bahrami@Sun.COM #define	CONV_DL_MODE_BUFSIZE		132
1764734Sab196087 typedef union {
1779273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1789273SAli.Bahrami@Sun.COM 	char				buf[CONV_DL_MODE_BUFSIZE];
1799273SAli.Bahrami@Sun.COM } Conv_dl_mode_buf_t;
1804734Sab196087 
1814734Sab196087 /* conv_dl_flag() */
1829273SAli.Bahrami@Sun.COM #define	CONV_DL_FLAG_BUFSIZE		185
1834734Sab196087 typedef union {
1849273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1859273SAli.Bahrami@Sun.COM 	char				buf[CONV_DL_FLAG_BUFSIZE];
1869273SAli.Bahrami@Sun.COM } Conv_dl_flag_buf_t;
1874734Sab196087 
1884734Sab196087 /* conv_grphdl_flags() */
189*9963SRod.Evans@Sun.COM #define	CONV_GRPHDL_FLAGS_BUFSIZE	78
1904734Sab196087 typedef union {
1919273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1929273SAli.Bahrami@Sun.COM 	char				buf[CONV_GRPHDL_FLAGS_BUFSIZE];
1939273SAli.Bahrami@Sun.COM } Conv_grphdl_flags_buf_t;
1944734Sab196087 
1954734Sab196087 /* conv_grpdesc_flags() */
1969577SRod.Evans@Sun.COM #define	CONV_GRPDESC_FLAGS_BUFSIZE	91
1974734Sab196087 typedef union {
1989273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1999273SAli.Bahrami@Sun.COM 	char				buf[CONV_GRPDESC_FLAGS_BUFSIZE];
2009273SAli.Bahrami@Sun.COM } Conv_grpdesc_flags_buf_t;
2014734Sab196087 
2024734Sab196087 /* conv_seg_flags() */
2039273SAli.Bahrami@Sun.COM #define	CONV_SEG_FLAGS_BUFSIZE		196
2044734Sab196087 typedef union {
2059273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2069273SAli.Bahrami@Sun.COM 	char				buf[CONV_SEG_FLAGS_BUFSIZE];
2079273SAli.Bahrami@Sun.COM } Conv_seg_flags_buf_t;
2084734Sab196087 
2094734Sab196087 /* conv_dyn_posflag1() */
2109273SAli.Bahrami@Sun.COM #define	CONV_DYN_POSFLAG1_BUFSIZE	57
2114734Sab196087 typedef union {
2129273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2139273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_POSFLAG1_BUFSIZE];
2149273SAli.Bahrami@Sun.COM } Conv_dyn_posflag1_buf_t;
2154734Sab196087 
2164734Sab196087 /* conv_dyn_flag() */
2179273SAli.Bahrami@Sun.COM #define	CONV_DYN_FLAG_BUFSIZE		85
2184734Sab196087 typedef union {
2199273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2209273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FLAG_BUFSIZE];
2219273SAli.Bahrami@Sun.COM } Conv_dyn_flag_buf_t;
2224734Sab196087 
2234734Sab196087 /* conv_dyn_flag1() */
2249273SAli.Bahrami@Sun.COM #define	CONV_DYN_FLAG1_BUFSIZE		361
2254734Sab196087 typedef union {
2269273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2279273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FLAG1_BUFSIZE];
2289273SAli.Bahrami@Sun.COM } Conv_dyn_flag1_buf_t;
2294734Sab196087 
2304734Sab196087 /* conv_dyn_feature1() */
2319273SAli.Bahrami@Sun.COM #define	CONV_DYN_FEATURE1_BUFSIZE	54
2324734Sab196087 typedef union {
2339273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2349273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FEATURE1_BUFSIZE];
2359273SAli.Bahrami@Sun.COM } Conv_dyn_feature1_buf_t;
2364734Sab196087 
2374734Sab196087 /* conv_bnd_type() */
2389273SAli.Bahrami@Sun.COM #define	CONV_BND_TYPE_BUFSIZE		51
2394734Sab196087 typedef union {
2409273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2419273SAli.Bahrami@Sun.COM 	char				buf[CONV_BND_TYPE_BUFSIZE];
2429273SAli.Bahrami@Sun.COM } Conv_bnd_type_buf_t;
2434734Sab196087 
2444734Sab196087 /* conv_bnd_obj() */
2459273SAli.Bahrami@Sun.COM #define	CONV_BND_OBJ_BUFSIZE		60
2464734Sab196087 typedef union {
2479273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2489273SAli.Bahrami@Sun.COM 	char				buf[CONV_BND_OBJ_BUFSIZE];
2499273SAli.Bahrami@Sun.COM } Conv_bnd_obj_buf_t;
2504734Sab196087 
2514734Sab196087 /* conv_phdr_flags() */
2529273SAli.Bahrami@Sun.COM #define	CONV_PHDR_FLAGS_BUFSIZE		57
2534734Sab196087 typedef union {
2549577SRod.Evans@Sun.COM 	Conv_inv_buf_t			inv_buf;
2559577SRod.Evans@Sun.COM 	char				buf[CONV_PHDR_FLAGS_BUFSIZE];
2569273SAli.Bahrami@Sun.COM } Conv_phdr_flags_buf_t;
2574734Sab196087 
2584734Sab196087 /* conv_sec_flags() */
2599273SAli.Bahrami@Sun.COM #define	CONV_SEC_FLAGS_BUFSIZE		190
2604734Sab196087 typedef union {
2619273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2629273SAli.Bahrami@Sun.COM 	char				buf[CONV_SEC_FLAGS_BUFSIZE];
2639273SAli.Bahrami@Sun.COM } Conv_sec_flags_buf_t;
2644734Sab196087 
2654734Sab196087 /* conv_dwarf_ehe() */
2669273SAli.Bahrami@Sun.COM #define	CONV_DWARF_EHE_BUFSIZE		43
2674734Sab196087 typedef union {
2689273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2699273SAli.Bahrami@Sun.COM 	char				buf[CONV_DWARF_EHE_BUFSIZE];
2709273SAli.Bahrami@Sun.COM } Conv_dwarf_ehe_buf_t;
2714734Sab196087 
2725088Sab196087 /* conv_syminfo_flags() */
2739273SAli.Bahrami@Sun.COM #define	CONV_SYMINFO_FLAGS_BUFSIZE	193
2745088Sab196087 typedef union {
2759273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2769273SAli.Bahrami@Sun.COM 	char				buf[CONV_SYMINFO_FLAGS_BUFSIZE];
2779273SAli.Bahrami@Sun.COM } Conv_syminfo_flags_buf_t;
2785088Sab196087 
2796635Sab196087 /* conv_cnote_pr_flags() */
2809273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_PR_FLAGS_BUFSIZE	254
2816635Sab196087 typedef union {
2829273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2839273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
2849273SAli.Bahrami@Sun.COM } Conv_cnote_pr_flags_buf_t;
2856635Sab196087 
2866635Sab196087 /* conv_cnote_old_pr_flags() */
2879273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE	174
2886635Sab196087 typedef union {
2899273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2909273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
2919273SAli.Bahrami@Sun.COM } Conv_cnote_old_pr_flags_buf_t;
2926635Sab196087 
2936635Sab196087 /* conv_cnote_proc_flag() */
2949273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_PROC_FLAG_BUFSIZE	39
2956635Sab196087 typedef union {
2969273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2979273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
2989273SAli.Bahrami@Sun.COM } Conv_cnote_proc_flag_buf_t;
2996635Sab196087 
3006635Sab196087 
3016635Sab196087 /* conv_cnote_sigset() */
3029273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SIGSET_BUFSIZE	639
3036635Sab196087 typedef union {
3049273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3059273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SIGSET_BUFSIZE];
3069273SAli.Bahrami@Sun.COM } Conv_cnote_sigset_buf_t;
3076635Sab196087 
3086635Sab196087 /* conv_cnote_fltset() */
3099273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_FLTSET_BUFSIZE	511
3106635Sab196087 typedef union {
3119273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3129273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_FLTSET_BUFSIZE];
3139273SAli.Bahrami@Sun.COM } Conv_cnote_fltset_buf_t;
3146635Sab196087 
3156635Sab196087 /* conv_cnote_sysset() */
3169273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SYSSET_BUFSIZE	3222
3176635Sab196087 typedef union {
3189273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3199273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SYSSET_BUFSIZE];
3209273SAli.Bahrami@Sun.COM } Conv_cnote_sysset_buf_t;
3216635Sab196087 
3226635Sab196087 /* conv_cnote_sa_flags() */
3239273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SA_FLAGS_BUFSIZE	109
3246635Sab196087 typedef union {
3259273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3269273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
3279273SAli.Bahrami@Sun.COM } Conv_cnote_sa_flags_buf_t;
3286635Sab196087 
3296635Sab196087 /* conv_cnote_ss_flags() */
3309273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SS_FLAGS_BUFSIZE	48
3316635Sab196087 typedef union {
3329273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3339273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
3349273SAli.Bahrami@Sun.COM } Conv_cnote_ss_flags_buf_t;
3356635Sab196087 
3366635Sab196087 /* conv_cnote_cc_content() */
3379273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_CC_CONTENT_BUFSIZE	97
3386635Sab196087 typedef union {
3399273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3409273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
3419273SAli.Bahrami@Sun.COM } Conv_cnote_cc_content_buf_t;
3426635Sab196087 
3436635Sab196087 /* conv_cnote_auxv_af() */
3449273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_AUXV_AF_BUFSIZE	73
3456635Sab196087 typedef union {
3469273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3479273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
3489273SAli.Bahrami@Sun.COM } Conv_cnote_auxv_af_buf_t;
3496635Sab196087 
3507682SAli.Bahrami@Sun.COM /* conv_ver_flags() */
3519273SAli.Bahrami@Sun.COM #define	CONV_VER_FLAGS_BUFSIZE		41
3527682SAli.Bahrami@Sun.COM typedef union {
3539273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3549273SAli.Bahrami@Sun.COM 	char				buf[CONV_VER_FLAGS_BUFSIZE];
3559273SAli.Bahrami@Sun.COM } Conv_ver_flags_buf_t;
3564734Sab196087 
3579577SRod.Evans@Sun.COM /*
3589577SRod.Evans@Sun.COM  * conv_time()
3599577SRod.Evans@Sun.COM  *
3609577SRod.Evans@Sun.COM  * This size is based on the maximum "hour.min.sec.fraction: " time that
3619577SRod.Evans@Sun.COM  * would be expected of ld().
3629577SRod.Evans@Sun.COM  */
3639577SRod.Evans@Sun.COM #define	CONV_TIME_BUFSIZE		18
3649577SRod.Evans@Sun.COM typedef union {
3659577SRod.Evans@Sun.COM 	char				buf[CONV_TIME_BUFSIZE];
3669577SRod.Evans@Sun.COM } Conv_time_buf_t;
3672850Srie 
3682850Srie /*
3695088Sab196087  * Many conversion routines accept a fmt_flags argument of this type
3705088Sab196087  * to allow the caller to modify the output. There are two parts to
3715088Sab196087  * this value:
3725088Sab196087  *
3735088Sab196087  *	(1) Format requests (decimal vs hex, etc...)
3745088Sab196087  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
3755088Sab196087  *		and retrieved by CONV_TYPE_FMT_ALT are integer
3765088Sab196087  *		values that specify that an alternate set of
3779273SAli.Bahrami@Sun.COM  *		strings should be used.
3785088Sab196087  *
3799273SAli.Bahrami@Sun.COM  * The fmt_flags value is designed such that a caller can always
3809273SAli.Bahrami@Sun.COM  * supply a 0 in order to receive default behavior.
3811618Srie  */
3825088Sab196087 typedef int Conv_fmt_flags_t;
3835088Sab196087 
3845088Sab196087 /*
3859273SAli.Bahrami@Sun.COM  * Type used to represent ELF constants within libconv. This relies on
3869273SAli.Bahrami@Sun.COM  * the fact that there are no ELF constants that need more than 32-bits,
3879273SAli.Bahrami@Sun.COM  * nor are there any signed values.
3889273SAli.Bahrami@Sun.COM  */
3899273SAli.Bahrami@Sun.COM typedef uint32_t Conv_elfvalue_t;
3909273SAli.Bahrami@Sun.COM 
3919273SAli.Bahrami@Sun.COM /*
3929273SAli.Bahrami@Sun.COM  * Most conversion routines are able to provide strings in one of
3939273SAli.Bahrami@Sun.COM  * several alternative styles. The bottom 8 bits of Conv_fmt_flags_t
3949273SAli.Bahrami@Sun.COM  * are used to specify which strings should be used for a given call
3959273SAli.Bahrami@Sun.COM  * to a conversion routine:
3969273SAli.Bahrami@Sun.COM  *
3979273SAli.Bahrami@Sun.COM  *   DEFAULT
3989273SAli.Bahrami@Sun.COM  *	The default string style used by a given conversion routine is
3999273SAli.Bahrami@Sun.COM  *	an independent choice made by that routine. Different routines
4009273SAli.Bahrami@Sun.COM  *	make different choices, based largely on historical usage and
4019273SAli.Bahrami@Sun.COM  *	the perceived common case. It may be an alias for one of the
4029273SAli.Bahrami@Sun.COM  *	specific styles listed below, or it may be unique.
4039273SAli.Bahrami@Sun.COM  *
4049273SAli.Bahrami@Sun.COM  *   DUMP
4059273SAli.Bahrami@Sun.COM  *	Style of strings used by dump(1).
4069273SAli.Bahrami@Sun.COM  *
4079273SAli.Bahrami@Sun.COM  *   FILE
4089273SAli.Bahrami@Sun.COM  *	Style of strings used by file(1).
4095088Sab196087  *
4109273SAli.Bahrami@Sun.COM  *   CRLE
4119273SAli.Bahrami@Sun.COM  *	Style of strings used by crle(1).
4129273SAli.Bahrami@Sun.COM  *
4139273SAli.Bahrami@Sun.COM  *   CF
4149273SAli.Bahrami@Sun.COM  *	Canonical Form: The string is exactly the same as the name
4159273SAli.Bahrami@Sun.COM  *	of the #define macro that defines it in the public header files.
4169273SAli.Bahrami@Sun.COM  *	(e.g. STB_LOCAL, not LOCL, LOCAL, LOC, or any other variation).
4179273SAli.Bahrami@Sun.COM  *
4189273SAli.Bahrami@Sun.COM  *   CFNP
4199273SAli.Bahrami@Sun.COM  *	No Prefix Canonical Form: The same strings supplied by CF,
4209273SAli.Bahrami@Sun.COM  *	but without their standard prefix. (e.g. LOCAL, instead of STT_LOCAL).
4219273SAli.Bahrami@Sun.COM  *
4229273SAli.Bahrami@Sun.COM  *   NF
4239273SAli.Bahrami@Sun.COM  *	Natural Form: The form of the strings that might typically be entered
4249273SAli.Bahrami@Sun.COM  *	via a keyboard by an interactive user. These are usually the strings
4259273SAli.Bahrami@Sun.COM  *	from CFNP, converted to lowercase, although in some cases they may
4269273SAli.Bahrami@Sun.COM  *	take some other "natural" form. In command completion applications,
4279273SAli.Bahrami@Sun.COM  *	lowercase strings appear less formal, and are easier on the eye.
4289273SAli.Bahrami@Sun.COM  *
4299273SAli.Bahrami@Sun.COM  * Every routine is required to have a default style. The others are optional,
4309273SAli.Bahrami@Sun.COM  * and may not be provided if not needed. If a given conversion routine does
4319273SAli.Bahrami@Sun.COM  * not support alternative strings for a given CONV_FMT_ALT type, it silently
4329273SAli.Bahrami@Sun.COM  * ignores the request and supplies the default set. This means that a utility
4339273SAli.Bahrami@Sun.COM  * like dump(1) is free to specify a style like DUMP to every conversion
4345088Sab196087  * routine. It will receive its special strings if there are any, and
4355088Sab196087  * the defaults otherwise.
4365088Sab196087  */
4375088Sab196087 #define	CONV_MASK_FMT_ALT		0xff
4385088Sab196087 #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
4395088Sab196087 
4405088Sab196087 #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
4419273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_DUMP	1	/* dump(1) */
4429273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_FILE	2	/* file(1) */
4439273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CRLE	3	/* crle(1) */
4449273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CF		4	/* Canonical Form */
4459273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CFNP	5	/* No Prefix Canonical Form */
4469273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_NF		6	/* Natural Form */
4475088Sab196087 
4485088Sab196087 /*
4495088Sab196087  * Flags that alter standard formatting for conversion routines.
4505088Sab196087  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
4515088Sab196087  */
4525088Sab196087 #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
4531976Sab196087 					/*    integer print as decimal */
4541976Sab196087 					/*    (default is hex) */
4555088Sab196087 #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
4561976Sab196087 					/*    a space after the number.  */
4575088Sab196087 #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
4585088Sab196087 					/*    prefix and suffix strings */
4591976Sab196087 
4609273SAli.Bahrami@Sun.COM /*
4619273SAli.Bahrami@Sun.COM  * A Val_desc structure is used to associate an ELF constant and
4629273SAli.Bahrami@Sun.COM  * the message code (Msg) for the string that corresponds to it.
4639273SAli.Bahrami@Sun.COM  *
4649273SAli.Bahrami@Sun.COM  * Val_desc2 adds v_osabi and v_mach fields to Val_desc, which allows
4659273SAli.Bahrami@Sun.COM  * for non-generic mappings that apply only to a specific OSABI/machine.
4669273SAli.Bahrami@Sun.COM  * Setting v_osabi to 0 (ELFOSABI_NONE) specifies that any OSABI matches.
4679273SAli.Bahrami@Sun.COM  * Similarly, setting v_mach to 0 (EM_MACH) matches any machine. Hence,
4689273SAli.Bahrami@Sun.COM  * setting v_osabi and v_mach to 0 in a Val_desc2 results in a generic item,
4699273SAli.Bahrami@Sun.COM  * and is equivalent to simply using a Val_desc.
4709273SAli.Bahrami@Sun.COM  *
4719273SAli.Bahrami@Sun.COM  * These structs are used in two different contexts:
4729273SAli.Bahrami@Sun.COM  *
4739273SAli.Bahrami@Sun.COM  * 1)	To expand bit-field data items, using conv_expn_field() to
4749273SAli.Bahrami@Sun.COM  *	process a NULL terminated array of Val_desc, or conv_expn_field2()
4759273SAli.Bahrami@Sun.COM  *	to process a null terminated array of Val_desc2.
4769273SAli.Bahrami@Sun.COM  *
4779273SAli.Bahrami@Sun.COM  * 2)	To represent sparse ranges of non-bitfield values, referenced via
4789273SAli.Bahrami@Sun.COM  *	conv_ds_vd_t or conv_ds_vd2_t descriptors, as described below.
4799273SAli.Bahrami@Sun.COM  */
4809273SAli.Bahrami@Sun.COM typedef struct {
4819273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	v_val;		/* expansion value */
4829273SAli.Bahrami@Sun.COM 	Msg		v_msg;		/* associated message string code */
4839273SAli.Bahrami@Sun.COM } Val_desc;
4849273SAli.Bahrami@Sun.COM typedef struct {
4859273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	v_val;		/* expansion value */
4869273SAli.Bahrami@Sun.COM 	uchar_t		v_osabi;	/* OSABI to which entry applies */
4879273SAli.Bahrami@Sun.COM 	Half		v_mach;		/* Machine to which entry applies */
4889273SAli.Bahrami@Sun.COM 	Msg		v_msg;		/* associated message string code */
4899273SAli.Bahrami@Sun.COM } Val_desc2;
4909273SAli.Bahrami@Sun.COM 
4919273SAli.Bahrami@Sun.COM /*
4929273SAli.Bahrami@Sun.COM  * The conv_ds_XXX_t structs are used to pull together the information used
4939273SAli.Bahrami@Sun.COM  * to map non-bitfield values to strings. They are a variant family, sharing
4949273SAli.Bahrami@Sun.COM  * the same initial fields, with a generic "header" definition that can be
4959273SAli.Bahrami@Sun.COM  * used to read those common fields and determine which subcase is being
4969273SAli.Bahrami@Sun.COM  * seen. We do this instead of using a single struct containing a type code
4979273SAli.Bahrami@Sun.COM  * and a union in order to allow for static compile-time initialization.
4989273SAli.Bahrami@Sun.COM  *
4999273SAli.Bahrami@Sun.COM  * conv_ds_t is the base type, containing the initial fields common to all
5009273SAli.Bahrami@Sun.COM  * the variants. Variables of type conv_ds_t are never instantiated. This
5019273SAli.Bahrami@Sun.COM  * type exists only to provide a common pointer type that can reference
5029273SAli.Bahrami@Sun.COM  * any of the variants safely. In C++, it would be a virtual base class.
5039273SAli.Bahrami@Sun.COM  * The fields common to all the variants are:
5049273SAli.Bahrami@Sun.COM  *
5059273SAli.Bahrami@Sun.COM  *	ds_type: Identifies the variant
5069273SAli.Bahrami@Sun.COM  *	ds_baseval/ds_topval: The lower and upper bound of the range
5079273SAli.Bahrami@Sun.COM  *		of values represented by this conv_ds_XXX_t descriptor.
5089273SAli.Bahrami@Sun.COM  *
5099273SAli.Bahrami@Sun.COM  * There are three different variants:
5109273SAli.Bahrami@Sun.COM  *    conv_ds_msg_t (ds_type == CONV_DS_MSGARR)
5119273SAli.Bahrami@Sun.COM  *	This structure references an array of message codes corresponding
5129273SAli.Bahrami@Sun.COM  *	to consecutive ELF values. The first item in the array is the Msg
5139273SAli.Bahrami@Sun.COM  *	code for the value given by ds_baseval. Consecutive strings follow
5149273SAli.Bahrami@Sun.COM  *	in consecutive order. The final item corresponds to the value given
5159273SAli.Bahrami@Sun.COM  *	by ds_topval. Zero (0) Msg values can be used to represent missing
5169273SAli.Bahrami@Sun.COM  *	values. Entries with a 0 are quietly ignored.
5179273SAli.Bahrami@Sun.COM  *
5189273SAli.Bahrami@Sun.COM  *    conv_ds_vd_t (ds_type == CONV_DS_VD)
5199273SAli.Bahrami@Sun.COM  *	This structure employs a NULL terminated array of Val_desc structs.
5209273SAli.Bahrami@Sun.COM  *	Each Val_desc supplies a mapping from a value in the range
5219273SAli.Bahrami@Sun.COM  *	(ds_baseval <= value <= ds_topval). The values described need not
5229273SAli.Bahrami@Sun.COM  *	be consecutive, and can be sparse. ds_baseval does not need to
5239273SAli.Bahrami@Sun.COM  *	correspond to the first item, and ds_topval need not correspond to
5249273SAli.Bahrami@Sun.COM  *	the final item.
5259273SAli.Bahrami@Sun.COM  *
5269273SAli.Bahrami@Sun.COM  *    conv_ds_vd2_t (ds_type == CONV_DS_VD2)
5279273SAli.Bahrami@Sun.COM  *	This structure employs a NULL terminated array of Val_desc2 structs,
5289273SAli.Bahrami@Sun.COM  *	rather than Val_desc, adding the ability to specify OSABI and machine
5299273SAli.Bahrami@Sun.COM  *	as part of the value/string mapping. It is otherwise the same thing
5309273SAli.Bahrami@Sun.COM  *	as CONV_DS_VD.
5319273SAli.Bahrami@Sun.COM  */
5329273SAli.Bahrami@Sun.COM typedef enum {
5339273SAli.Bahrami@Sun.COM 	CONV_DS_MSGARR = 0,		/* Array of Msg */
5349273SAli.Bahrami@Sun.COM 	CONV_DS_VD = 1,			/* Null terminated array of Val_desc */
5359273SAli.Bahrami@Sun.COM 	CONV_DS_VD2 = 2,		/* Null terminated array of Val_desc2 */
5369273SAli.Bahrami@Sun.COM } conv_ds_type_t;
5379273SAli.Bahrami@Sun.COM 
5389273SAli.Bahrami@Sun.COM #define	CONV_DS_COMMON_FIELDS \
5399273SAli.Bahrami@Sun.COM 	conv_ds_type_t	ds_type;   	/* Type of data structure used */ \
5409273SAli.Bahrami@Sun.COM 	uint32_t	ds_baseval;	/* Value of first item */	\
5419273SAli.Bahrami@Sun.COM 	uint32_t	ds_topval	/* Value of last item */
5429273SAli.Bahrami@Sun.COM 
5439273SAli.Bahrami@Sun.COM typedef struct {		/* Virtual base type --- do not instantiate */
5449273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5459273SAli.Bahrami@Sun.COM } conv_ds_t;
5469273SAli.Bahrami@Sun.COM typedef struct {
5479273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5489273SAli.Bahrami@Sun.COM 	const Msg		*ds_msg;
5499273SAli.Bahrami@Sun.COM } conv_ds_msg_t;
5509273SAli.Bahrami@Sun.COM typedef struct {
5519273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5529273SAli.Bahrami@Sun.COM 	const Val_desc		*ds_vd;
5539273SAli.Bahrami@Sun.COM } conv_ds_vd_t;
5549273SAli.Bahrami@Sun.COM typedef struct {
5559273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5569273SAli.Bahrami@Sun.COM 	const Val_desc2		*ds_vd2;
5579273SAli.Bahrami@Sun.COM } conv_ds_vd2_t;
5581618Srie 
5591618Srie /*
5609273SAli.Bahrami@Sun.COM  * The initialization of conv_ds_msg_t can be completely derived from
5619273SAli.Bahrami@Sun.COM  * its base value and the array of Msg codes. CONV_DS_MSG_INIT() is used
5629273SAli.Bahrami@Sun.COM  * to do that.
5639273SAli.Bahrami@Sun.COM  */
5649273SAli.Bahrami@Sun.COM #define	CONV_DS_MSG_INIT(_baseval, _arr) \
5659273SAli.Bahrami@Sun.COM 	CONV_DS_MSGARR, _baseval, \
5669273SAli.Bahrami@Sun.COM 	_baseval + (sizeof (_arr) / sizeof (_arr[0])) - 1, _arr
5679273SAli.Bahrami@Sun.COM 
5689273SAli.Bahrami@Sun.COM /*
5699273SAli.Bahrami@Sun.COM  * Null terminated arrays of pointers to conv_ds_XXX_t structs are processed
5709273SAli.Bahrami@Sun.COM  * by conv_map_ds() to convert ELF constants to their symbolic names, and by
5719273SAli.Bahrami@Sun.COM  * conv_iter_ds() to iterate over all the available value/name combinations.
5729273SAli.Bahrami@Sun.COM  *
5739273SAli.Bahrami@Sun.COM  * These pointers are formed by casting the address of the specific
5749273SAli.Bahrami@Sun.COM  * variant types (described above) to generic base type pointer.
5759273SAli.Bahrami@Sun.COM  * CONV_DS_ADDR() is a convenience macro to take the address of
5769273SAli.Bahrami@Sun.COM  * one of these variants and turn it into a generic pointer.
5779273SAli.Bahrami@Sun.COM  */
5789273SAli.Bahrami@Sun.COM #define	CONV_DS_ADDR(_item) ((conv_ds_t *)&(_item))
5799273SAli.Bahrami@Sun.COM 
5809273SAli.Bahrami@Sun.COM /*
5819273SAli.Bahrami@Sun.COM  * Type used by libconv to represent osabi values passed to iteration
5829273SAli.Bahrami@Sun.COM  * functions. The type in the ELF header is uchar_t. However, every possible
5839273SAli.Bahrami@Sun.COM  * value 0-255 has a valid meaning, leaving us no extra value to assign
5849273SAli.Bahrami@Sun.COM  * to mean "ALL". Using Half for osabi leaves us the top byte to use for
5859273SAli.Bahrami@Sun.COM  * out of bound values.
5869273SAli.Bahrami@Sun.COM  *
5879273SAli.Bahrami@Sun.COM  * Non-iteration functions, and any code that does not need to use
5889273SAli.Bahrami@Sun.COM  * CONV_OSABI_ALL, should use uchar_t for osabi.
5899273SAli.Bahrami@Sun.COM  */
5909273SAli.Bahrami@Sun.COM typedef Half conv_iter_osabi_t;
5919273SAli.Bahrami@Sun.COM 
5929273SAli.Bahrami@Sun.COM /*
5939273SAli.Bahrami@Sun.COM  * Many of the iteration functions accept an osabi or mach argument,
5949273SAli.Bahrami@Sun.COM  * used to specify the type of object being processed. The following
5959273SAli.Bahrami@Sun.COM  * values can be used to specify a wildcard that matches any item. Their
5969273SAli.Bahrami@Sun.COM  * values are carefully chosen to ensure that they cannot be interpreted
5979273SAli.Bahrami@Sun.COM  * as an otherwise valid osabi or machine.
5989273SAli.Bahrami@Sun.COM  */
5999273SAli.Bahrami@Sun.COM #define	CONV_OSABI_ALL	1024	/* Larger than can be represented by uchar_t */
6009273SAli.Bahrami@Sun.COM #define	CONV_MACH_ALL	EM_NUM	/* Never a valid machine type */
6019273SAli.Bahrami@Sun.COM 
6029273SAli.Bahrami@Sun.COM /*
6039273SAli.Bahrami@Sun.COM  * We compare Val_Desc2 descriptors with a specified osabi and machine
6049273SAli.Bahrami@Sun.COM  * to determine whether to use it or not. This macro encapsulates that logic.
6059273SAli.Bahrami@Sun.COM  *
6069273SAli.Bahrami@Sun.COM  * We consider an osabi to match when any of the following things hold:
6079273SAli.Bahrami@Sun.COM  *
6089273SAli.Bahrami@Sun.COM  * -	The descriptor osabi is ELFOSABI_NONE.
6099273SAli.Bahrami@Sun.COM  * -	The supplied osabi and the descriptor osabi match
6109273SAli.Bahrami@Sun.COM  * -	The supplied osabi is ELFOSABI_NONE, and the descriptor osabi is
6119273SAli.Bahrami@Sun.COM  *	ELFOSABI_SOLARIS. Many operating systems, Solaris included,
6129273SAli.Bahrami@Sun.COM  *	produce or have produced ELFOSABI_NONE native objects, if only
6139273SAli.Bahrami@Sun.COM  *	because OSABI ranges are not an original ELF feature. We
6149273SAli.Bahrami@Sun.COM  *	give our own objects the home field advantage.
6159273SAli.Bahrami@Sun.COM  * -	Iteration Only: An osabi value of CONV_OSABI_ALL is specified.
6169273SAli.Bahrami@Sun.COM  *
6179273SAli.Bahrami@Sun.COM  * We consider a machine to match when any of the following things hold:
6189273SAli.Bahrami@Sun.COM  *
6199273SAli.Bahrami@Sun.COM  * -	The descriptor mach is EM_NONE.
6209273SAli.Bahrami@Sun.COM  * -	The supplied mach and the descriptor mach match
6219273SAli.Bahrami@Sun.COM  * -	Iteration Only: A mach value of CONV_MACH_ALL is specified.
6229273SAli.Bahrami@Sun.COM  *
6239273SAli.Bahrami@Sun.COM  * The special extra _ALL case for iteration is handled by defining a separate
6249273SAli.Bahrami@Sun.COM  * macro with the extra CONV_xxx_ALL tests.
6259273SAli.Bahrami@Sun.COM  */
6269273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP_OSABI(_osabi, _vdp) \
6279273SAli.Bahrami@Sun.COM 	((_vdp->v_osabi != ELFOSABI_NONE) && (_vdp->v_osabi != osabi) && \
6289273SAli.Bahrami@Sun.COM 	((_osabi != ELFOSABI_NONE) || (_vdp->v_osabi != ELFOSABI_SOLARIS)))
6299273SAli.Bahrami@Sun.COM 
6309273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP_MACH(_mach, _vdp) \
6319273SAli.Bahrami@Sun.COM 	((_vdp->v_mach != EM_NONE) && (_vdp->v_mach != _mach))
6329273SAli.Bahrami@Sun.COM 
6339273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP(_osabi, _mach, _vdp) \
6349273SAli.Bahrami@Sun.COM 	(CONV_VD2_SKIP_OSABI(_osabi, _vdp) || CONV_VD2_SKIP_MACH(_mach, _vdp))
6359273SAli.Bahrami@Sun.COM 
6369273SAli.Bahrami@Sun.COM #define	CONV_ITER_VD2_SKIP(_osabi, _mach, _vdp)			      \
6379273SAli.Bahrami@Sun.COM 	((CONV_VD2_SKIP_OSABI(_osabi, _vdp) && (_osabi != CONV_OSABI_ALL)) || \
6389273SAli.Bahrami@Sun.COM 	(CONV_VD2_SKIP_MACH(_mach, _vdp) && (_mach != CONV_MACH_ALL)))
6399273SAli.Bahrami@Sun.COM 
6409273SAli.Bahrami@Sun.COM 
6419273SAli.Bahrami@Sun.COM /*
6429273SAli.Bahrami@Sun.COM  * Possible return values from iteration functions.
6439273SAli.Bahrami@Sun.COM  */
6449273SAli.Bahrami@Sun.COM typedef enum {
6459273SAli.Bahrami@Sun.COM 	CONV_ITER_DONE,		/* Stop: No more iterations are desired */
6469273SAli.Bahrami@Sun.COM 	CONV_ITER_CONT		/* Continue with following iterations */
6479273SAli.Bahrami@Sun.COM } conv_iter_ret_t;
6489273SAli.Bahrami@Sun.COM 
6499273SAli.Bahrami@Sun.COM /*
6509273SAli.Bahrami@Sun.COM  * Prototype for caller supplied callback function to iteration functions.
6519273SAli.Bahrami@Sun.COM  */
6529273SAli.Bahrami@Sun.COM typedef conv_iter_ret_t (* conv_iter_cb_t)(const char *str,
6539273SAli.Bahrami@Sun.COM     Conv_elfvalue_t value, void *uvalue);
6549273SAli.Bahrami@Sun.COM 
6559273SAli.Bahrami@Sun.COM /*
6569273SAli.Bahrami@Sun.COM  * User value block employed by conv_iter_strtol()
6571618Srie  */
6581618Srie typedef struct {
6599273SAli.Bahrami@Sun.COM 	const char	*csl_str;	/* String to search for */
6609273SAli.Bahrami@Sun.COM 	size_t		csl_strlen;	/* # chars in csl_str to examine */
6619273SAli.Bahrami@Sun.COM 	int		csl_found;	/* Init to 0, set to 1 if item found */
6629273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	csl_value;	/* If csl_found, resulting value */
6639273SAli.Bahrami@Sun.COM } conv_strtol_uvalue_t;
6641618Srie 
6651618Srie /*
6662352Sab196087  * conv_expn_field() is willing to supply default strings for the
6672352Sab196087  * prefix, separator, and suffix arguments, if they are passed as NULL.
6682352Sab196087  * The caller needs to know how much room to allow for these items.
6692352Sab196087  * These values supply those sizes.
6702352Sab196087  */
6712352Sab196087 #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
6722352Sab196087 #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
6732352Sab196087 #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
6742352Sab196087 
6752352Sab196087 /*
6762352Sab196087  * conv_expn_field() requires a large number of inputs, many of which
6772352Sab196087  * can be NULL to accept default behavior. An argument of the following
6782352Sab196087  * type is used to supply them.
6792352Sab196087  */
6802352Sab196087 typedef struct {
6812352Sab196087 	char *buf;		/* Buffer to receive generated string */
6822352Sab196087 	size_t bufsize;		/* sizeof(buf) */
6832352Sab196087 	const char **lead_str;	/* NULL, or array of pointers to strings to */
6842352Sab196087 				/*	be output at the head of the list. */
6852352Sab196087 				/*	Last entry must be NULL. */
6862352Sab196087 	Xword oflags;		/* Bits for which output strings are desired */
6872352Sab196087 	Xword rflags;		/* Bits for which a numeric value should be */
6882352Sab196087 				/*	output if vdp does not provide str. */
6892352Sab196087 				/*	Must be a proper subset of oflags */
6902352Sab196087 	const char *prefix;	/* NULL, or string to prefix output with */
6912352Sab196087 				/*	If NULL, "[ " is used. */
6922352Sab196087 	const char *sep;	/* NULL, or string to separate output items */
6932352Sab196087 				/*	with. If NULL, " " is used. */
6942352Sab196087 	const char *suffix;	/* NULL, or string to suffix output with */
6952352Sab196087 				/*	If NULL, " ]" is used. */
6962352Sab196087 } CONV_EXPN_FIELD_ARG;
6972352Sab196087 
6986635Sab196087 /*
6996635Sab196087  * Callback function for conv_str_to_c_literal(). A user supplied function
7006635Sab196087  * of this type is called by conv_str_to_c_literal() in order to dispatch
7016635Sab196087  * the translated output characters.
7026635Sab196087  *
7036635Sab196087  *	buf - Pointer to output text
7046635Sab196087  *	n - # of characters to output
7056635Sab196087  *	uvalue - User value argument to conv_str_to_c_literal(),
7066635Sab196087  *		passed through without interpretation.
7076635Sab196087  */
7086635Sab196087 typedef	void		Conv_str_to_c_literal_func_t(const void *ptr,
7096635Sab196087 			    size_t size, void *uvalue);
7106635Sab196087 
7112352Sab196087 /*
7129273SAli.Bahrami@Sun.COM  * Generic miscellaneous interfaces
7130Sstevel@tonic-gate  */
7142647Srie extern	uchar_t		conv_check_native(char **, char **);
7159273SAli.Bahrami@Sun.COM extern	const char	*conv_lddstub(int);
7169406SAli.Bahrami@Sun.COM extern	int		conv_strproc_isspace(int);
7179406SAli.Bahrami@Sun.COM extern	char		*conv_strproc_trim(char *);
7189406SAli.Bahrami@Sun.COM extern	Boolean		conv_strproc_extract_value(char *, size_t, int,
7199406SAli.Bahrami@Sun.COM 			    const char **);
7209406SAli.Bahrami@Sun.COM extern	int		conv_sys_eclass(void);
7219273SAli.Bahrami@Sun.COM 
7229273SAli.Bahrami@Sun.COM /*
7239273SAli.Bahrami@Sun.COM  * Generic core formatting and iteration functionality
7249273SAli.Bahrami@Sun.COM  */
7259273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_ds(conv_iter_osabi_t, Half,
7269273SAli.Bahrami@Sun.COM 			    const conv_ds_t **, conv_iter_cb_t, void *,
7279273SAli.Bahrami@Sun.COM 			    const char *);
7289273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_ds_msg(const conv_ds_msg_t *,
7299273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *, const char *);
7309273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_vd(const Val_desc *, conv_iter_cb_t,
7319273SAli.Bahrami@Sun.COM 			    void *, const char *);
7329273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_vd2(conv_iter_osabi_t, Half,
7339273SAli.Bahrami@Sun.COM 			    const Val_desc2 *, conv_iter_cb_t, void *,
7349273SAli.Bahrami@Sun.COM 			    const char *);
7359273SAli.Bahrami@Sun.COM extern	int		conv_iter_strtol_init(const char *,
7369273SAli.Bahrami@Sun.COM 			    conv_strtol_uvalue_t *);
7379273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_strtol(const char *, Conv_elfvalue_t, void *);
7389273SAli.Bahrami@Sun.COM extern	const char	*_conv_map_ds(uchar_t, Half, Conv_elfvalue_t,
7399273SAli.Bahrami@Sun.COM 			    const conv_ds_t **, Conv_fmt_flags_t,
7409273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *, const char *);
7419273SAli.Bahrami@Sun.COM 
7429273SAli.Bahrami@Sun.COM 
7439273SAli.Bahrami@Sun.COM /*
7449273SAli.Bahrami@Sun.COM  * Generic formatting interfaces.
7459273SAli.Bahrami@Sun.COM  */
7469273SAli.Bahrami@Sun.COM extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
7479273SAli.Bahrami@Sun.COM extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
7484734Sab196087 extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
7494734Sab196087 extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
7501618Srie extern	const char	*conv_config_upm(const char *, const char *,
7511618Srie 			    const char *, size_t);
7526635Sab196087 extern	const char	*conv_cnote_auxv_af(Word, Conv_fmt_flags_t,
7536635Sab196087 			    Conv_cnote_auxv_af_buf_t *);
7546635Sab196087 extern	const char	*conv_cnote_auxv_type(Word, Conv_fmt_flags_t,
7556635Sab196087 			    Conv_inv_buf_t *);
7566635Sab196087 extern	const char	*conv_cnote_cc_content(Lword, Conv_fmt_flags_t,
7576635Sab196087 			    Conv_cnote_cc_content_buf_t *);
7586635Sab196087 extern	const char	*conv_cnote_errno(int, Conv_fmt_flags_t,
7596635Sab196087 			    Conv_inv_buf_t *);
7606635Sab196087 extern	const char	*conv_cnote_fault(Word, Conv_fmt_flags_t,
7616635Sab196087 			    Conv_inv_buf_t *);
7626635Sab196087 extern	const char	*conv_cnote_fltset(uint32_t *, int,
7636635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *);
7646635Sab196087 extern	const char	*conv_cnote_old_pr_flags(int, Conv_fmt_flags_t,
7656635Sab196087 			    Conv_cnote_old_pr_flags_buf_t *);
7666635Sab196087 extern	const char	*conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t,
7676635Sab196087 			    Conv_inv_buf_t *);
7686635Sab196087 extern	const char	*conv_cnote_pr_flags(int, Conv_fmt_flags_t,
7696635Sab196087 			    Conv_cnote_pr_flags_buf_t *);
7706635Sab196087 extern	const char	*conv_cnote_proc_flag(int, Conv_fmt_flags_t,
7716635Sab196087 			    Conv_cnote_proc_flag_buf_t *);
7726635Sab196087 extern	const char	*conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t,
7736635Sab196087 			    Conv_inv_buf_t *inv_buf);
7746635Sab196087 extern	const char	*conv_cnote_pr_stype(Word, Conv_fmt_flags_t,
7756635Sab196087 			    Conv_inv_buf_t *);
7766635Sab196087 extern	const char	*conv_cnote_pr_what(short, short, Conv_fmt_flags_t,
7776635Sab196087 			    Conv_inv_buf_t *);
7786635Sab196087 extern	const char	*conv_cnote_pr_why(short, Conv_fmt_flags_t,
7796635Sab196087 			    Conv_inv_buf_t *);
7806635Sab196087 extern	const char	*conv_cnote_priv(int, Conv_fmt_flags_t,
7816635Sab196087 			    Conv_inv_buf_t *);
7826635Sab196087 extern	const char	*conv_cnote_psetid(int, Conv_fmt_flags_t,
7836635Sab196087 			    Conv_inv_buf_t *);
7846635Sab196087 extern	const char	*conv_cnote_sa_flags(int, Conv_fmt_flags_t,
7856635Sab196087 			    Conv_cnote_sa_flags_buf_t *);
7866635Sab196087 extern	const char	*conv_cnote_signal(Word, Conv_fmt_flags_t,
7876635Sab196087 			    Conv_inv_buf_t *);
7886635Sab196087 extern	const char	*conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t,
7896635Sab196087 			    Conv_inv_buf_t *);
7906635Sab196087 extern	const char	*conv_cnote_sigset(uint32_t *, int,
7916635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *);
7926635Sab196087 extern	const char	*conv_cnote_ss_flags(int, Conv_fmt_flags_t,
7936635Sab196087 			    Conv_cnote_ss_flags_buf_t *);
7946635Sab196087 extern	const char	*conv_cnote_syscall(Word, Conv_fmt_flags_t,
7956635Sab196087 			    Conv_inv_buf_t *);
7966635Sab196087 extern	const char	*conv_cnote_sysset(uint32_t *, int,
7976635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
7986635Sab196087 extern	const char	*conv_cnote_type(Word, Conv_fmt_flags_t,
7996635Sab196087 			    Conv_inv_buf_t *);
8004734Sab196087 extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
8011618Srie extern	const char	*conv_demangle_name(const char *);
8025088Sab196087 extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
8035088Sab196087 			    Conv_dl_flag_buf_t *);
8044734Sab196087 extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
8059085SAli.Bahrami@Sun.COM extern	const char	*conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t,
8069085SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8074734Sab196087 extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
8089085SAli.Bahrami@Sun.COM extern	const char	*conv_dwarf_regname(Half, Word, Conv_fmt_flags_t,
8099085SAli.Bahrami@Sun.COM 			    int *, Conv_inv_buf_t *);
8109273SAli.Bahrami@Sun.COM extern	const char	*conv_ehdr_abivers(uchar_t, Word, Conv_fmt_flags_t,
8115088Sab196087 			    Conv_inv_buf_t *);
8125088Sab196087 extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
8135088Sab196087 			    Conv_inv_buf_t *);
8145088Sab196087 extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
8155088Sab196087 			    Conv_inv_buf_t *);
8165088Sab196087 extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
8175088Sab196087 			    Conv_ehdr_flags_buf_t *);
8185088Sab196087 extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
8195088Sab196087 			    Conv_inv_buf_t *);
8205088Sab196087 extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
8215088Sab196087 			    Conv_inv_buf_t *);
8229273SAli.Bahrami@Sun.COM extern	const char	*conv_ehdr_type(uchar_t, Half, Conv_fmt_flags_t,
8235088Sab196087 			    Conv_inv_buf_t *);
8245088Sab196087 extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
8255088Sab196087 			    Conv_inv_buf_t *);
8269273SAli.Bahrami@Sun.COM extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
8279273SAli.Bahrami@Sun.COM extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
8289273SAli.Bahrami@Sun.COM extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
8299273SAli.Bahrami@Sun.COM extern	Isa_desc	*conv_isalist(void);
8309273SAli.Bahrami@Sun.COM extern	const char	*conv_phdr_flags(uchar_t, Word, Conv_fmt_flags_t,
8315088Sab196087 			    Conv_phdr_flags_buf_t *);
8329273SAli.Bahrami@Sun.COM extern	const char	*conv_phdr_type(uchar_t, Half, Word, Conv_fmt_flags_t,
8335088Sab196087 			    Conv_inv_buf_t *);
8346206Sab196087 extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *,
8356206Sab196087 			    Half mach);
8365088Sab196087 extern	const char	*conv_reloc_type(Half, Word, Conv_fmt_flags_t,
8375088Sab196087 			    Conv_inv_buf_t *);
8385088Sab196087 extern	const char	*conv_reloc_type_static(Half, Word, Conv_fmt_flags_t);
8395088Sab196087 extern	const char	*conv_reloc_386_type(Word, Conv_fmt_flags_t,
8405088Sab196087 			    Conv_inv_buf_t *);
8415088Sab196087 extern	const char	*conv_reloc_amd64_type(Word, Conv_fmt_flags_t,
8425088Sab196087 			    Conv_inv_buf_t *);
8435088Sab196087 extern	const char	*conv_reloc_SPARC_type(Word, Conv_fmt_flags_t,
8445088Sab196087 			    Conv_inv_buf_t *);
8459273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_type(uchar_t, Half, Word, Conv_fmt_flags_t,
8465088Sab196087 			    Conv_inv_buf_t *);
8479273SAli.Bahrami@Sun.COM extern	const char	*conv_seg_flags(Half, Conv_seg_flags_buf_t *);
8489273SAli.Bahrami@Sun.COM extern	void		conv_str_to_c_literal(const char *buf, size_t n,
8499273SAli.Bahrami@Sun.COM 			    Conv_str_to_c_literal_func_t *cb_func,
8509273SAli.Bahrami@Sun.COM 			    void *uvalue);
8515088Sab196087 extern	const char	*conv_sym_info_bind(uchar_t, Conv_fmt_flags_t,
8525088Sab196087 			    Conv_inv_buf_t *);
8535088Sab196087 extern	const char	*conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t,
8544734Sab196087 			    Conv_inv_buf_t *);
8559273SAli.Bahrami@Sun.COM extern	const char	*conv_sym_shndx(uchar_t, Half, Half, Conv_fmt_flags_t,
8569273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8574734Sab196087 extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
8585088Sab196087 extern	const char	*conv_sym_other_vis(uchar_t, Conv_fmt_flags_t,
8595088Sab196087 			    Conv_inv_buf_t *);
8609273SAli.Bahrami@Sun.COM extern	const char	*conv_syminfo_boundto(Half, Conv_fmt_flags_t,
8619273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8629273SAli.Bahrami@Sun.COM extern	const char	*conv_syminfo_flags(Half, Conv_fmt_flags_t,
8639273SAli.Bahrami@Sun.COM 			    Conv_syminfo_flags_buf_t *);
8649577SRod.Evans@Sun.COM extern	const char	*conv_time(struct timeval *, struct timeval *,
8659577SRod.Evans@Sun.COM 			    Conv_time_buf_t *);
8669273SAli.Bahrami@Sun.COM extern	Uts_desc	*conv_uts(void);
8679273SAli.Bahrami@Sun.COM extern	const char	*conv_ver_flags(Half, Conv_fmt_flags_t,
8689273SAli.Bahrami@Sun.COM 			    Conv_ver_flags_buf_t *);
8699273SAli.Bahrami@Sun.COM extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
8709273SAli.Bahrami@Sun.COM 
8719273SAli.Bahrami@Sun.COM 
8729273SAli.Bahrami@Sun.COM /*
8739273SAli.Bahrami@Sun.COM  * Generic iteration interfaces.
8749273SAli.Bahrami@Sun.COM  */
8759273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_tags(Conv_fmt_flags_t, conv_iter_cb_t,
8769273SAli.Bahrami@Sun.COM 			    void *);
8779273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_val_hw1(Half, Conv_fmt_flags_t,
8789273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
8799273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t,
8809273SAli.Bahrami@Sun.COM 			    void *);
8819273SAli.Bahrami@Sun.COM 
8829273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t,
8839273SAli.Bahrami@Sun.COM 			    void *);
8849273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_flag(Conv_fmt_flags_t, conv_iter_cb_t,
8859273SAli.Bahrami@Sun.COM 			    void *);
8869273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_flag1(Conv_fmt_flags_t, conv_iter_cb_t,
8879273SAli.Bahrami@Sun.COM 			    void *);
8889273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_posflag1(Conv_fmt_flags_t, conv_iter_cb_t,
8899273SAli.Bahrami@Sun.COM 			    void *);
8909273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_tag(conv_iter_osabi_t, Half,
8919273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
8929273SAli.Bahrami@Sun.COM 
8939273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_abivers(conv_iter_osabi_t,
8949273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
8959273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_class(Conv_fmt_flags_t, conv_iter_cb_t,
8969273SAli.Bahrami@Sun.COM 			    void *);
8979273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_data(Conv_fmt_flags_t, conv_iter_cb_t,
8989273SAli.Bahrami@Sun.COM 			    void *);
8999273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_eident(Conv_fmt_flags_t, conv_iter_cb_t,
9009273SAli.Bahrami@Sun.COM 			    void *);
9019273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_flags(Half, Conv_fmt_flags_t,
9029273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9039273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_mach(Conv_fmt_flags_t, conv_iter_cb_t,
9049273SAli.Bahrami@Sun.COM 			    void *);
9059273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_osabi(Conv_fmt_flags_t, conv_iter_cb_t,
9069273SAli.Bahrami@Sun.COM 			    void *);
9079273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
9089273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9099273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_vers(Conv_fmt_flags_t, conv_iter_cb_t,
9109273SAli.Bahrami@Sun.COM 			    void *);
9119273SAli.Bahrami@Sun.COM 
9129273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_phdr_flags(conv_iter_osabi_t,
9139273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9149273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_phdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
9159273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9169273SAli.Bahrami@Sun.COM 
9179273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_flags(conv_iter_osabi_t, Half,
9189273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9199273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_symtab(conv_iter_osabi_t,
9209273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9219273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_type(conv_iter_osabi_t, Half,
9229273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9239273SAli.Bahrami@Sun.COM 
9249273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_info_bind(Conv_fmt_flags_t,
9259273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9269273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_other_vis(Conv_fmt_flags_t,
9279273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9289273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_shndx(conv_iter_osabi_t, Half,
9299273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9309273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_info_type(Half, Conv_fmt_flags_t,
9319273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9329273SAli.Bahrami@Sun.COM 
9339273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_syminfo_boundto(Conv_fmt_flags_t,
9349273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9359273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_syminfo_flags(Conv_fmt_flags_t,
9369273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9379273SAli.Bahrami@Sun.COM 
9389273SAli.Bahrami@Sun.COM /*
9399273SAli.Bahrami@Sun.COM  * Define all class specific routines.
9409273SAli.Bahrami@Sun.COM  */
9419273SAli.Bahrami@Sun.COM #if	defined(_ELF64)
9429273SAli.Bahrami@Sun.COM #define	conv_cap_tag		conv64_cap_tag
9439273SAli.Bahrami@Sun.COM #define	conv_cap_val		conv64_cap_val
9449273SAli.Bahrami@Sun.COM #define	conv_cap_val_hw1	conv64_cap_val_hw1
9459273SAli.Bahrami@Sun.COM #define	conv_cap_val_sf1	conv64_cap_val_sf1
9469273SAli.Bahrami@Sun.COM #define	conv_dyn_feature1	conv64_dyn_feature1
9479273SAli.Bahrami@Sun.COM #define	conv_dyn_flag1		conv64_dyn_flag1
9489273SAli.Bahrami@Sun.COM #define	conv_dyn_flag		conv64_dyn_flag
9499273SAli.Bahrami@Sun.COM #define	conv_dyn_posflag1	conv64_dyn_posflag1
9509273SAli.Bahrami@Sun.COM #define	conv_dyn_tag		conv64_dyn_tag
9519273SAli.Bahrami@Sun.COM #define	_conv_expn_field	_conv64_expn_field
9529273SAli.Bahrami@Sun.COM #define	_conv_expn_field2	_conv64_expn_field2
9539273SAli.Bahrami@Sun.COM #define	conv_invalid_val	conv64_invalid_val
9549273SAli.Bahrami@Sun.COM #define	conv_sec_flags		conv64_sec_flags
9559273SAli.Bahrami@Sun.COM #define	conv_sec_linkinfo	conv64_sec_linkinfo
9569273SAli.Bahrami@Sun.COM #define	conv_sym_value		conv64_sym_value
9579273SAli.Bahrami@Sun.COM #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
9589273SAli.Bahrami@Sun.COM #else
9599273SAli.Bahrami@Sun.COM #define	conv_cap_tag		conv32_cap_tag
9609273SAli.Bahrami@Sun.COM #define	conv_cap_val		conv32_cap_val
9619273SAli.Bahrami@Sun.COM #define	conv_cap_val_hw1	conv32_cap_val_hw1
9629273SAli.Bahrami@Sun.COM #define	conv_cap_val_sf1	conv32_cap_val_sf1
9639273SAli.Bahrami@Sun.COM #define	conv_dyn_feature1	conv32_dyn_feature1
9649273SAli.Bahrami@Sun.COM #define	conv_dyn_flag1		conv32_dyn_flag1
9659273SAli.Bahrami@Sun.COM #define	conv_dyn_flag		conv32_dyn_flag
9669273SAli.Bahrami@Sun.COM #define	conv_dyn_posflag1	conv32_dyn_posflag1
9679273SAli.Bahrami@Sun.COM #define	conv_dyn_tag		conv32_dyn_tag
9689273SAli.Bahrami@Sun.COM #define	_conv_expn_field	_conv32_expn_field
9699273SAli.Bahrami@Sun.COM #define	_conv_expn_field2	_conv32_expn_field2
9709273SAli.Bahrami@Sun.COM #define	conv_invalid_val	conv32_invalid_val
9719273SAli.Bahrami@Sun.COM #define	conv_sec_flags		conv32_sec_flags
9729273SAli.Bahrami@Sun.COM #define	conv_sec_linkinfo	conv32_sec_linkinfo
9739273SAli.Bahrami@Sun.COM #define	conv_sym_value		conv32_sym_value
9749273SAli.Bahrami@Sun.COM #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
9759273SAli.Bahrami@Sun.COM #endif
9769273SAli.Bahrami@Sun.COM 
9779273SAli.Bahrami@Sun.COM /*
9789273SAli.Bahrami@Sun.COM  * ELFCLASS-specific core formatting functionality
9799273SAli.Bahrami@Sun.COM  */
9809273SAli.Bahrami@Sun.COM extern	int		_conv_expn_field(CONV_EXPN_FIELD_ARG *,
9819273SAli.Bahrami@Sun.COM 			    const Val_desc *, Conv_fmt_flags_t, const char *);
9829273SAli.Bahrami@Sun.COM extern	int		_conv_expn_field2(CONV_EXPN_FIELD_ARG *, uchar_t,
9839273SAli.Bahrami@Sun.COM 			    Half, const Val_desc2 *, Conv_fmt_flags_t,
9849273SAli.Bahrami@Sun.COM 			    const char *);
9859273SAli.Bahrami@Sun.COM extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
9869273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t);
9879273SAli.Bahrami@Sun.COM 
9889273SAli.Bahrami@Sun.COM /*
9899273SAli.Bahrami@Sun.COM  * ELFCLASS-specific formatting interfaces.
9909273SAli.Bahrami@Sun.COM  */
9919273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_tag(Xword, Conv_fmt_flags_t,
9929273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
9939273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *);
9949273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
9959273SAli.Bahrami@Sun.COM 			    Conv_cap_val_hw1_buf_t *);
9969273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
9979273SAli.Bahrami@Sun.COM 			    Conv_cap_val_sf1_buf_t *);
9989273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
9999273SAli.Bahrami@Sun.COM 			    Conv_dyn_flag1_buf_t *);
10009273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
10019273SAli.Bahrami@Sun.COM 			    Conv_dyn_flag_buf_t *);
10029273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
10039273SAli.Bahrami@Sun.COM 			    Conv_dyn_posflag1_buf_t *);
10049273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_tag(Xword, uchar_t, Half, Conv_fmt_flags_t,
10059273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
10069273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
10079273SAli.Bahrami@Sun.COM 			    Conv_dyn_feature1_buf_t *);
10089273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_flags(uchar_t osabi, Half mach, Xword,
10099273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, Conv_sec_flags_buf_t *);
10109273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
10114734Sab196087 extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
10125088Sab196087 extern	const char	*conv_sym_SPARC_value(Addr, Conv_fmt_flags_t,
10135088Sab196087 			    Conv_inv_buf_t *);
10149273SAli.Bahrami@Sun.COM 
10159273SAli.Bahrami@Sun.COM /*
10169273SAli.Bahrami@Sun.COM  * Define macros for _conv_XXX() routines that accept local_sgs_msg as the
10179273SAli.Bahrami@Sun.COM  * final argument. The macros hide that argument from the caller's view and
10189273SAli.Bahrami@Sun.COM  * supply the SGS message array for the file from which the macro is used
10199273SAli.Bahrami@Sun.COM  * in its place. This trick is used to allow these functions to access the
10209273SAli.Bahrami@Sun.COM  * message strings from any source file they are called from.
10219273SAli.Bahrami@Sun.COM  */
10229273SAli.Bahrami@Sun.COM #define	conv_expn_field(_arg, _vdp, _fmt_flags) \
10239273SAli.Bahrami@Sun.COM     _conv_expn_field(_arg, _vdp, _fmt_flags, MSG_SGS_LOCAL_ARRAY)
10249273SAli.Bahrami@Sun.COM 
10259273SAli.Bahrami@Sun.COM #define	conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags) \
10269273SAli.Bahrami@Sun.COM     _conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags, \
10279273SAli.Bahrami@Sun.COM     MSG_SGS_LOCAL_ARRAY)
10289273SAli.Bahrami@Sun.COM 
10299273SAli.Bahrami@Sun.COM #define	conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue) \
10309273SAli.Bahrami@Sun.COM     _conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10319273SAli.Bahrami@Sun.COM 
10329273SAli.Bahrami@Sun.COM #define	conv_iter_vd(_vdp, _func, _uvalue)	\
10339273SAli.Bahrami@Sun.COM     _conv_iter_vd(_vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10349273SAli.Bahrami@Sun.COM 
10359273SAli.Bahrami@Sun.COM #define	conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue)		\
10369273SAli.Bahrami@Sun.COM     _conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10379273SAli.Bahrami@Sun.COM 
10389273SAli.Bahrami@Sun.COM #define	conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf) \
10399273SAli.Bahrami@Sun.COM     _conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf, \
10409273SAli.Bahrami@Sun.COM     MSG_SGS_LOCAL_ARRAY)
10419273SAli.Bahrami@Sun.COM 
10420Sstevel@tonic-gate 
10430Sstevel@tonic-gate #ifdef	__cplusplus
10440Sstevel@tonic-gate }
10450Sstevel@tonic-gate #endif
10460Sstevel@tonic-gate 
10470Sstevel@tonic-gate #endif /* _CONV_H */
1048