xref: /onnv-gate/usr/src/cmd/sgs/include/conv.h (revision 12029:3202400f09a4)
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  *
2611734SAli.Bahrami@Sun.COM  * Copyright 2010 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 /*
13011827SRod.Evans@Sun.COM  * conv_cap_val_hw/sf()
1314734Sab196087  *
13211827SRod.Evans@Sun.COM  * These sizes are based on the maximum number of capabilities that exist.
13311827SRod.Evans@Sun.COM  * 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 
14111827SRod.Evans@Sun.COM #define	CONV_CAP_VAL_HW2_BUFSIZE	CONV_INV_BUFSIZE	/* for now */
14211827SRod.Evans@Sun.COM typedef union {
14311827SRod.Evans@Sun.COM 	Conv_inv_buf_t			inv_buf;
14411827SRod.Evans@Sun.COM 	char				buf[CONV_CAP_VAL_HW2_BUFSIZE];
14511827SRod.Evans@Sun.COM } Conv_cap_val_hw2_buf_t;
14611827SRod.Evans@Sun.COM 
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;
15811827SRod.Evans@Sun.COM 	Conv_cap_val_hw2_buf_t		cap_val_hw2_buf;
1599273SAli.Bahrami@Sun.COM } Conv_cap_val_buf_t;
1604734Sab196087 
1614734Sab196087 /* conv_config_feat() */
1629273SAli.Bahrami@Sun.COM #define	CONV_CONFIG_FEAT_BUFSIZE	204
1634734Sab196087 typedef union {
1649273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1659273SAli.Bahrami@Sun.COM 	char				buf[CONV_CONFIG_FEAT_BUFSIZE];
1669273SAli.Bahrami@Sun.COM } Conv_config_feat_buf_t;
1674734Sab196087 
1684734Sab196087 /* conv_config_obj() */
1699273SAli.Bahrami@Sun.COM #define	CONV_CONFIG_OBJ_BUFSIZE		164
1704734Sab196087 typedef union {
1719273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1729273SAli.Bahrami@Sun.COM 	char				buf[CONV_CONFIG_OBJ_BUFSIZE];
1739273SAli.Bahrami@Sun.COM } Conv_config_obj_buf_t;
1744734Sab196087 
1754734Sab196087 /* conv_dl_mode() */
1769273SAli.Bahrami@Sun.COM #define	CONV_DL_MODE_BUFSIZE		132
1774734Sab196087 typedef union {
1789273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1799273SAli.Bahrami@Sun.COM 	char				buf[CONV_DL_MODE_BUFSIZE];
1809273SAli.Bahrami@Sun.COM } Conv_dl_mode_buf_t;
1814734Sab196087 
1824734Sab196087 /* conv_dl_flag() */
1839273SAli.Bahrami@Sun.COM #define	CONV_DL_FLAG_BUFSIZE		185
1844734Sab196087 typedef union {
1859273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1869273SAli.Bahrami@Sun.COM 	char				buf[CONV_DL_FLAG_BUFSIZE];
1879273SAli.Bahrami@Sun.COM } Conv_dl_flag_buf_t;
1884734Sab196087 
1894734Sab196087 /* conv_grphdl_flags() */
1909963SRod.Evans@Sun.COM #define	CONV_GRPHDL_FLAGS_BUFSIZE	78
1914734Sab196087 typedef union {
1929273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
1939273SAli.Bahrami@Sun.COM 	char				buf[CONV_GRPHDL_FLAGS_BUFSIZE];
1949273SAli.Bahrami@Sun.COM } Conv_grphdl_flags_buf_t;
1954734Sab196087 
1964734Sab196087 /* conv_grpdesc_flags() */
1979577SRod.Evans@Sun.COM #define	CONV_GRPDESC_FLAGS_BUFSIZE	91
1984734Sab196087 typedef union {
1999273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2009273SAli.Bahrami@Sun.COM 	char				buf[CONV_GRPDESC_FLAGS_BUFSIZE];
2019273SAli.Bahrami@Sun.COM } Conv_grpdesc_flags_buf_t;
2024734Sab196087 
2034734Sab196087 /* conv_seg_flags() */
20411734SAli.Bahrami@Sun.COM #define	CONV_SEG_FLAGS_BUFSIZE		241
2054734Sab196087 typedef union {
2069273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2079273SAli.Bahrami@Sun.COM 	char				buf[CONV_SEG_FLAGS_BUFSIZE];
2089273SAli.Bahrami@Sun.COM } Conv_seg_flags_buf_t;
2094734Sab196087 
2104734Sab196087 /* conv_dyn_posflag1() */
2119273SAli.Bahrami@Sun.COM #define	CONV_DYN_POSFLAG1_BUFSIZE	57
2124734Sab196087 typedef union {
2139273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2149273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_POSFLAG1_BUFSIZE];
2159273SAli.Bahrami@Sun.COM } Conv_dyn_posflag1_buf_t;
2164734Sab196087 
2174734Sab196087 /* conv_dyn_flag() */
2189273SAli.Bahrami@Sun.COM #define	CONV_DYN_FLAG_BUFSIZE		85
2194734Sab196087 typedef union {
2209273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2219273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FLAG_BUFSIZE];
2229273SAli.Bahrami@Sun.COM } Conv_dyn_flag_buf_t;
2234734Sab196087 
2244734Sab196087 /* conv_dyn_flag1() */
2259273SAli.Bahrami@Sun.COM #define	CONV_DYN_FLAG1_BUFSIZE		361
2264734Sab196087 typedef union {
2279273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2289273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FLAG1_BUFSIZE];
2299273SAli.Bahrami@Sun.COM } Conv_dyn_flag1_buf_t;
2304734Sab196087 
2314734Sab196087 /* conv_dyn_feature1() */
2329273SAli.Bahrami@Sun.COM #define	CONV_DYN_FEATURE1_BUFSIZE	54
2334734Sab196087 typedef union {
2349273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2359273SAli.Bahrami@Sun.COM 	char				buf[CONV_DYN_FEATURE1_BUFSIZE];
2369273SAli.Bahrami@Sun.COM } Conv_dyn_feature1_buf_t;
2374734Sab196087 
2384734Sab196087 /* conv_bnd_type() */
2399273SAli.Bahrami@Sun.COM #define	CONV_BND_TYPE_BUFSIZE		51
2404734Sab196087 typedef union {
2419273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2429273SAli.Bahrami@Sun.COM 	char				buf[CONV_BND_TYPE_BUFSIZE];
2439273SAli.Bahrami@Sun.COM } Conv_bnd_type_buf_t;
2444734Sab196087 
2454734Sab196087 /* conv_bnd_obj() */
2469273SAli.Bahrami@Sun.COM #define	CONV_BND_OBJ_BUFSIZE		60
2474734Sab196087 typedef union {
2489273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2499273SAli.Bahrami@Sun.COM 	char				buf[CONV_BND_OBJ_BUFSIZE];
2509273SAli.Bahrami@Sun.COM } Conv_bnd_obj_buf_t;
2514734Sab196087 
2524734Sab196087 /* conv_phdr_flags() */
2539273SAli.Bahrami@Sun.COM #define	CONV_PHDR_FLAGS_BUFSIZE		57
2544734Sab196087 typedef union {
2559577SRod.Evans@Sun.COM 	Conv_inv_buf_t			inv_buf;
2569577SRod.Evans@Sun.COM 	char				buf[CONV_PHDR_FLAGS_BUFSIZE];
2579273SAli.Bahrami@Sun.COM } Conv_phdr_flags_buf_t;
2584734Sab196087 
2594734Sab196087 /* conv_sec_flags() */
2609273SAli.Bahrami@Sun.COM #define	CONV_SEC_FLAGS_BUFSIZE		190
2614734Sab196087 typedef union {
2629273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2639273SAli.Bahrami@Sun.COM 	char				buf[CONV_SEC_FLAGS_BUFSIZE];
2649273SAli.Bahrami@Sun.COM } Conv_sec_flags_buf_t;
2654734Sab196087 
2664734Sab196087 /* conv_dwarf_ehe() */
2679273SAli.Bahrami@Sun.COM #define	CONV_DWARF_EHE_BUFSIZE		43
2684734Sab196087 typedef union {
2699273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2709273SAli.Bahrami@Sun.COM 	char				buf[CONV_DWARF_EHE_BUFSIZE];
2719273SAli.Bahrami@Sun.COM } Conv_dwarf_ehe_buf_t;
2724734Sab196087 
2735088Sab196087 /* conv_syminfo_flags() */
2749273SAli.Bahrami@Sun.COM #define	CONV_SYMINFO_FLAGS_BUFSIZE	193
2755088Sab196087 typedef union {
2769273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2779273SAli.Bahrami@Sun.COM 	char				buf[CONV_SYMINFO_FLAGS_BUFSIZE];
2789273SAli.Bahrami@Sun.COM } Conv_syminfo_flags_buf_t;
2795088Sab196087 
2806635Sab196087 /* conv_cnote_pr_flags() */
2819273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_PR_FLAGS_BUFSIZE	254
2826635Sab196087 typedef union {
2839273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2849273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
2859273SAli.Bahrami@Sun.COM } Conv_cnote_pr_flags_buf_t;
2866635Sab196087 
2876635Sab196087 /* conv_cnote_old_pr_flags() */
2889273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE	174
2896635Sab196087 typedef union {
2909273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2919273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
2929273SAli.Bahrami@Sun.COM } Conv_cnote_old_pr_flags_buf_t;
2936635Sab196087 
2946635Sab196087 /* conv_cnote_proc_flag() */
2959273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_PROC_FLAG_BUFSIZE	39
2966635Sab196087 typedef union {
2979273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
2989273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
2999273SAli.Bahrami@Sun.COM } Conv_cnote_proc_flag_buf_t;
3006635Sab196087 
3016635Sab196087 
3026635Sab196087 /* conv_cnote_sigset() */
3039273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SIGSET_BUFSIZE	639
3046635Sab196087 typedef union {
3059273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3069273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SIGSET_BUFSIZE];
3079273SAli.Bahrami@Sun.COM } Conv_cnote_sigset_buf_t;
3086635Sab196087 
3096635Sab196087 /* conv_cnote_fltset() */
3109273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_FLTSET_BUFSIZE	511
3116635Sab196087 typedef union {
3129273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3139273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_FLTSET_BUFSIZE];
3149273SAli.Bahrami@Sun.COM } Conv_cnote_fltset_buf_t;
3156635Sab196087 
3166635Sab196087 /* conv_cnote_sysset() */
31711798SRoger.Faulkner@Sun.COM #define	CONV_CNOTE_SYSSET_BUFSIZE	3195
3186635Sab196087 typedef union {
3199273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3209273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SYSSET_BUFSIZE];
3219273SAli.Bahrami@Sun.COM } Conv_cnote_sysset_buf_t;
3226635Sab196087 
3236635Sab196087 /* conv_cnote_sa_flags() */
3249273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SA_FLAGS_BUFSIZE	109
3256635Sab196087 typedef union {
3269273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3279273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
3289273SAli.Bahrami@Sun.COM } Conv_cnote_sa_flags_buf_t;
3296635Sab196087 
3306635Sab196087 /* conv_cnote_ss_flags() */
3319273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_SS_FLAGS_BUFSIZE	48
3326635Sab196087 typedef union {
3339273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3349273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
3359273SAli.Bahrami@Sun.COM } Conv_cnote_ss_flags_buf_t;
3366635Sab196087 
3376635Sab196087 /* conv_cnote_cc_content() */
3389273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_CC_CONTENT_BUFSIZE	97
3396635Sab196087 typedef union {
3409273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3419273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
3429273SAli.Bahrami@Sun.COM } Conv_cnote_cc_content_buf_t;
3436635Sab196087 
3446635Sab196087 /* conv_cnote_auxv_af() */
3459273SAli.Bahrami@Sun.COM #define	CONV_CNOTE_AUXV_AF_BUFSIZE	73
3466635Sab196087 typedef union {
3479273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3489273SAli.Bahrami@Sun.COM 	char				buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
3499273SAli.Bahrami@Sun.COM } Conv_cnote_auxv_af_buf_t;
3506635Sab196087 
3517682SAli.Bahrami@Sun.COM /* conv_ver_flags() */
3529273SAli.Bahrami@Sun.COM #define	CONV_VER_FLAGS_BUFSIZE		41
3537682SAli.Bahrami@Sun.COM typedef union {
3549273SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
3559273SAli.Bahrami@Sun.COM 	char				buf[CONV_VER_FLAGS_BUFSIZE];
3569273SAli.Bahrami@Sun.COM } Conv_ver_flags_buf_t;
3574734Sab196087 
35811734SAli.Bahrami@Sun.COM /* conv_ent_flags() */
35911734SAli.Bahrami@Sun.COM #define	CONV_ENT_FLAGS_BUFSIZE		69
36011734SAli.Bahrami@Sun.COM typedef union {
36111734SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
36211734SAli.Bahrami@Sun.COM 	char				buf[CONV_ENT_FLAGS_BUFSIZE];
36311734SAli.Bahrami@Sun.COM } Conv_ent_flags_buf_t;
36411734SAli.Bahrami@Sun.COM 
36511734SAli.Bahrami@Sun.COM /* conv_ent_files_flags() */
36611827SRod.Evans@Sun.COM #define	CONV_ENT_FILES_FLAGS_BUFSIZE	89
36711734SAli.Bahrami@Sun.COM typedef union {
36811734SAli.Bahrami@Sun.COM 	Conv_inv_buf_t			inv_buf;
36911734SAli.Bahrami@Sun.COM 	char				buf[CONV_ENT_FILES_FLAGS_BUFSIZE];
37011734SAli.Bahrami@Sun.COM } Conv_ent_files_flags_buf_t;
37111734SAli.Bahrami@Sun.COM 
3729577SRod.Evans@Sun.COM /*
3739577SRod.Evans@Sun.COM  * conv_time()
3749577SRod.Evans@Sun.COM  *
3759577SRod.Evans@Sun.COM  * This size is based on the maximum "hour.min.sec.fraction: " time that
3769577SRod.Evans@Sun.COM  * would be expected of ld().
3779577SRod.Evans@Sun.COM  */
3789577SRod.Evans@Sun.COM #define	CONV_TIME_BUFSIZE		18
3799577SRod.Evans@Sun.COM typedef union {
3809577SRod.Evans@Sun.COM 	char				buf[CONV_TIME_BUFSIZE];
3819577SRod.Evans@Sun.COM } Conv_time_buf_t;
3822850Srie 
3832850Srie /*
3845088Sab196087  * Many conversion routines accept a fmt_flags argument of this type
3855088Sab196087  * to allow the caller to modify the output. There are two parts to
3865088Sab196087  * this value:
3875088Sab196087  *
3885088Sab196087  *	(1) Format requests (decimal vs hex, etc...)
3895088Sab196087  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
3905088Sab196087  *		and retrieved by CONV_TYPE_FMT_ALT are integer
3915088Sab196087  *		values that specify that an alternate set of
3929273SAli.Bahrami@Sun.COM  *		strings should be used.
3935088Sab196087  *
3949273SAli.Bahrami@Sun.COM  * The fmt_flags value is designed such that a caller can always
3959273SAli.Bahrami@Sun.COM  * supply a 0 in order to receive default behavior.
3961618Srie  */
3975088Sab196087 typedef int Conv_fmt_flags_t;
3985088Sab196087 
3995088Sab196087 /*
4009273SAli.Bahrami@Sun.COM  * Type used to represent ELF constants within libconv. This relies on
4019273SAli.Bahrami@Sun.COM  * the fact that there are no ELF constants that need more than 32-bits,
4029273SAli.Bahrami@Sun.COM  * nor are there any signed values.
4039273SAli.Bahrami@Sun.COM  */
4049273SAli.Bahrami@Sun.COM typedef uint32_t Conv_elfvalue_t;
4059273SAli.Bahrami@Sun.COM 
4069273SAli.Bahrami@Sun.COM /*
4079273SAli.Bahrami@Sun.COM  * Most conversion routines are able to provide strings in one of
4089273SAli.Bahrami@Sun.COM  * several alternative styles. The bottom 8 bits of Conv_fmt_flags_t
4099273SAli.Bahrami@Sun.COM  * are used to specify which strings should be used for a given call
4109273SAli.Bahrami@Sun.COM  * to a conversion routine:
4119273SAli.Bahrami@Sun.COM  *
4129273SAli.Bahrami@Sun.COM  *   DEFAULT
4139273SAli.Bahrami@Sun.COM  *	The default string style used by a given conversion routine is
4149273SAli.Bahrami@Sun.COM  *	an independent choice made by that routine. Different routines
4159273SAli.Bahrami@Sun.COM  *	make different choices, based largely on historical usage and
4169273SAli.Bahrami@Sun.COM  *	the perceived common case. It may be an alias for one of the
4179273SAli.Bahrami@Sun.COM  *	specific styles listed below, or it may be unique.
4189273SAli.Bahrami@Sun.COM  *
4199273SAli.Bahrami@Sun.COM  *   DUMP
4209273SAli.Bahrami@Sun.COM  *	Style of strings used by dump(1).
4219273SAli.Bahrami@Sun.COM  *
4229273SAli.Bahrami@Sun.COM  *   FILE
4239273SAli.Bahrami@Sun.COM  *	Style of strings used by file(1).
4245088Sab196087  *
4259273SAli.Bahrami@Sun.COM  *   CRLE
4269273SAli.Bahrami@Sun.COM  *	Style of strings used by crle(1).
4279273SAli.Bahrami@Sun.COM  *
4289273SAli.Bahrami@Sun.COM  *   CF
4299273SAli.Bahrami@Sun.COM  *	Canonical Form: The string is exactly the same as the name
4309273SAli.Bahrami@Sun.COM  *	of the #define macro that defines it in the public header files.
4319273SAli.Bahrami@Sun.COM  *	(e.g. STB_LOCAL, not LOCL, LOCAL, LOC, or any other variation).
4329273SAli.Bahrami@Sun.COM  *
4339273SAli.Bahrami@Sun.COM  *   CFNP
4349273SAli.Bahrami@Sun.COM  *	No Prefix Canonical Form: The same strings supplied by CF,
4359273SAli.Bahrami@Sun.COM  *	but without their standard prefix. (e.g. LOCAL, instead of STT_LOCAL).
4369273SAli.Bahrami@Sun.COM  *
4379273SAli.Bahrami@Sun.COM  *   NF
4389273SAli.Bahrami@Sun.COM  *	Natural Form: The form of the strings that might typically be entered
4399273SAli.Bahrami@Sun.COM  *	via a keyboard by an interactive user. These are usually the strings
4409273SAli.Bahrami@Sun.COM  *	from CFNP, converted to lowercase, although in some cases they may
4419273SAli.Bahrami@Sun.COM  *	take some other "natural" form. In command completion applications,
4429273SAli.Bahrami@Sun.COM  *	lowercase strings appear less formal, and are easier on the eye.
4439273SAli.Bahrami@Sun.COM  *
4449273SAli.Bahrami@Sun.COM  * Every routine is required to have a default style. The others are optional,
4459273SAli.Bahrami@Sun.COM  * and may not be provided if not needed. If a given conversion routine does
4469273SAli.Bahrami@Sun.COM  * not support alternative strings for a given CONV_FMT_ALT type, it silently
4479273SAli.Bahrami@Sun.COM  * ignores the request and supplies the default set. This means that a utility
4489273SAli.Bahrami@Sun.COM  * like dump(1) is free to specify a style like DUMP to every conversion
4495088Sab196087  * routine. It will receive its special strings if there are any, and
4505088Sab196087  * the defaults otherwise.
4515088Sab196087  */
4525088Sab196087 #define	CONV_MASK_FMT_ALT		0xff
4535088Sab196087 #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
4545088Sab196087 
4555088Sab196087 #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
4569273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_DUMP	1	/* dump(1) */
4579273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_FILE	2	/* file(1) */
4589273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CRLE	3	/* crle(1) */
4599273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CF		4	/* Canonical Form */
4609273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_CFNP	5	/* No Prefix Canonical Form */
4619273SAli.Bahrami@Sun.COM #define	CONV_FMT_ALT_NF		6	/* Natural Form */
4625088Sab196087 
4635088Sab196087 /*
4645088Sab196087  * Flags that alter standard formatting for conversion routines.
4655088Sab196087  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
4665088Sab196087  */
4675088Sab196087 #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
4681976Sab196087 					/*    integer print as decimal */
4691976Sab196087 					/*    (default is hex) */
4705088Sab196087 #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
4711976Sab196087 					/*    a space after the number.  */
4725088Sab196087 #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
4735088Sab196087 					/*    prefix and suffix strings */
4741976Sab196087 
4759273SAli.Bahrami@Sun.COM /*
4769273SAli.Bahrami@Sun.COM  * A Val_desc structure is used to associate an ELF constant and
4779273SAli.Bahrami@Sun.COM  * the message code (Msg) for the string that corresponds to it.
4789273SAli.Bahrami@Sun.COM  *
4799273SAli.Bahrami@Sun.COM  * Val_desc2 adds v_osabi and v_mach fields to Val_desc, which allows
4809273SAli.Bahrami@Sun.COM  * for non-generic mappings that apply only to a specific OSABI/machine.
4819273SAli.Bahrami@Sun.COM  * Setting v_osabi to 0 (ELFOSABI_NONE) specifies that any OSABI matches.
4829273SAli.Bahrami@Sun.COM  * Similarly, setting v_mach to 0 (EM_MACH) matches any machine. Hence,
4839273SAli.Bahrami@Sun.COM  * setting v_osabi and v_mach to 0 in a Val_desc2 results in a generic item,
4849273SAli.Bahrami@Sun.COM  * and is equivalent to simply using a Val_desc.
4859273SAli.Bahrami@Sun.COM  *
4869273SAli.Bahrami@Sun.COM  * These structs are used in two different contexts:
4879273SAli.Bahrami@Sun.COM  *
4889273SAli.Bahrami@Sun.COM  * 1)	To expand bit-field data items, using conv_expn_field() to
4899273SAli.Bahrami@Sun.COM  *	process a NULL terminated array of Val_desc, or conv_expn_field2()
4909273SAli.Bahrami@Sun.COM  *	to process a null terminated array of Val_desc2.
4919273SAli.Bahrami@Sun.COM  *
4929273SAli.Bahrami@Sun.COM  * 2)	To represent sparse ranges of non-bitfield values, referenced via
4939273SAli.Bahrami@Sun.COM  *	conv_ds_vd_t or conv_ds_vd2_t descriptors, as described below.
4949273SAli.Bahrami@Sun.COM  */
4959273SAli.Bahrami@Sun.COM typedef struct {
4969273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	v_val;		/* expansion value */
4979273SAli.Bahrami@Sun.COM 	Msg		v_msg;		/* associated message string code */
4989273SAli.Bahrami@Sun.COM } Val_desc;
4999273SAli.Bahrami@Sun.COM typedef struct {
5009273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	v_val;		/* expansion value */
5019273SAli.Bahrami@Sun.COM 	uchar_t		v_osabi;	/* OSABI to which entry applies */
5029273SAli.Bahrami@Sun.COM 	Half		v_mach;		/* Machine to which entry applies */
5039273SAli.Bahrami@Sun.COM 	Msg		v_msg;		/* associated message string code */
5049273SAli.Bahrami@Sun.COM } Val_desc2;
5059273SAli.Bahrami@Sun.COM 
5069273SAli.Bahrami@Sun.COM /*
5079273SAli.Bahrami@Sun.COM  * The conv_ds_XXX_t structs are used to pull together the information used
5089273SAli.Bahrami@Sun.COM  * to map non-bitfield values to strings. They are a variant family, sharing
5099273SAli.Bahrami@Sun.COM  * the same initial fields, with a generic "header" definition that can be
5109273SAli.Bahrami@Sun.COM  * used to read those common fields and determine which subcase is being
5119273SAli.Bahrami@Sun.COM  * seen. We do this instead of using a single struct containing a type code
5129273SAli.Bahrami@Sun.COM  * and a union in order to allow for static compile-time initialization.
5139273SAli.Bahrami@Sun.COM  *
5149273SAli.Bahrami@Sun.COM  * conv_ds_t is the base type, containing the initial fields common to all
5159273SAli.Bahrami@Sun.COM  * the variants. Variables of type conv_ds_t are never instantiated. This
5169273SAli.Bahrami@Sun.COM  * type exists only to provide a common pointer type that can reference
5179273SAli.Bahrami@Sun.COM  * any of the variants safely. In C++, it would be a virtual base class.
5189273SAli.Bahrami@Sun.COM  * The fields common to all the variants are:
5199273SAli.Bahrami@Sun.COM  *
5209273SAli.Bahrami@Sun.COM  *	ds_type: Identifies the variant
5219273SAli.Bahrami@Sun.COM  *	ds_baseval/ds_topval: The lower and upper bound of the range
5229273SAli.Bahrami@Sun.COM  *		of values represented by this conv_ds_XXX_t descriptor.
5239273SAli.Bahrami@Sun.COM  *
5249273SAli.Bahrami@Sun.COM  * There are three different variants:
5259273SAli.Bahrami@Sun.COM  *    conv_ds_msg_t (ds_type == CONV_DS_MSGARR)
5269273SAli.Bahrami@Sun.COM  *	This structure references an array of message codes corresponding
5279273SAli.Bahrami@Sun.COM  *	to consecutive ELF values. The first item in the array is the Msg
5289273SAli.Bahrami@Sun.COM  *	code for the value given by ds_baseval. Consecutive strings follow
5299273SAli.Bahrami@Sun.COM  *	in consecutive order. The final item corresponds to the value given
5309273SAli.Bahrami@Sun.COM  *	by ds_topval. Zero (0) Msg values can be used to represent missing
5319273SAli.Bahrami@Sun.COM  *	values. Entries with a 0 are quietly ignored.
5329273SAli.Bahrami@Sun.COM  *
5339273SAli.Bahrami@Sun.COM  *    conv_ds_vd_t (ds_type == CONV_DS_VD)
5349273SAli.Bahrami@Sun.COM  *	This structure employs a NULL terminated array of Val_desc structs.
5359273SAli.Bahrami@Sun.COM  *	Each Val_desc supplies a mapping from a value in the range
5369273SAli.Bahrami@Sun.COM  *	(ds_baseval <= value <= ds_topval). The values described need not
5379273SAli.Bahrami@Sun.COM  *	be consecutive, and can be sparse. ds_baseval does not need to
5389273SAli.Bahrami@Sun.COM  *	correspond to the first item, and ds_topval need not correspond to
5399273SAli.Bahrami@Sun.COM  *	the final item.
5409273SAli.Bahrami@Sun.COM  *
5419273SAli.Bahrami@Sun.COM  *    conv_ds_vd2_t (ds_type == CONV_DS_VD2)
5429273SAli.Bahrami@Sun.COM  *	This structure employs a NULL terminated array of Val_desc2 structs,
5439273SAli.Bahrami@Sun.COM  *	rather than Val_desc, adding the ability to specify OSABI and machine
5449273SAli.Bahrami@Sun.COM  *	as part of the value/string mapping. It is otherwise the same thing
5459273SAli.Bahrami@Sun.COM  *	as CONV_DS_VD.
5469273SAli.Bahrami@Sun.COM  */
5479273SAli.Bahrami@Sun.COM typedef enum {
5489273SAli.Bahrami@Sun.COM 	CONV_DS_MSGARR = 0,		/* Array of Msg */
5499273SAli.Bahrami@Sun.COM 	CONV_DS_VD = 1,			/* Null terminated array of Val_desc */
5509273SAli.Bahrami@Sun.COM 	CONV_DS_VD2 = 2,		/* Null terminated array of Val_desc2 */
5519273SAli.Bahrami@Sun.COM } conv_ds_type_t;
5529273SAli.Bahrami@Sun.COM 
5539273SAli.Bahrami@Sun.COM #define	CONV_DS_COMMON_FIELDS \
5549273SAli.Bahrami@Sun.COM 	conv_ds_type_t	ds_type;   	/* Type of data structure used */ \
5559273SAli.Bahrami@Sun.COM 	uint32_t	ds_baseval;	/* Value of first item */	\
5569273SAli.Bahrami@Sun.COM 	uint32_t	ds_topval	/* Value of last item */
5579273SAli.Bahrami@Sun.COM 
5589273SAli.Bahrami@Sun.COM typedef struct {		/* Virtual base type --- do not instantiate */
5599273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5609273SAli.Bahrami@Sun.COM } conv_ds_t;
5619273SAli.Bahrami@Sun.COM typedef struct {
5629273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5639273SAli.Bahrami@Sun.COM 	const Msg		*ds_msg;
5649273SAli.Bahrami@Sun.COM } conv_ds_msg_t;
5659273SAli.Bahrami@Sun.COM typedef struct {
5669273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5679273SAli.Bahrami@Sun.COM 	const Val_desc		*ds_vd;
5689273SAli.Bahrami@Sun.COM } conv_ds_vd_t;
5699273SAli.Bahrami@Sun.COM typedef struct {
5709273SAli.Bahrami@Sun.COM 	CONV_DS_COMMON_FIELDS;
5719273SAli.Bahrami@Sun.COM 	const Val_desc2		*ds_vd2;
5729273SAli.Bahrami@Sun.COM } conv_ds_vd2_t;
5731618Srie 
5741618Srie /*
5759273SAli.Bahrami@Sun.COM  * The initialization of conv_ds_msg_t can be completely derived from
5769273SAli.Bahrami@Sun.COM  * its base value and the array of Msg codes. CONV_DS_MSG_INIT() is used
5779273SAli.Bahrami@Sun.COM  * to do that.
5789273SAli.Bahrami@Sun.COM  */
5799273SAli.Bahrami@Sun.COM #define	CONV_DS_MSG_INIT(_baseval, _arr) \
5809273SAli.Bahrami@Sun.COM 	CONV_DS_MSGARR, _baseval, \
5819273SAli.Bahrami@Sun.COM 	_baseval + (sizeof (_arr) / sizeof (_arr[0])) - 1, _arr
5829273SAli.Bahrami@Sun.COM 
5839273SAli.Bahrami@Sun.COM /*
5849273SAli.Bahrami@Sun.COM  * Null terminated arrays of pointers to conv_ds_XXX_t structs are processed
5859273SAli.Bahrami@Sun.COM  * by conv_map_ds() to convert ELF constants to their symbolic names, and by
5869273SAli.Bahrami@Sun.COM  * conv_iter_ds() to iterate over all the available value/name combinations.
5879273SAli.Bahrami@Sun.COM  *
5889273SAli.Bahrami@Sun.COM  * These pointers are formed by casting the address of the specific
5899273SAli.Bahrami@Sun.COM  * variant types (described above) to generic base type pointer.
5909273SAli.Bahrami@Sun.COM  * CONV_DS_ADDR() is a convenience macro to take the address of
5919273SAli.Bahrami@Sun.COM  * one of these variants and turn it into a generic pointer.
5929273SAli.Bahrami@Sun.COM  */
5939273SAli.Bahrami@Sun.COM #define	CONV_DS_ADDR(_item) ((conv_ds_t *)&(_item))
5949273SAli.Bahrami@Sun.COM 
5959273SAli.Bahrami@Sun.COM /*
5969273SAli.Bahrami@Sun.COM  * Type used by libconv to represent osabi values passed to iteration
5979273SAli.Bahrami@Sun.COM  * functions. The type in the ELF header is uchar_t. However, every possible
5989273SAli.Bahrami@Sun.COM  * value 0-255 has a valid meaning, leaving us no extra value to assign
5999273SAli.Bahrami@Sun.COM  * to mean "ALL". Using Half for osabi leaves us the top byte to use for
6009273SAli.Bahrami@Sun.COM  * out of bound values.
6019273SAli.Bahrami@Sun.COM  *
6029273SAli.Bahrami@Sun.COM  * Non-iteration functions, and any code that does not need to use
6039273SAli.Bahrami@Sun.COM  * CONV_OSABI_ALL, should use uchar_t for osabi.
6049273SAli.Bahrami@Sun.COM  */
6059273SAli.Bahrami@Sun.COM typedef Half conv_iter_osabi_t;
6069273SAli.Bahrami@Sun.COM 
6079273SAli.Bahrami@Sun.COM /*
6089273SAli.Bahrami@Sun.COM  * Many of the iteration functions accept an osabi or mach argument,
6099273SAli.Bahrami@Sun.COM  * used to specify the type of object being processed. The following
6109273SAli.Bahrami@Sun.COM  * values can be used to specify a wildcard that matches any item. Their
6119273SAli.Bahrami@Sun.COM  * values are carefully chosen to ensure that they cannot be interpreted
6129273SAli.Bahrami@Sun.COM  * as an otherwise valid osabi or machine.
6139273SAli.Bahrami@Sun.COM  */
6149273SAli.Bahrami@Sun.COM #define	CONV_OSABI_ALL	1024	/* Larger than can be represented by uchar_t */
6159273SAli.Bahrami@Sun.COM #define	CONV_MACH_ALL	EM_NUM	/* Never a valid machine type */
6169273SAli.Bahrami@Sun.COM 
6179273SAli.Bahrami@Sun.COM /*
6189273SAli.Bahrami@Sun.COM  * We compare Val_Desc2 descriptors with a specified osabi and machine
6199273SAli.Bahrami@Sun.COM  * to determine whether to use it or not. This macro encapsulates that logic.
6209273SAli.Bahrami@Sun.COM  *
6219273SAli.Bahrami@Sun.COM  * We consider an osabi to match when any of the following things hold:
6229273SAli.Bahrami@Sun.COM  *
6239273SAli.Bahrami@Sun.COM  * -	The descriptor osabi is ELFOSABI_NONE.
6249273SAli.Bahrami@Sun.COM  * -	The supplied osabi and the descriptor osabi match
6259273SAli.Bahrami@Sun.COM  * -	The supplied osabi is ELFOSABI_NONE, and the descriptor osabi is
6269273SAli.Bahrami@Sun.COM  *	ELFOSABI_SOLARIS. Many operating systems, Solaris included,
6279273SAli.Bahrami@Sun.COM  *	produce or have produced ELFOSABI_NONE native objects, if only
6289273SAli.Bahrami@Sun.COM  *	because OSABI ranges are not an original ELF feature. We
6299273SAli.Bahrami@Sun.COM  *	give our own objects the home field advantage.
6309273SAli.Bahrami@Sun.COM  * -	Iteration Only: An osabi value of CONV_OSABI_ALL is specified.
6319273SAli.Bahrami@Sun.COM  *
6329273SAli.Bahrami@Sun.COM  * We consider a machine to match when any of the following things hold:
6339273SAli.Bahrami@Sun.COM  *
6349273SAli.Bahrami@Sun.COM  * -	The descriptor mach is EM_NONE.
6359273SAli.Bahrami@Sun.COM  * -	The supplied mach and the descriptor mach match
6369273SAli.Bahrami@Sun.COM  * -	Iteration Only: A mach value of CONV_MACH_ALL is specified.
6379273SAli.Bahrami@Sun.COM  *
6389273SAli.Bahrami@Sun.COM  * The special extra _ALL case for iteration is handled by defining a separate
6399273SAli.Bahrami@Sun.COM  * macro with the extra CONV_xxx_ALL tests.
6409273SAli.Bahrami@Sun.COM  */
6419273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP_OSABI(_osabi, _vdp) \
6429273SAli.Bahrami@Sun.COM 	((_vdp->v_osabi != ELFOSABI_NONE) && (_vdp->v_osabi != osabi) && \
6439273SAli.Bahrami@Sun.COM 	((_osabi != ELFOSABI_NONE) || (_vdp->v_osabi != ELFOSABI_SOLARIS)))
6449273SAli.Bahrami@Sun.COM 
6459273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP_MACH(_mach, _vdp) \
6469273SAli.Bahrami@Sun.COM 	((_vdp->v_mach != EM_NONE) && (_vdp->v_mach != _mach))
6479273SAli.Bahrami@Sun.COM 
6489273SAli.Bahrami@Sun.COM #define	CONV_VD2_SKIP(_osabi, _mach, _vdp) \
6499273SAli.Bahrami@Sun.COM 	(CONV_VD2_SKIP_OSABI(_osabi, _vdp) || CONV_VD2_SKIP_MACH(_mach, _vdp))
6509273SAli.Bahrami@Sun.COM 
6519273SAli.Bahrami@Sun.COM #define	CONV_ITER_VD2_SKIP(_osabi, _mach, _vdp)			      \
6529273SAli.Bahrami@Sun.COM 	((CONV_VD2_SKIP_OSABI(_osabi, _vdp) && (_osabi != CONV_OSABI_ALL)) || \
6539273SAli.Bahrami@Sun.COM 	(CONV_VD2_SKIP_MACH(_mach, _vdp) && (_mach != CONV_MACH_ALL)))
6549273SAli.Bahrami@Sun.COM 
6559273SAli.Bahrami@Sun.COM 
6569273SAli.Bahrami@Sun.COM /*
6579273SAli.Bahrami@Sun.COM  * Possible return values from iteration functions.
6589273SAli.Bahrami@Sun.COM  */
6599273SAli.Bahrami@Sun.COM typedef enum {
6609273SAli.Bahrami@Sun.COM 	CONV_ITER_DONE,		/* Stop: No more iterations are desired */
6619273SAli.Bahrami@Sun.COM 	CONV_ITER_CONT		/* Continue with following iterations */
6629273SAli.Bahrami@Sun.COM } conv_iter_ret_t;
6639273SAli.Bahrami@Sun.COM 
6649273SAli.Bahrami@Sun.COM /*
6659273SAli.Bahrami@Sun.COM  * Prototype for caller supplied callback function to iteration functions.
6669273SAli.Bahrami@Sun.COM  */
6679273SAli.Bahrami@Sun.COM typedef conv_iter_ret_t (* conv_iter_cb_t)(const char *str,
6689273SAli.Bahrami@Sun.COM     Conv_elfvalue_t value, void *uvalue);
6699273SAli.Bahrami@Sun.COM 
6709273SAli.Bahrami@Sun.COM /*
6719273SAli.Bahrami@Sun.COM  * User value block employed by conv_iter_strtol()
6721618Srie  */
6731618Srie typedef struct {
6749273SAli.Bahrami@Sun.COM 	const char	*csl_str;	/* String to search for */
6759273SAli.Bahrami@Sun.COM 	size_t		csl_strlen;	/* # chars in csl_str to examine */
6769273SAli.Bahrami@Sun.COM 	int		csl_found;	/* Init to 0, set to 1 if item found */
6779273SAli.Bahrami@Sun.COM 	Conv_elfvalue_t	csl_value;	/* If csl_found, resulting value */
6789273SAli.Bahrami@Sun.COM } conv_strtol_uvalue_t;
6791618Srie 
6801618Srie /*
6812352Sab196087  * conv_expn_field() is willing to supply default strings for the
6822352Sab196087  * prefix, separator, and suffix arguments, if they are passed as NULL.
6832352Sab196087  * The caller needs to know how much room to allow for these items.
6842352Sab196087  * These values supply those sizes.
6852352Sab196087  */
6862352Sab196087 #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
6872352Sab196087 #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
6882352Sab196087 #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
6892352Sab196087 
6902352Sab196087 /*
6912352Sab196087  * conv_expn_field() requires a large number of inputs, many of which
6922352Sab196087  * can be NULL to accept default behavior. An argument of the following
6932352Sab196087  * type is used to supply them.
6942352Sab196087  */
6952352Sab196087 typedef struct {
6962352Sab196087 	char *buf;		/* Buffer to receive generated string */
6972352Sab196087 	size_t bufsize;		/* sizeof(buf) */
6982352Sab196087 	const char **lead_str;	/* NULL, or array of pointers to strings to */
6992352Sab196087 				/*	be output at the head of the list. */
7002352Sab196087 				/*	Last entry must be NULL. */
7012352Sab196087 	Xword oflags;		/* Bits for which output strings are desired */
7022352Sab196087 	Xword rflags;		/* Bits for which a numeric value should be */
7032352Sab196087 				/*	output if vdp does not provide str. */
7042352Sab196087 				/*	Must be a proper subset of oflags */
7052352Sab196087 	const char *prefix;	/* NULL, or string to prefix output with */
7062352Sab196087 				/*	If NULL, "[ " is used. */
7072352Sab196087 	const char *sep;	/* NULL, or string to separate output items */
7082352Sab196087 				/*	with. If NULL, " " is used. */
7092352Sab196087 	const char *suffix;	/* NULL, or string to suffix output with */
7102352Sab196087 				/*	If NULL, " ]" is used. */
7112352Sab196087 } CONV_EXPN_FIELD_ARG;
7122352Sab196087 
7136635Sab196087 /*
7146635Sab196087  * Callback function for conv_str_to_c_literal(). A user supplied function
7156635Sab196087  * of this type is called by conv_str_to_c_literal() in order to dispatch
7166635Sab196087  * the translated output characters.
7176635Sab196087  *
7186635Sab196087  *	buf - Pointer to output text
7196635Sab196087  *	n - # of characters to output
7206635Sab196087  *	uvalue - User value argument to conv_str_to_c_literal(),
7216635Sab196087  *		passed through without interpretation.
7226635Sab196087  */
7236635Sab196087 typedef	void		Conv_str_to_c_literal_func_t(const void *ptr,
7246635Sab196087 			    size_t size, void *uvalue);
7256635Sab196087 
7262352Sab196087 /*
7279273SAli.Bahrami@Sun.COM  * Generic miscellaneous interfaces
7280Sstevel@tonic-gate  */
7292647Srie extern	uchar_t		conv_check_native(char **, char **);
7309273SAli.Bahrami@Sun.COM extern	const char	*conv_lddstub(int);
7319406SAli.Bahrami@Sun.COM extern	int		conv_strproc_isspace(int);
7329406SAli.Bahrami@Sun.COM extern	char		*conv_strproc_trim(char *);
7339406SAli.Bahrami@Sun.COM extern	Boolean		conv_strproc_extract_value(char *, size_t, int,
7349406SAli.Bahrami@Sun.COM 			    const char **);
7359406SAli.Bahrami@Sun.COM extern	int		conv_sys_eclass(void);
73611734SAli.Bahrami@Sun.COM extern	int		conv_translate_c_esc(char **);
7379273SAli.Bahrami@Sun.COM 
7389273SAli.Bahrami@Sun.COM /*
7399273SAli.Bahrami@Sun.COM  * Generic core formatting and iteration functionality
7409273SAli.Bahrami@Sun.COM  */
7419273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_ds(conv_iter_osabi_t, Half,
7429273SAli.Bahrami@Sun.COM 			    const conv_ds_t **, conv_iter_cb_t, void *,
7439273SAli.Bahrami@Sun.COM 			    const char *);
7449273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_ds_msg(const conv_ds_msg_t *,
7459273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *, const char *);
7469273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_vd(const Val_desc *, conv_iter_cb_t,
7479273SAli.Bahrami@Sun.COM 			    void *, const char *);
7489273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	_conv_iter_vd2(conv_iter_osabi_t, Half,
7499273SAli.Bahrami@Sun.COM 			    const Val_desc2 *, conv_iter_cb_t, void *,
7509273SAli.Bahrami@Sun.COM 			    const char *);
7519273SAli.Bahrami@Sun.COM extern	int		conv_iter_strtol_init(const char *,
7529273SAli.Bahrami@Sun.COM 			    conv_strtol_uvalue_t *);
7539273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_strtol(const char *, Conv_elfvalue_t, void *);
7549273SAli.Bahrami@Sun.COM extern	const char	*_conv_map_ds(uchar_t, Half, Conv_elfvalue_t,
7559273SAli.Bahrami@Sun.COM 			    const conv_ds_t **, Conv_fmt_flags_t,
7569273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *, const char *);
7579273SAli.Bahrami@Sun.COM 
7589273SAli.Bahrami@Sun.COM 
7599273SAli.Bahrami@Sun.COM /*
7609273SAli.Bahrami@Sun.COM  * Generic formatting interfaces.
7619273SAli.Bahrami@Sun.COM  */
7629273SAli.Bahrami@Sun.COM extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
7639273SAli.Bahrami@Sun.COM extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
7644734Sab196087 extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
7654734Sab196087 extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
7661618Srie extern	const char	*conv_config_upm(const char *, const char *,
7671618Srie 			    const char *, size_t);
7686635Sab196087 extern	const char	*conv_cnote_auxv_af(Word, Conv_fmt_flags_t,
7696635Sab196087 			    Conv_cnote_auxv_af_buf_t *);
7706635Sab196087 extern	const char	*conv_cnote_auxv_type(Word, Conv_fmt_flags_t,
7716635Sab196087 			    Conv_inv_buf_t *);
7726635Sab196087 extern	const char	*conv_cnote_cc_content(Lword, Conv_fmt_flags_t,
7736635Sab196087 			    Conv_cnote_cc_content_buf_t *);
7746635Sab196087 extern	const char	*conv_cnote_errno(int, Conv_fmt_flags_t,
7756635Sab196087 			    Conv_inv_buf_t *);
7766635Sab196087 extern	const char	*conv_cnote_fault(Word, Conv_fmt_flags_t,
7776635Sab196087 			    Conv_inv_buf_t *);
7786635Sab196087 extern	const char	*conv_cnote_fltset(uint32_t *, int,
7796635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *);
7806635Sab196087 extern	const char	*conv_cnote_old_pr_flags(int, Conv_fmt_flags_t,
7816635Sab196087 			    Conv_cnote_old_pr_flags_buf_t *);
7826635Sab196087 extern	const char	*conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t,
7836635Sab196087 			    Conv_inv_buf_t *);
7846635Sab196087 extern	const char	*conv_cnote_pr_flags(int, Conv_fmt_flags_t,
7856635Sab196087 			    Conv_cnote_pr_flags_buf_t *);
7866635Sab196087 extern	const char	*conv_cnote_proc_flag(int, Conv_fmt_flags_t,
7876635Sab196087 			    Conv_cnote_proc_flag_buf_t *);
7886635Sab196087 extern	const char	*conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t,
7896635Sab196087 			    Conv_inv_buf_t *inv_buf);
7906635Sab196087 extern	const char	*conv_cnote_pr_stype(Word, Conv_fmt_flags_t,
7916635Sab196087 			    Conv_inv_buf_t *);
7926635Sab196087 extern	const char	*conv_cnote_pr_what(short, short, Conv_fmt_flags_t,
7936635Sab196087 			    Conv_inv_buf_t *);
7946635Sab196087 extern	const char	*conv_cnote_pr_why(short, Conv_fmt_flags_t,
7956635Sab196087 			    Conv_inv_buf_t *);
7966635Sab196087 extern	const char	*conv_cnote_priv(int, Conv_fmt_flags_t,
7976635Sab196087 			    Conv_inv_buf_t *);
7986635Sab196087 extern	const char	*conv_cnote_psetid(int, Conv_fmt_flags_t,
7996635Sab196087 			    Conv_inv_buf_t *);
8006635Sab196087 extern	const char	*conv_cnote_sa_flags(int, Conv_fmt_flags_t,
8016635Sab196087 			    Conv_cnote_sa_flags_buf_t *);
8026635Sab196087 extern	const char	*conv_cnote_signal(Word, Conv_fmt_flags_t,
8036635Sab196087 			    Conv_inv_buf_t *);
8046635Sab196087 extern	const char	*conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t,
8056635Sab196087 			    Conv_inv_buf_t *);
8066635Sab196087 extern	const char	*conv_cnote_sigset(uint32_t *, int,
8076635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *);
8086635Sab196087 extern	const char	*conv_cnote_ss_flags(int, Conv_fmt_flags_t,
8096635Sab196087 			    Conv_cnote_ss_flags_buf_t *);
8106635Sab196087 extern	const char	*conv_cnote_syscall(Word, Conv_fmt_flags_t,
8116635Sab196087 			    Conv_inv_buf_t *);
8126635Sab196087 extern	const char	*conv_cnote_sysset(uint32_t *, int,
8136635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
8146635Sab196087 extern	const char	*conv_cnote_type(Word, Conv_fmt_flags_t,
8156635Sab196087 			    Conv_inv_buf_t *);
8164734Sab196087 extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
8171618Srie extern	const char	*conv_demangle_name(const char *);
8185088Sab196087 extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
8195088Sab196087 			    Conv_dl_flag_buf_t *);
820*12029SRod.Evans@Sun.COM extern	const char	*conv_dl_info(int);
8214734Sab196087 extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
8229085SAli.Bahrami@Sun.COM extern	const char	*conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t,
8239085SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8244734Sab196087 extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
8259085SAli.Bahrami@Sun.COM extern	const char	*conv_dwarf_regname(Half, Word, Conv_fmt_flags_t,
8269085SAli.Bahrami@Sun.COM 			    int *, Conv_inv_buf_t *);
8279273SAli.Bahrami@Sun.COM extern	const char	*conv_ehdr_abivers(uchar_t, Word, Conv_fmt_flags_t,
8285088Sab196087 			    Conv_inv_buf_t *);
8295088Sab196087 extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
8305088Sab196087 			    Conv_inv_buf_t *);
8315088Sab196087 extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
8325088Sab196087 			    Conv_inv_buf_t *);
8335088Sab196087 extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
8345088Sab196087 			    Conv_ehdr_flags_buf_t *);
8355088Sab196087 extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
8365088Sab196087 			    Conv_inv_buf_t *);
8375088Sab196087 extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
8385088Sab196087 			    Conv_inv_buf_t *);
8399273SAli.Bahrami@Sun.COM extern	const char	*conv_ehdr_type(uchar_t, Half, Conv_fmt_flags_t,
8405088Sab196087 			    Conv_inv_buf_t *);
8415088Sab196087 extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
8425088Sab196087 			    Conv_inv_buf_t *);
8439273SAli.Bahrami@Sun.COM extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
84411734SAli.Bahrami@Sun.COM extern	const char	*conv_ent_flags(ec_flags_t, Conv_ent_flags_buf_t *);
84511734SAli.Bahrami@Sun.COM extern	const char	*conv_ent_files_flags(Word,  Conv_fmt_flags_t fmt_flags,
84611734SAli.Bahrami@Sun.COM 			    Conv_ent_files_flags_buf_t *);
8479273SAli.Bahrami@Sun.COM extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
8489273SAli.Bahrami@Sun.COM extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
8499273SAli.Bahrami@Sun.COM extern	Isa_desc	*conv_isalist(void);
85011734SAli.Bahrami@Sun.COM extern	const char	*conv_mapfile_version(Word, Conv_fmt_flags_t,
85111734SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8529273SAli.Bahrami@Sun.COM extern	const char	*conv_phdr_flags(uchar_t, Word, Conv_fmt_flags_t,
8535088Sab196087 			    Conv_phdr_flags_buf_t *);
8549273SAli.Bahrami@Sun.COM extern	const char	*conv_phdr_type(uchar_t, Half, Word, Conv_fmt_flags_t,
8555088Sab196087 			    Conv_inv_buf_t *);
8566206Sab196087 extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *,
8576206Sab196087 			    Half mach);
8585088Sab196087 extern	const char	*conv_reloc_type(Half, Word, Conv_fmt_flags_t,
8595088Sab196087 			    Conv_inv_buf_t *);
8605088Sab196087 extern	const char	*conv_reloc_type_static(Half, Word, Conv_fmt_flags_t);
8615088Sab196087 extern	const char	*conv_reloc_386_type(Word, Conv_fmt_flags_t,
8625088Sab196087 			    Conv_inv_buf_t *);
8635088Sab196087 extern	const char	*conv_reloc_amd64_type(Word, Conv_fmt_flags_t,
8645088Sab196087 			    Conv_inv_buf_t *);
8655088Sab196087 extern	const char	*conv_reloc_SPARC_type(Word, Conv_fmt_flags_t,
8665088Sab196087 			    Conv_inv_buf_t *);
8679273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_type(uchar_t, Half, Word, Conv_fmt_flags_t,
8685088Sab196087 			    Conv_inv_buf_t *);
86911734SAli.Bahrami@Sun.COM extern	const char	*conv_seg_flags(sg_flags_t, Conv_seg_flags_buf_t *);
8709273SAli.Bahrami@Sun.COM extern	void		conv_str_to_c_literal(const char *buf, size_t n,
8719273SAli.Bahrami@Sun.COM 			    Conv_str_to_c_literal_func_t *cb_func,
8729273SAli.Bahrami@Sun.COM 			    void *uvalue);
8735088Sab196087 extern	const char	*conv_sym_info_bind(uchar_t, Conv_fmt_flags_t,
8745088Sab196087 			    Conv_inv_buf_t *);
8755088Sab196087 extern	const char	*conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t,
8764734Sab196087 			    Conv_inv_buf_t *);
8779273SAli.Bahrami@Sun.COM extern	const char	*conv_sym_shndx(uchar_t, Half, Half, Conv_fmt_flags_t,
8789273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8794734Sab196087 extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
8805088Sab196087 extern	const char	*conv_sym_other_vis(uchar_t, Conv_fmt_flags_t,
8815088Sab196087 			    Conv_inv_buf_t *);
8829273SAli.Bahrami@Sun.COM extern	const char	*conv_syminfo_boundto(Half, Conv_fmt_flags_t,
8839273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
8849273SAli.Bahrami@Sun.COM extern	const char	*conv_syminfo_flags(Half, Conv_fmt_flags_t,
8859273SAli.Bahrami@Sun.COM 			    Conv_syminfo_flags_buf_t *);
8869577SRod.Evans@Sun.COM extern	const char	*conv_time(struct timeval *, struct timeval *,
8879577SRod.Evans@Sun.COM 			    Conv_time_buf_t *);
8889273SAli.Bahrami@Sun.COM extern	Uts_desc	*conv_uts(void);
8899273SAli.Bahrami@Sun.COM extern	const char	*conv_ver_flags(Half, Conv_fmt_flags_t,
8909273SAli.Bahrami@Sun.COM 			    Conv_ver_flags_buf_t *);
8919273SAli.Bahrami@Sun.COM extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
8929273SAli.Bahrami@Sun.COM 
8939273SAli.Bahrami@Sun.COM 
8949273SAli.Bahrami@Sun.COM /*
8959273SAli.Bahrami@Sun.COM  * Generic iteration interfaces.
8969273SAli.Bahrami@Sun.COM  */
8979273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_tags(Conv_fmt_flags_t, conv_iter_cb_t,
8989273SAli.Bahrami@Sun.COM 			    void *);
8999273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_val_hw1(Half, Conv_fmt_flags_t,
9009273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
90111827SRod.Evans@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_val_hw2(Half, Conv_fmt_flags_t,
90211827SRod.Evans@Sun.COM 			    conv_iter_cb_t, void *);
9039273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t,
9049273SAli.Bahrami@Sun.COM 			    void *);
9059273SAli.Bahrami@Sun.COM 
9069273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t,
9079273SAli.Bahrami@Sun.COM 			    void *);
9089273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_flag(Conv_fmt_flags_t, conv_iter_cb_t,
9099273SAli.Bahrami@Sun.COM 			    void *);
9109273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_flag1(Conv_fmt_flags_t, conv_iter_cb_t,
9119273SAli.Bahrami@Sun.COM 			    void *);
9129273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_posflag1(Conv_fmt_flags_t, conv_iter_cb_t,
9139273SAli.Bahrami@Sun.COM 			    void *);
9149273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_dyn_tag(conv_iter_osabi_t, Half,
9159273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9169273SAli.Bahrami@Sun.COM 
9179273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_abivers(conv_iter_osabi_t,
9189273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9199273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_class(Conv_fmt_flags_t, conv_iter_cb_t,
9209273SAli.Bahrami@Sun.COM 			    void *);
9219273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_data(Conv_fmt_flags_t, conv_iter_cb_t,
9229273SAli.Bahrami@Sun.COM 			    void *);
9239273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_eident(Conv_fmt_flags_t, conv_iter_cb_t,
9249273SAli.Bahrami@Sun.COM 			    void *);
9259273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_flags(Half, Conv_fmt_flags_t,
9269273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9279273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_mach(Conv_fmt_flags_t, conv_iter_cb_t,
9289273SAli.Bahrami@Sun.COM 			    void *);
9299273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_osabi(Conv_fmt_flags_t, conv_iter_cb_t,
9309273SAli.Bahrami@Sun.COM 			    void *);
9319273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
9329273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9339273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_ehdr_vers(Conv_fmt_flags_t, conv_iter_cb_t,
9349273SAli.Bahrami@Sun.COM 			    void *);
9359273SAli.Bahrami@Sun.COM 
9369273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_phdr_flags(conv_iter_osabi_t,
9379273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9389273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_phdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
9399273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9409273SAli.Bahrami@Sun.COM 
9419273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_flags(conv_iter_osabi_t, Half,
9429273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9439273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_symtab(conv_iter_osabi_t,
9449273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9459273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sec_type(conv_iter_osabi_t, Half,
9469273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9479273SAli.Bahrami@Sun.COM 
9489273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_info_bind(Conv_fmt_flags_t,
9499273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9509273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_other_vis(Conv_fmt_flags_t,
9519273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9529273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_shndx(conv_iter_osabi_t, Half,
9539273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9549273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_sym_info_type(Half, Conv_fmt_flags_t,
9559273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9569273SAli.Bahrami@Sun.COM 
9579273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_syminfo_boundto(Conv_fmt_flags_t,
9589273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9599273SAli.Bahrami@Sun.COM extern	conv_iter_ret_t	conv_iter_syminfo_flags(Conv_fmt_flags_t,
9609273SAli.Bahrami@Sun.COM 			    conv_iter_cb_t, void *);
9619273SAli.Bahrami@Sun.COM 
9629273SAli.Bahrami@Sun.COM /*
9639273SAli.Bahrami@Sun.COM  * Define all class specific routines.
9649273SAli.Bahrami@Sun.COM  */
9659273SAli.Bahrami@Sun.COM #if	defined(_ELF64)
9669273SAli.Bahrami@Sun.COM #define	conv_cap_tag		conv64_cap_tag
9679273SAli.Bahrami@Sun.COM #define	conv_cap_val		conv64_cap_val
9689273SAli.Bahrami@Sun.COM #define	conv_cap_val_hw1	conv64_cap_val_hw1
96911827SRod.Evans@Sun.COM #define	conv_cap_val_hw2	conv64_cap_val_hw2
9709273SAli.Bahrami@Sun.COM #define	conv_cap_val_sf1	conv64_cap_val_sf1
9719273SAli.Bahrami@Sun.COM #define	conv_dyn_feature1	conv64_dyn_feature1
9729273SAli.Bahrami@Sun.COM #define	conv_dyn_flag1		conv64_dyn_flag1
9739273SAli.Bahrami@Sun.COM #define	conv_dyn_flag		conv64_dyn_flag
9749273SAli.Bahrami@Sun.COM #define	conv_dyn_posflag1	conv64_dyn_posflag1
9759273SAli.Bahrami@Sun.COM #define	conv_dyn_tag		conv64_dyn_tag
9769273SAli.Bahrami@Sun.COM #define	_conv_expn_field	_conv64_expn_field
9779273SAli.Bahrami@Sun.COM #define	_conv_expn_field2	_conv64_expn_field2
9789273SAli.Bahrami@Sun.COM #define	conv_invalid_val	conv64_invalid_val
9799273SAli.Bahrami@Sun.COM #define	conv_sec_flags		conv64_sec_flags
9809273SAli.Bahrami@Sun.COM #define	conv_sec_linkinfo	conv64_sec_linkinfo
9819273SAli.Bahrami@Sun.COM #define	conv_sym_value		conv64_sym_value
9829273SAli.Bahrami@Sun.COM #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
9839273SAli.Bahrami@Sun.COM #else
9849273SAli.Bahrami@Sun.COM #define	conv_cap_tag		conv32_cap_tag
9859273SAli.Bahrami@Sun.COM #define	conv_cap_val		conv32_cap_val
9869273SAli.Bahrami@Sun.COM #define	conv_cap_val_hw1	conv32_cap_val_hw1
98711827SRod.Evans@Sun.COM #define	conv_cap_val_hw2	conv32_cap_val_hw2
9889273SAli.Bahrami@Sun.COM #define	conv_cap_val_sf1	conv32_cap_val_sf1
9899273SAli.Bahrami@Sun.COM #define	conv_dyn_feature1	conv32_dyn_feature1
9909273SAli.Bahrami@Sun.COM #define	conv_dyn_flag1		conv32_dyn_flag1
9919273SAli.Bahrami@Sun.COM #define	conv_dyn_flag		conv32_dyn_flag
9929273SAli.Bahrami@Sun.COM #define	conv_dyn_posflag1	conv32_dyn_posflag1
9939273SAli.Bahrami@Sun.COM #define	conv_dyn_tag		conv32_dyn_tag
9949273SAli.Bahrami@Sun.COM #define	_conv_expn_field	_conv32_expn_field
9959273SAli.Bahrami@Sun.COM #define	_conv_expn_field2	_conv32_expn_field2
9969273SAli.Bahrami@Sun.COM #define	conv_invalid_val	conv32_invalid_val
9979273SAli.Bahrami@Sun.COM #define	conv_sec_flags		conv32_sec_flags
9989273SAli.Bahrami@Sun.COM #define	conv_sec_linkinfo	conv32_sec_linkinfo
9999273SAli.Bahrami@Sun.COM #define	conv_sym_value		conv32_sym_value
10009273SAli.Bahrami@Sun.COM #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
10019273SAli.Bahrami@Sun.COM #endif
10029273SAli.Bahrami@Sun.COM 
10039273SAli.Bahrami@Sun.COM /*
10049273SAli.Bahrami@Sun.COM  * ELFCLASS-specific core formatting functionality
10059273SAli.Bahrami@Sun.COM  */
10069273SAli.Bahrami@Sun.COM extern	int		_conv_expn_field(CONV_EXPN_FIELD_ARG *,
10079273SAli.Bahrami@Sun.COM 			    const Val_desc *, Conv_fmt_flags_t, const char *);
10089273SAli.Bahrami@Sun.COM extern	int		_conv_expn_field2(CONV_EXPN_FIELD_ARG *, uchar_t,
10099273SAli.Bahrami@Sun.COM 			    Half, const Val_desc2 *, Conv_fmt_flags_t,
10109273SAli.Bahrami@Sun.COM 			    const char *);
10119273SAli.Bahrami@Sun.COM extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
10129273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t);
10139273SAli.Bahrami@Sun.COM 
10149273SAli.Bahrami@Sun.COM /*
10159273SAli.Bahrami@Sun.COM  * ELFCLASS-specific formatting interfaces.
10169273SAli.Bahrami@Sun.COM  */
10179273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_tag(Xword, Conv_fmt_flags_t,
10189273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
101911827SRod.Evans@Sun.COM extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_fmt_flags_t,
102011827SRod.Evans@Sun.COM 			    Conv_cap_val_buf_t *);
10219273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
10229273SAli.Bahrami@Sun.COM 			    Conv_cap_val_hw1_buf_t *);
102311827SRod.Evans@Sun.COM extern	const char	*conv_cap_val_hw2(Xword, Half, Conv_fmt_flags_t,
102411827SRod.Evans@Sun.COM 			    Conv_cap_val_hw2_buf_t *);
10259273SAli.Bahrami@Sun.COM extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
10269273SAli.Bahrami@Sun.COM 			    Conv_cap_val_sf1_buf_t *);
10279273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
10289273SAli.Bahrami@Sun.COM 			    Conv_dyn_flag1_buf_t *);
10299273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
10309273SAli.Bahrami@Sun.COM 			    Conv_dyn_flag_buf_t *);
10319273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
10329273SAli.Bahrami@Sun.COM 			    Conv_dyn_posflag1_buf_t *);
10339273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_tag(Xword, uchar_t, Half, Conv_fmt_flags_t,
10349273SAli.Bahrami@Sun.COM 			    Conv_inv_buf_t *);
10359273SAli.Bahrami@Sun.COM extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
10369273SAli.Bahrami@Sun.COM 			    Conv_dyn_feature1_buf_t *);
10379273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_flags(uchar_t osabi, Half mach, Xword,
10389273SAli.Bahrami@Sun.COM 			    Conv_fmt_flags_t, Conv_sec_flags_buf_t *);
10399273SAli.Bahrami@Sun.COM extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
10404734Sab196087 extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
10415088Sab196087 extern	const char	*conv_sym_SPARC_value(Addr, Conv_fmt_flags_t,
10425088Sab196087 			    Conv_inv_buf_t *);
10439273SAli.Bahrami@Sun.COM 
10449273SAli.Bahrami@Sun.COM /*
10459273SAli.Bahrami@Sun.COM  * Define macros for _conv_XXX() routines that accept local_sgs_msg as the
10469273SAli.Bahrami@Sun.COM  * final argument. The macros hide that argument from the caller's view and
10479273SAli.Bahrami@Sun.COM  * supply the SGS message array for the file from which the macro is used
10489273SAli.Bahrami@Sun.COM  * in its place. This trick is used to allow these functions to access the
10499273SAli.Bahrami@Sun.COM  * message strings from any source file they are called from.
10509273SAli.Bahrami@Sun.COM  */
10519273SAli.Bahrami@Sun.COM #define	conv_expn_field(_arg, _vdp, _fmt_flags) \
10529273SAli.Bahrami@Sun.COM     _conv_expn_field(_arg, _vdp, _fmt_flags, MSG_SGS_LOCAL_ARRAY)
10539273SAli.Bahrami@Sun.COM 
10549273SAli.Bahrami@Sun.COM #define	conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags) \
10559273SAli.Bahrami@Sun.COM     _conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags, \
10569273SAli.Bahrami@Sun.COM     MSG_SGS_LOCAL_ARRAY)
10579273SAli.Bahrami@Sun.COM 
10589273SAli.Bahrami@Sun.COM #define	conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue) \
10599273SAli.Bahrami@Sun.COM     _conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10609273SAli.Bahrami@Sun.COM 
10619273SAli.Bahrami@Sun.COM #define	conv_iter_vd(_vdp, _func, _uvalue)	\
10629273SAli.Bahrami@Sun.COM     _conv_iter_vd(_vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10639273SAli.Bahrami@Sun.COM 
10649273SAli.Bahrami@Sun.COM #define	conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue)		\
10659273SAli.Bahrami@Sun.COM     _conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
10669273SAli.Bahrami@Sun.COM 
10679273SAli.Bahrami@Sun.COM #define	conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf) \
10689273SAli.Bahrami@Sun.COM     _conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf, \
10699273SAli.Bahrami@Sun.COM     MSG_SGS_LOCAL_ARRAY)
10709273SAli.Bahrami@Sun.COM 
10710Sstevel@tonic-gate 
10720Sstevel@tonic-gate #ifdef	__cplusplus
10730Sstevel@tonic-gate }
10740Sstevel@tonic-gate #endif
10750Sstevel@tonic-gate 
10760Sstevel@tonic-gate #endif /* _CONV_H */
1077