xref: /onnv-gate/usr/src/cmd/sgs/include/conv.h (revision 6635:8de60a34b2e5)
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  *
266206Sab196087  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
271618Srie  * Use is subject to license terms.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef	_CONV_H
310Sstevel@tonic-gate #define	_CONV_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * Global include file for conversion library.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <stdlib.h>
400Sstevel@tonic-gate #include <libelf.h>
410Sstevel@tonic-gate #include <dlfcn.h>
420Sstevel@tonic-gate #include <libld.h>
430Sstevel@tonic-gate #include <sgs.h>
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #ifdef	__cplusplus
460Sstevel@tonic-gate extern "C" {
470Sstevel@tonic-gate #endif
480Sstevel@tonic-gate 
490Sstevel@tonic-gate /*
500Sstevel@tonic-gate  * Configuration features available - maintained here (instead of debug.h)
510Sstevel@tonic-gate  * to save libconv from having to include debug.h which results in numerous
520Sstevel@tonic-gate  * "declared but not used or defined" lint errors.
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
550Sstevel@tonic-gate #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
560Sstevel@tonic-gate #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
570Sstevel@tonic-gate #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
580Sstevel@tonic-gate #define	CONF_DIRCFG	0x001000	/* directory configuration available */
590Sstevel@tonic-gate #define	CONF_OBJALT	0x002000	/* object alternatives available */
600Sstevel@tonic-gate #define	CONF_MEMRESV	0x004000	/* memory reservation required */
610Sstevel@tonic-gate #define	CONF_ENVS	0x008000	/* environment variables available */
620Sstevel@tonic-gate #define	CONF_FLTR	0x010000	/* filter information available */
630Sstevel@tonic-gate #define	CONF_FEATMSK	0xffff00
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*
664734Sab196087  * Buffer types:
674734Sab196087  *
684734Sab196087  * Many of the routines in this module require the user to supply a
694734Sab196087  * buffer into which the desired strings may be written. These are
704734Sab196087  * all arrays of characters, and might be defined as simple arrays
714734Sab196087  * of char. The problem with that approach is that when such an array
724734Sab196087  * is passed to a function, the C language considers it to have the
734734Sab196087  * type (char *), without any regard to its length. Not all of our
744734Sab196087  * buffers have the same length, and we want to ensure that the compiler
754734Sab196087  * will refuse to compile code that passes the wrong type of buffer to
764734Sab196087  * a given routine. The solution is to define the buffers as unions
774734Sab196087  * that contain the needed array, and then to pass the given union
784734Sab196087  * by address. The compiler will catch attempts to pass the wrong type
794734Sab196087  * of pointer, and the size of a structure/union is implicit in its type.
804734Sab196087  *
814734Sab196087  * A nice side effect of this approach is that we can use a union with
824734Sab196087  * multiple buffers to handle the cases where a given routine needs
834734Sab196087  * more than one type of buffer. The end result is a single buffer large
844734Sab196087  * enough to handle any of the subcases, but no larger.
854734Sab196087  */
864734Sab196087 
874734Sab196087 /*
884734Sab196087  * Size of buffer used by conv_invalid_val():
894734Sab196087  *
901618Srie  * Various values that can't be matched to a symbolic definition are converted
914734Sab196087  * to a numeric string.
924734Sab196087  *
934734Sab196087  * The buffer size reflects the maximum number of digits needed to
944734Sab196087  * display an integer as text, plus a trailing null, and with room for
954734Sab196087  * a leading "0x" if hexidecimal display is selected.
964734Sab196087  */
974734Sab196087 #define	CONV32_INV_BUFSIZE	12
984734Sab196087 typedef union {
994734Sab196087 	char			buf[CONV32_INV_BUFSIZE];
1004734Sab196087 } Conv32_inv_buf_t;
1014734Sab196087 
1024734Sab196087 #define	CONV64_INV_BUFSIZE	22
1034734Sab196087 typedef union {
1044734Sab196087 	char			buf[CONV64_INV_BUFSIZE];
1054734Sab196087 } Conv64_inv_buf_t;
1064734Sab196087 
1074734Sab196087 
1084734Sab196087 
1094734Sab196087 /* conv_ehdr_flags() */
1105088Sab196087 #define	CONV_EHDR_FLAGS_BASE_BUFSIZE	69
1114734Sab196087 #define	CONV32_EHDR_FLAGS_BUFSIZE	\
1125088Sab196087 	(CONV_EHDR_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
1134734Sab196087 typedef union {
1144734Sab196087 	Conv32_inv_buf_t	inv_buf;
1154734Sab196087 	char			buf[CONV32_EHDR_FLAGS_BUFSIZE];
1164734Sab196087 } Conv32_ehdr_flags_buf_t;
1174734Sab196087 
1184734Sab196087 #define	CONV64_EHDR_FLAGS_BUFSIZE	\
1195088Sab196087 	(CONV_EHDR_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
1204734Sab196087 typedef union {
1214734Sab196087 	Conv64_inv_buf_t	inv_buf;
1224734Sab196087 	char			buf[CONV64_EHDR_FLAGS_BUFSIZE];
1234734Sab196087 } Conv64_ehdr_flags_buf_t;
1244734Sab196087 
1254734Sab196087 
1264734Sab196087 /* conv_reject_desc() */
1274734Sab196087 typedef union {
1284734Sab196087 	Conv32_inv_buf_t	inv_buf;
1294734Sab196087 	Conv32_ehdr_flags_buf_t	flags_buf;
1304734Sab196087 } Conv32_reject_desc_buf_t;
1314734Sab196087 
1324734Sab196087 typedef union {
1334734Sab196087 	Conv64_inv_buf_t	inv_buf;
1344734Sab196087 	Conv64_ehdr_flags_buf_t	flags_buf;
1354734Sab196087 } Conv64_reject_desc_buf_t;
1364734Sab196087 
1374734Sab196087 
1384734Sab196087 /*
1394734Sab196087  * conv_cap_val_hw1()
1404734Sab196087  *
1414734Sab196087  * This size is based on the maximum number of hardware capabilities
1424734Sab196087  * that exist.  See common/elfcap.
1434734Sab196087  */
1444734Sab196087 #define	CONV_CAP_VAL_HW1_BUFSIZE	195
1454734Sab196087 
1464734Sab196087 typedef union {
1474734Sab196087 	Conv32_inv_buf_t	inv_buf;
1484734Sab196087 	char			buf[CONV_CAP_VAL_HW1_BUFSIZE];
1494734Sab196087 } Conv32_cap_val_hw1_buf_t;
1504734Sab196087 
1514734Sab196087 typedef union {
1524734Sab196087 	Conv64_inv_buf_t	inv_buf;
1534734Sab196087 	char			buf[CONV_CAP_VAL_HW1_BUFSIZE];
1544734Sab196087 } Conv64_cap_val_hw1_buf_t;
1554734Sab196087 
1564734Sab196087 
1574734Sab196087 /*
1584734Sab196087  * conv_cap_val_sf1()
1591618Srie  *
1604734Sab196087  * This size is based on the maximum number of software capabilities
1614734Sab196087  * that exist.  See common/elfcap.
1624734Sab196087  */
1634734Sab196087 #define	CONV_CAP_VAL_SF1_BUFSIZE	45
1644734Sab196087 
1654734Sab196087 typedef union {
1664734Sab196087 	Conv32_inv_buf_t	inv_buf;
1674734Sab196087 	char			buf[CONV_CAP_VAL_SF1_BUFSIZE];
1684734Sab196087 } Conv32_cap_val_sf1_buf_t;
1694734Sab196087 
1704734Sab196087 typedef union {
1714734Sab196087 	Conv64_inv_buf_t	inv_buf;
1724734Sab196087 	char			buf[CONV_CAP_VAL_SF1_BUFSIZE];
1734734Sab196087 } Conv64_cap_val_sf1_buf_t;
1744734Sab196087 
1754734Sab196087 
1764734Sab196087 
1774734Sab196087 /* conv_cap_val_buf() */
1784734Sab196087 typedef union {
1794734Sab196087 	Conv32_inv_buf_t		inv_buf;
1804734Sab196087 	Conv32_cap_val_hw1_buf_t	cap_val_hw1_buf;
1814734Sab196087 	Conv32_cap_val_sf1_buf_t	cap_val_sf1_buf;
1824734Sab196087 } Conv32_cap_val_buf_t;
1834734Sab196087 
1844734Sab196087 typedef union {
1854734Sab196087 	Conv64_inv_buf_t		inv_buf;
1864734Sab196087 	Conv64_cap_val_hw1_buf_t	cap_val_hw1_buf;
1874734Sab196087 	Conv64_cap_val_sf1_buf_t	cap_val_sf1_buf;
1884734Sab196087 } Conv64_cap_val_buf_t;
1894734Sab196087 
1904734Sab196087 
1914734Sab196087 /* conv_config_feat() */
1925152Sab196087 #define	CONV_CONFIG_FEAT_BUFSIZE	194
1934734Sab196087 
1944734Sab196087 typedef union {
1954734Sab196087 	Conv32_inv_buf_t	inv_buf;
1964734Sab196087 	char			buf[CONV_CONFIG_FEAT_BUFSIZE];
1974734Sab196087 } Conv32_config_feat_buf_t;
1984734Sab196087 
1994734Sab196087 typedef union {
2004734Sab196087 	Conv64_inv_buf_t	inv_buf;
2014734Sab196087 	char			buf[CONV_CONFIG_FEAT_BUFSIZE];
2024734Sab196087 } Conv64_config_feat_buf_t;
2034734Sab196087 
2044734Sab196087 
2054734Sab196087 /* conv_config_obj() */
2064734Sab196087 #define	CONV_CONFIG_OBJ_BUFSIZE		154
2074734Sab196087 
2084734Sab196087 typedef union {
2094734Sab196087 	Conv32_inv_buf_t	inv_buf;
2104734Sab196087 	char			buf[CONV_CONFIG_OBJ_BUFSIZE];
2114734Sab196087 } Conv32_config_obj_buf_t;
2124734Sab196087 
2134734Sab196087 typedef union {
2144734Sab196087 	Conv64_inv_buf_t	inv_buf;
2154734Sab196087 	char			buf[CONV_CONFIG_OBJ_BUFSIZE];
2164734Sab196087 } Conv64_config_obj_buf_t;
2174734Sab196087 
2184734Sab196087 
2194734Sab196087 /* conv_dl_mode() */
2204734Sab196087 #define	CONV_DL_MODE_BUFSIZE		122
2214734Sab196087 
2224734Sab196087 typedef union {
2234734Sab196087 	Conv32_inv_buf_t	inv_buf;
2244734Sab196087 	char			buf[CONV_DL_MODE_BUFSIZE];
2254734Sab196087 } Conv32_dl_mode_buf_t;
2264734Sab196087 
2274734Sab196087 typedef union {
2284734Sab196087 	Conv64_inv_buf_t	inv_buf;
2294734Sab196087 	char			buf[CONV_DL_MODE_BUFSIZE];
2304734Sab196087 } Conv64_dl_mode_buf_t;
2314734Sab196087 
2324734Sab196087 
2334734Sab196087 /* conv_dl_flag() */
2345152Sab196087 #define	CONV_DL_FLAG_BUFSIZE		175
2354734Sab196087 
2364734Sab196087 typedef union {
2374734Sab196087 	Conv32_inv_buf_t	inv_buf;
2384734Sab196087 	char			buf[CONV_DL_FLAG_BUFSIZE];
2394734Sab196087 } Conv32_dl_flag_buf_t;
2404734Sab196087 
2414734Sab196087 typedef union {
2424734Sab196087 	Conv64_inv_buf_t	inv_buf;
2434734Sab196087 	char			buf[CONV_DL_FLAG_BUFSIZE];
2444734Sab196087 } Conv64_dl_flag_buf_t;
2454734Sab196087 
2464734Sab196087 
2474734Sab196087 /* conv_grphdl_flags() */
2485067Srie #define	CONV_GRPHDL_FLAGS_BUFSIZE	82
2494734Sab196087 
2504734Sab196087 typedef union {
2514734Sab196087 	Conv32_inv_buf_t	inv_buf;
2524734Sab196087 	char			buf[CONV_GRPHDL_FLAGS_BUFSIZE];
2534734Sab196087 } Conv32_grphdl_flags_buf_t;
2544734Sab196087 
2554734Sab196087 typedef union {
2564734Sab196087 	Conv64_inv_buf_t	inv_buf;
2574734Sab196087 	char			buf[CONV_GRPHDL_FLAGS_BUFSIZE];
2584734Sab196087 } Conv64_grphdl_flags_buf_t;
2594734Sab196087 
2604734Sab196087 
2614734Sab196087 /* conv_grpdesc_flags() */
2625067Srie #define	CONV_GRPDESC_FLAGS_BUFSIZE	92
2634734Sab196087 
2644734Sab196087 typedef union {
2654734Sab196087 	Conv32_inv_buf_t	inv_buf;
2664734Sab196087 	char			buf[CONV_GRPDESC_FLAGS_BUFSIZE];
2674734Sab196087 } Conv32_grpdesc_flags_buf_t;
2684734Sab196087 
2694734Sab196087 typedef union {
2704734Sab196087 	Conv64_inv_buf_t	inv_buf;
2714734Sab196087 	char			buf[CONV_GRPDESC_FLAGS_BUFSIZE];
2724734Sab196087 } Conv64_grpdesc_flags_buf_t;
2734734Sab196087 
2744734Sab196087 
2754734Sab196087 /* conv_seg_flags() */
2764734Sab196087 #define	CONV_SEG_FLAGS_BUFSIZE		186
2774734Sab196087 
2784734Sab196087 typedef union {
2794734Sab196087 	Conv32_inv_buf_t	inv_buf;
2804734Sab196087 	char			buf[CONV_SEG_FLAGS_BUFSIZE];
2814734Sab196087 } Conv32_seg_flags_buf_t;
2824734Sab196087 
2834734Sab196087 typedef union {
2844734Sab196087 	Conv64_inv_buf_t	inv_buf;
2854734Sab196087 	char			buf[CONV_SEG_FLAGS_BUFSIZE];
2864734Sab196087 } Conv64_seg_flags_buf_t;
2874734Sab196087 
2884734Sab196087 
2894734Sab196087 /* conv_dyn_posflag1() */
2905088Sab196087 #define	CONV_DYN_POSFLAG1_BASE_BUFSIZE	23
2914734Sab196087 #define	CONV32_DYN_POSFLAG1_BUFSIZE	\
2925088Sab196087 	(CONV_DYN_POSFLAG1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
2934734Sab196087 typedef union {
2944734Sab196087 	Conv32_inv_buf_t	inv_buf;
2954734Sab196087 	char			buf[CONV32_DYN_POSFLAG1_BUFSIZE];
2964734Sab196087 } Conv32_dyn_posflag1_buf_t;
2974734Sab196087 
2984734Sab196087 #define	CONV64_DYN_POSFLAG1_BUFSIZE	\
2995088Sab196087 	(CONV_DYN_POSFLAG1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3004734Sab196087 typedef union {
3014734Sab196087 	Conv64_inv_buf_t	inv_buf;
3024734Sab196087 	char			buf[CONV64_DYN_POSFLAG1_BUFSIZE];
3034734Sab196087 } Conv64_dyn_posflag1_buf_t;
3044734Sab196087 
3054734Sab196087 
3064734Sab196087 /* conv_dyn_flag() */
3075088Sab196087 #define	CONV_DYN_FLAG_BASE_BUFSIZE	48
3084734Sab196087 #define	CONV32_DYN_FLAG_BUFSIZE	\
3095088Sab196087 	(CONV_DYN_FLAG_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3104734Sab196087 typedef union {
3114734Sab196087 	Conv32_inv_buf_t	inv_buf;
3124734Sab196087 	char			buf[CONV32_DYN_FLAG_BUFSIZE];
3134734Sab196087 } Conv32_dyn_flag_buf_t;
3144734Sab196087 
3154734Sab196087 #define	CONV64_DYN_FLAG_BUFSIZE	\
3165088Sab196087 	(CONV_DYN_FLAG_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3174734Sab196087 typedef union {
3184734Sab196087 	Conv64_inv_buf_t	inv_buf;
3194734Sab196087 	char			buf[CONV64_DYN_FLAG_BUFSIZE];
3204734Sab196087 } Conv64_dyn_flag_buf_t;
3214734Sab196087 
3224734Sab196087 
3234734Sab196087 /* conv_dyn_flag1() */
3245220Srie #define	CONV_DYN_FLAG1_BASE_BUFSIZE	265
3254734Sab196087 #define	CONV32_DYN_FLAG1_BUFSIZE	\
3265088Sab196087 	(CONV_DYN_FLAG1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3274734Sab196087 typedef union {
3284734Sab196087 	Conv32_inv_buf_t	inv_buf;
3294734Sab196087 	char			buf[CONV32_DYN_FLAG1_BUFSIZE];
3304734Sab196087 } Conv32_dyn_flag1_buf_t;
3314734Sab196087 
3324734Sab196087 #define	CONV64_DYN_FLAG1_BUFSIZE	\
3335088Sab196087 	(CONV_DYN_FLAG1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3344734Sab196087 typedef union {
3354734Sab196087 	Conv64_inv_buf_t	inv_buf;
3364734Sab196087 	char			buf[CONV64_DYN_FLAG1_BUFSIZE];
3374734Sab196087 } Conv64_dyn_flag1_buf_t;
3384734Sab196087 
3394734Sab196087 
3404734Sab196087 /* conv_dyn_feature1() */
3415088Sab196087 #define	CONV_DYN_FEATURE1_BASE_BUFSIZE	20
3424734Sab196087 #define	CONV32_DYN_FEATURE1_BUFSIZE	\
3435088Sab196087 	(CONV_DYN_FEATURE1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3444734Sab196087 typedef union {
3454734Sab196087 	Conv32_inv_buf_t	inv_buf;
3464734Sab196087 	char			buf[CONV32_DYN_FEATURE1_BUFSIZE];
3474734Sab196087 } Conv32_dyn_feature1_buf_t;
3484734Sab196087 
3494734Sab196087 #define	CONV64_DYN_FEATURE1_BUFSIZE	\
3505088Sab196087 	(CONV_DYN_FEATURE1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3514734Sab196087 typedef union {
3524734Sab196087 	Conv64_inv_buf_t	inv_buf;
3534734Sab196087 	char			buf[CONV64_DYN_FEATURE1_BUFSIZE];
3544734Sab196087 } Conv64_dyn_feature1_buf_t;
3554734Sab196087 
3564734Sab196087 
3574734Sab196087 /* conv_bnd_type() */
3585088Sab196087 #define	CONV_BND_TYPE_BASE_BUFSIZE	29
3594734Sab196087 #define	CONV32_BND_TYPE_BUFSIZE	\
3605088Sab196087 	(CONV_BND_TYPE_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3614734Sab196087 typedef union {
3624734Sab196087 	Conv32_inv_buf_t	inv_buf;
3634734Sab196087 	char			buf[CONV32_BND_TYPE_BUFSIZE];
3644734Sab196087 } Conv32_bnd_type_buf_t;
3654734Sab196087 
3664734Sab196087 #define	CONV64_BND_TYPE_BUFSIZE	\
3675088Sab196087 	(CONV_BND_TYPE_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3684734Sab196087 typedef union {
3694734Sab196087 	Conv64_inv_buf_t	inv_buf;
3704734Sab196087 	char			buf[CONV64_BND_TYPE_BUFSIZE];
3714734Sab196087 } Conv64_bnd_type_buf_t;
3724734Sab196087 
3734734Sab196087 
3744734Sab196087 /* conv_bnd_obj() */
3755088Sab196087 #define	CONV_BND_OBJ_BASE_BUFSIZE	38
3764734Sab196087 #define	CONV32_BND_OBJ_BUFSIZE	\
3775088Sab196087 	(CONV_BND_OBJ_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3784734Sab196087 typedef union {
3794734Sab196087 	Conv32_inv_buf_t	inv_buf;
3804734Sab196087 	char			buf[CONV32_BND_OBJ_BUFSIZE];
3814734Sab196087 } Conv32_bnd_obj_buf_t;
3824734Sab196087 
3834734Sab196087 #define	CONV64_BND_OBJ_BUFSIZE	\
3845088Sab196087 	(CONV_BND_OBJ_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
3854734Sab196087 typedef union {
3864734Sab196087 	Conv64_inv_buf_t	inv_buf;
3874734Sab196087 	char			buf[CONV64_BND_OBJ_BUFSIZE];
3884734Sab196087 } Conv64_bnd_obj_buf_t;
3894734Sab196087 
3904734Sab196087 
3914734Sab196087 /* conv_phdr_flags() */
3925088Sab196087 #define	CONV_PHDR_FLAGS_BASE_BUFSIZE	35
3934734Sab196087 #define	CONV32_PHDR_FLAGS_BUFSIZE	\
3945088Sab196087 	(CONV_PHDR_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
3954734Sab196087 typedef union {
3964734Sab196087 	Conv32_inv_buf_t	inv_buf;
3974734Sab196087 	char			buf[CONV32_PHDR_FLAGS_BUFSIZE];
3984734Sab196087 } Conv32_phdr_flags_buf_t;
3994734Sab196087 
4004734Sab196087 #define	CONV64_PHDR_FLAGS_BUFSIZE	\
4015088Sab196087 	(CONV_PHDR_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
4024734Sab196087 typedef union {
4034734Sab196087 	Conv64_inv_buf_t	inv_buf;
4044734Sab196087 	char			buf[CONV64_PHDR_FLAGS_BUFSIZE];
4054734Sab196087 } Conv64_phdr_flags_buf_t;
4064734Sab196087 
4074734Sab196087 
4084734Sab196087 /* conv_sec_flags() */
4095088Sab196087 #define	CONV_SEC_FLAGS_BASE_BUFSIZE	168
4104734Sab196087 #define	CONV32_SEC_FLAGS_BUFSIZE	\
4115088Sab196087 	(CONV_SEC_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
4124734Sab196087 typedef union {
4134734Sab196087 	Conv32_inv_buf_t	inv_buf;
4144734Sab196087 	char			buf[CONV32_SEC_FLAGS_BUFSIZE];
4154734Sab196087 } Conv32_sec_flags_buf_t;
4164734Sab196087 
4174734Sab196087 #define	CONV64_SEC_FLAGS_BUFSIZE	\
4185088Sab196087 	(CONV_SEC_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
4194734Sab196087 typedef union {
4204734Sab196087 	Conv64_inv_buf_t	inv_buf;
4214734Sab196087 	char			buf[CONV64_SEC_FLAGS_BUFSIZE];
4224734Sab196087 } Conv64_sec_flags_buf_t;
4234734Sab196087 
4244734Sab196087 
4254734Sab196087 /* conv_dwarf_ehe() */
4264734Sab196087 #define	CONV_DWARF_EHE_BUFSIZE		33
4274734Sab196087 typedef union {
4284734Sab196087 	Conv32_inv_buf_t	inv_buf;
4294734Sab196087 	char			buf[CONV_DWARF_EHE_BUFSIZE];
4304734Sab196087 } Conv32_dwarf_ehe_buf_t;
4314734Sab196087 typedef union {
4324734Sab196087 	Conv64_inv_buf_t	inv_buf;
4334734Sab196087 	char			buf[CONV_DWARF_EHE_BUFSIZE];
4344734Sab196087 } Conv64_dwarf_ehe_buf_t;
4354734Sab196087 
4364734Sab196087 
4375088Sab196087 /* conv_syminfo_flags() */
4385088Sab196087 #define	CONV_SYMINFO_FLAGS_BASE_BUFSIZE	36
4395088Sab196087 #define	CONV32_SYMINFO_FLAGS_BUFSIZE	\
4405088Sab196087 	(CONV_SYMINFO_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
4415088Sab196087 typedef union {
4425088Sab196087 	Conv32_inv_buf_t	inv_buf;
4435088Sab196087 	char			buf[CONV32_SYMINFO_FLAGS_BUFSIZE];
4445088Sab196087 } Conv32_syminfo_flags_buf_t;
4455088Sab196087 
4465088Sab196087 #define	CONV64_SYMINFO_FLAGS_BUFSIZE	\
4475088Sab196087 	(CONV_SYMINFO_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
4485088Sab196087 typedef union {
4495088Sab196087 	Conv64_inv_buf_t	inv_buf;
4505088Sab196087 	char			buf[CONV64_SYMINFO_FLAGS_BUFSIZE];
4515088Sab196087 } Conv64_syminfo_flags_buf_t;
4525088Sab196087 
4535088Sab196087 
454*6635Sab196087 /* conv_cnote_pr_flags() */
455*6635Sab196087 #define	CONV_CNOTE_PR_FLAGS_BUFSIZE	244
456*6635Sab196087 typedef union {
457*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
458*6635Sab196087 	char			buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
459*6635Sab196087 } Conv32_cnote_pr_flags_buf_t;
460*6635Sab196087 typedef union {
461*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
462*6635Sab196087 	char			buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
463*6635Sab196087 } Conv64_cnote_pr_flags_buf_t;
464*6635Sab196087 
465*6635Sab196087 
466*6635Sab196087 /* conv_cnote_old_pr_flags() */
467*6635Sab196087 #define	CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE	164
468*6635Sab196087 typedef union {
469*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
470*6635Sab196087 	char			buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
471*6635Sab196087 } Conv32_cnote_old_pr_flags_buf_t;
472*6635Sab196087 typedef union {
473*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
474*6635Sab196087 	char			buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
475*6635Sab196087 } Conv64_cnote_old_pr_flags_buf_t;
476*6635Sab196087 
477*6635Sab196087 
478*6635Sab196087 /* conv_cnote_proc_flag() */
479*6635Sab196087 #define	CONV_CNOTE_PROC_FLAG_BUFSIZE	29
480*6635Sab196087 typedef union {
481*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
482*6635Sab196087 	char			buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
483*6635Sab196087 } Conv32_cnote_proc_flag_buf_t;
484*6635Sab196087 typedef union {
485*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
486*6635Sab196087 	char			buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
487*6635Sab196087 } Conv64_cnote_proc_flag_buf_t;
488*6635Sab196087 
489*6635Sab196087 
490*6635Sab196087 /* conv_cnote_sigset() */
491*6635Sab196087 #define	CONV_CNOTE_SIGSET_BUFSIZE	629
492*6635Sab196087 typedef union {
493*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
494*6635Sab196087 	char			buf[CONV_CNOTE_SIGSET_BUFSIZE];
495*6635Sab196087 } Conv32_cnote_sigset_buf_t;
496*6635Sab196087 typedef union {
497*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
498*6635Sab196087 	char			buf[CONV_CNOTE_SIGSET_BUFSIZE];
499*6635Sab196087 } Conv64_cnote_sigset_buf_t;
500*6635Sab196087 
501*6635Sab196087 
502*6635Sab196087 /* conv_cnote_fltset() */
503*6635Sab196087 #define	CONV_CNOTE_FLTSET_BUFSIZE	501
504*6635Sab196087 typedef union {
505*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
506*6635Sab196087 	char			buf[CONV_CNOTE_FLTSET_BUFSIZE];
507*6635Sab196087 } Conv32_cnote_fltset_buf_t;
508*6635Sab196087 typedef union {
509*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
510*6635Sab196087 	char			buf[CONV_CNOTE_FLTSET_BUFSIZE];
511*6635Sab196087 } Conv64_cnote_fltset_buf_t;
512*6635Sab196087 
513*6635Sab196087 
514*6635Sab196087 /* conv_cnote_sysset() */
515*6635Sab196087 #define	CONV_CNOTE_SYSSET_BUFSIZE	3212
516*6635Sab196087 typedef union {
517*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
518*6635Sab196087 	char			buf[CONV_CNOTE_SYSSET_BUFSIZE];
519*6635Sab196087 } Conv32_cnote_sysset_buf_t;
520*6635Sab196087 typedef union {
521*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
522*6635Sab196087 	char			buf[CONV_CNOTE_SYSSET_BUFSIZE];
523*6635Sab196087 } Conv64_cnote_sysset_buf_t;
524*6635Sab196087 
525*6635Sab196087 
526*6635Sab196087 /* conv_cnote_sa_flags() */
527*6635Sab196087 #define	CONV_CNOTE_SA_FLAGS_BUFSIZE	99
528*6635Sab196087 typedef union {
529*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
530*6635Sab196087 	char			buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
531*6635Sab196087 } Conv32_cnote_sa_flags_buf_t;
532*6635Sab196087 typedef union {
533*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
534*6635Sab196087 	char			buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
535*6635Sab196087 } Conv64_cnote_sa_flags_buf_t;
536*6635Sab196087 
537*6635Sab196087 
538*6635Sab196087 /* conv_cnote_ss_flags() */
539*6635Sab196087 #define	CONV_CNOTE_SS_FLAGS_BUFSIZE	38
540*6635Sab196087 typedef union {
541*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
542*6635Sab196087 	char			buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
543*6635Sab196087 } Conv32_cnote_ss_flags_buf_t;
544*6635Sab196087 typedef union {
545*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
546*6635Sab196087 	char			buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
547*6635Sab196087 } Conv64_cnote_ss_flags_buf_t;
548*6635Sab196087 
549*6635Sab196087 
550*6635Sab196087 /* conv_cnote_cc_content() */
551*6635Sab196087 #define	CONV_CNOTE_CC_CONTENT_BUFSIZE	87
552*6635Sab196087 typedef union {
553*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
554*6635Sab196087 	char			buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
555*6635Sab196087 } Conv32_cnote_cc_content_buf_t;
556*6635Sab196087 typedef union {
557*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
558*6635Sab196087 	char			buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
559*6635Sab196087 } Conv64_cnote_cc_content_buf_t;
560*6635Sab196087 
561*6635Sab196087 
562*6635Sab196087 /* conv_cnote_auxv_af() */
563*6635Sab196087 #define	CONV_CNOTE_AUXV_AF_BUFSIZE	63
564*6635Sab196087 typedef union {
565*6635Sab196087 	Conv32_inv_buf_t	inv_buf;
566*6635Sab196087 	char			buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
567*6635Sab196087 } Conv32_cnote_auxv_af_buf_t;
568*6635Sab196087 typedef union {
569*6635Sab196087 	Conv64_inv_buf_t	inv_buf;
570*6635Sab196087 	char			buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
571*6635Sab196087 } Conv64_cnote_auxv_af_buf_t;
572*6635Sab196087 
573*6635Sab196087 
5744734Sab196087 
5754734Sab196087 /*
5764734Sab196087  * Generic names for class specific buffer types above
5771618Srie  */
5781618Srie #if	defined(_ELF64)
5794734Sab196087 #define	CONV_INV_BUFSIZE		CONV64_INV_BUFSIZE
5804734Sab196087 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV64_EHDR_FLAGS_BUFSIZE
5814734Sab196087 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV64_DYN_POSFLAG1_BUFSIZE
5824734Sab196087 #define	CONV_DYN_FLAG_BUFSIZE		CONV64_DYN_FLAG_BUFSIZE
5834734Sab196087 #define	CONV_DYN_FLAG1_BUFSIZE		CONV64_DYN_FLAG1_BUFSIZE
5844734Sab196087 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV64_DYN_FEATURE1_BUFSIZE
5854734Sab196087 #define	CONV_BND_TYPE_BUFSIZE		CONV64_BND_TYPE_BUFSIZE
5864734Sab196087 #define	CONV_BND_OBJ_BUFSIZE		CONV64_BND_OBJ_BUFSIZE
5874734Sab196087 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV64_PHDR_FLAGS_BUFSIZE
5884734Sab196087 #define	CONV_SEC_FLAGS_BUFSIZE		CONV64_SEC_FLAGS_BUFSIZE
5895088Sab196087 #define	CONV_SYMINFO_FLAGS_BUFSIZE	CONV64_SYMINFO_FLAGS_BUFSIZE
5904734Sab196087 
5914734Sab196087 #define	Conv_inv_buf_t			Conv64_inv_buf_t
5924734Sab196087 #define	Conv_ehdr_flags_buf_t		Conv64_ehdr_flags_buf_t
5934734Sab196087 #define	Conv_reject_desc_buf_t		Conv64_reject_desc_buf_t
5944734Sab196087 #define	Conv_cap_val_hw1_buf_t		Conv64_cap_val_hw1_buf_t
5954734Sab196087 #define	Conv_cap_val_sf1_buf_t		Conv64_cap_val_sf1_buf_t
5964734Sab196087 #define	Conv_cap_val_buf_t		Conv64_cap_val_buf_t
5974734Sab196087 #define	Conv_config_feat_buf_t		Conv64_config_feat_buf_t
5984734Sab196087 #define	Conv_config_obj_buf_t		Conv64_config_obj_buf_t
5994734Sab196087 #define	Conv_dl_mode_buf_t		Conv64_dl_mode_buf_t
6004734Sab196087 #define	Conv_dl_flag_buf_t		Conv64_dl_flag_buf_t
6014734Sab196087 #define	Conv_grphdl_flags_buf_t		Conv64_grphdl_flags_buf_t
6024734Sab196087 #define	Conv_grpdesc_flags_buf_t	Conv64_grpdesc_flags_buf_t
6034734Sab196087 #define	Conv_seg_flags_buf_t		Conv64_seg_flags_buf_t
6044734Sab196087 #define	Conv_dyn_posflag1_buf_t		Conv64_dyn_posflag1_buf_t
6054734Sab196087 #define	Conv_dyn_flag_buf_t		Conv64_dyn_flag_buf_t
6064734Sab196087 #define	Conv_dyn_flag1_buf_t		Conv64_dyn_flag1_buf_t
6074734Sab196087 #define	Conv_dyn_feature1_buf_t		Conv64_dyn_feature1_buf_t
6084734Sab196087 #define	Conv_bnd_type_buf_t		Conv64_bnd_type_buf_t
6094734Sab196087 #define	Conv_bnd_obj_buf_t		Conv64_bnd_obj_buf_t
6104734Sab196087 #define	Conv_phdr_flags_buf_t		Conv64_phdr_flags_buf_t
6114734Sab196087 #define	Conv_sec_flags_buf_t		Conv64_sec_flags_buf_t
6124734Sab196087 #define	Conv_dwarf_ehe_buf_t		Conv64_dwarf_ehe_buf_t
6135088Sab196087 #define	Conv_syminfo_flags_buf_t	Conv64_syminfo_flags_buf_t
614*6635Sab196087 #define	Conv_cnote_pr_flags_buf_t	Conv64_cnote_pr_flags_buf_t
615*6635Sab196087 #define	Conv_cnote_old_pr_flags_buf_t	Conv64_cnote_old_pr_flags_buf_t
616*6635Sab196087 #define	Conv_cnote_proc_flag_buf_t	Conv64_cnote_proc_flag_buf_t
617*6635Sab196087 #define	Conv_cnote_sigset_buf_t		Conv64_cnote_sigset_buf_t
618*6635Sab196087 #define	Conv_cnote_fltset_buf_t		Conv64_cnote_fltset_buf_t
619*6635Sab196087 #define	Conv_cnote_sysset_buf_t		Conv64_cnote_sysset_buf_t
620*6635Sab196087 #define	Conv_cnote_sa_flags_buf_t	Conv64_cnote_sa_flags_buf_t
621*6635Sab196087 #define	Conv_cnote_ss_flags_buf_t	Conv64_cnote_ss_flags_buf_t
622*6635Sab196087 #define	Conv_cnote_cc_content_buf_t	Conv64_cnote_cc_content_buf_t
623*6635Sab196087 #define	Conv_cnote_auxv_af_buf_t	Conv64_cnote_auxv_af_buf_t
6241618Srie #else
6254734Sab196087 #define	CONV_INV_BUFSIZE		CONV32_INV_BUFSIZE
6264734Sab196087 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV32_EHDR_FLAGS_BUFSIZE
6274734Sab196087 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV32_DYN_POSFLAG1_BUFSIZE
6284734Sab196087 #define	CONV_DYN_FLAG_BUFSIZE		CONV32_DYN_FLAG_BUFSIZE
6294734Sab196087 #define	CONV_DYN_FLAG1_BUFSIZE		CONV32_DYN_FLAG1_BUFSIZE
6304734Sab196087 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV32_DYN_FEATURE1_BUFSIZE
6314734Sab196087 #define	CONV_BND_TYPE_BUFSIZE		CONV32_BND_TYPE_BUFSIZE
6324734Sab196087 #define	CONV_BND_OBJ_BUFSIZE		CONV32_BND_OBJ_BUFSIZE
6334734Sab196087 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV32_PHDR_FLAGS_BUFSIZE
6344734Sab196087 #define	CONV_SEC_FLAGS_BUFSIZE		CONV32_SEC_FLAGS_BUFSIZE
6355088Sab196087 #define	CONV_SYMINFO_FLAGS_BUFSIZE	CONV32_SYMINFO_FLAGS_BUFSIZE
6364734Sab196087 
6374734Sab196087 #define	Conv_inv_buf_t			Conv32_inv_buf_t
6384734Sab196087 #define	Conv_ehdr_flags_buf_t		Conv32_ehdr_flags_buf_t
6394734Sab196087 #define	Conv_reject_desc_buf_t		Conv32_reject_desc_buf_t
6404734Sab196087 #define	Conv_cap_val_hw1_buf_t		Conv32_cap_val_hw1_buf_t
6414734Sab196087 #define	Conv_cap_val_sf1_buf_t		Conv32_cap_val_sf1_buf_t
6424734Sab196087 #define	Conv_cap_val_buf_t		Conv32_cap_val_buf_t
6434734Sab196087 #define	Conv_config_feat_buf_t		Conv32_config_feat_buf_t
6444734Sab196087 #define	Conv_config_obj_buf_t		Conv32_config_obj_buf_t
6454734Sab196087 #define	Conv_dl_mode_buf_t		Conv32_dl_mode_buf_t
6464734Sab196087 #define	Conv_dl_flag_buf_t		Conv32_dl_flag_buf_t
6474734Sab196087 #define	Conv_grphdl_flags_buf_t		Conv32_grphdl_flags_buf_t
6484734Sab196087 #define	Conv_grpdesc_flags_buf_t	Conv32_grpdesc_flags_buf_t
6494734Sab196087 #define	Conv_seg_flags_buf_t		Conv32_seg_flags_buf_t
6504734Sab196087 #define	Conv_dyn_posflag1_buf_t		Conv32_dyn_posflag1_buf_t
6514734Sab196087 #define	Conv_dyn_flag_buf_t		Conv32_dyn_flag_buf_t
6524734Sab196087 #define	Conv_dyn_flag1_buf_t		Conv32_dyn_flag1_buf_t
6534734Sab196087 #define	Conv_dyn_feature1_buf_t		Conv32_dyn_feature1_buf_t
6544734Sab196087 #define	Conv_bnd_type_buf_t		Conv32_bnd_type_buf_t
6554734Sab196087 #define	Conv_bnd_obj_buf_t		Conv32_bnd_obj_buf_t
6564734Sab196087 #define	Conv_phdr_flags_buf_t		Conv32_phdr_flags_buf_t
6574734Sab196087 #define	Conv_sec_flags_buf_t		Conv32_sec_flags_buf_t
6584734Sab196087 #define	Conv_dwarf_ehe_buf_t		Conv32_dwarf_ehe_buf_t
6595088Sab196087 #define	Conv_syminfo_flags_buf_t	Conv32_syminfo_flags_buf_t
660*6635Sab196087 #define	Conv_cnote_pr_flags_buf_t	Conv32_cnote_pr_flags_buf_t
661*6635Sab196087 #define	Conv_cnote_old_pr_flags_buf_t	Conv32_cnote_old_pr_flags_buf_t
662*6635Sab196087 #define	Conv_cnote_proc_flag_buf_t	Conv32_cnote_proc_flag_buf_t
663*6635Sab196087 #define	Conv_cnote_sigset_buf_t		Conv32_cnote_sigset_buf_t
664*6635Sab196087 #define	Conv_cnote_fltset_buf_t		Conv32_cnote_fltset_buf_t
665*6635Sab196087 #define	Conv_cnote_sysset_buf_t		Conv32_cnote_sysset_buf_t
666*6635Sab196087 #define	Conv_cnote_sa_flags_buf_t	Conv32_cnote_sa_flags_buf_t
667*6635Sab196087 #define	Conv_cnote_ss_flags_buf_t	Conv32_cnote_ss_flags_buf_t
668*6635Sab196087 #define	Conv_cnote_cc_content_buf_t	Conv32_cnote_cc_content_buf_t
669*6635Sab196087 #define	Conv_cnote_auxv_af_buf_t	Conv32_cnote_auxv_af_buf_t
6701618Srie #endif
6711618Srie 
6724734Sab196087 
6734734Sab196087 
6742850Srie 
6752850Srie /*
6765088Sab196087  * Many conversion routines accept a fmt_flags argument of this type
6775088Sab196087  * to allow the caller to modify the output. There are two parts to
6785088Sab196087  * this value:
6795088Sab196087  *
6805088Sab196087  *	(1) Format requests (decimal vs hex, etc...)
6815088Sab196087  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
6825088Sab196087  *		and retrieved by CONV_TYPE_FMT_ALT are integer
6835088Sab196087  *		values that specify that an alternate set of
6845088Sab196087  *		strings should be used. This is necessary because
6855088Sab196087  *		different utilities evolved to use different strings,
6865088Sab196087  *		and there are backward compatability guarantees in
6875088Sab196087  *		place that prevent changing them.
6885088Sab196087  *
6895088Sab196087  * These values are designed such that a caller can always supply a
6905088Sab196087  * simple 0 in order to receive "default" behavior.
6911618Srie  */
6925088Sab196087 typedef int Conv_fmt_flags_t;
6935088Sab196087 
6945088Sab196087 /*
6955088Sab196087  * The bottom 8 bits of Conv_fmt_flags_t are used to encode
6965088Sab196087  * alternative strings.
6975088Sab196087  *
6985088Sab196087  * If a given conversion routine does not support alternative strings
6995088Sab196087  * for a given CONV_FMT_ALT type, it silently ignores the request and
7005088Sab196087  * supplies the default set. This means that a utility like dump(1) is
7015088Sab196087  * free to specify its special type in every conversion routine call,
7025088Sab196087  * without regard to whether it has any special meaning for that particular
7035088Sab196087  * routine. It will receive its special strings if there are any, and
7045088Sab196087  * the defaults otherwise.
7055088Sab196087  */
7065088Sab196087 #define	CONV_MASK_FMT_ALT		0xff
7075088Sab196087 #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
7085088Sab196087 
7095088Sab196087 #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
7105088Sab196087 #define	CONV_FMT_ALT_DUMP	1	/* Style of strings used by dump(1) */
7115088Sab196087 #define	CONV_FMT_ALT_FILE	2	/* Style of strings used by file(1) */
7125088Sab196087 #define	CONV_FMT_ALT_CRLE	3	/* Style of strings used by crle(1) */
7135088Sab196087 #define	CONV_FMT_ALT_FULLNAME	4	/* Strings should be full #define */
7145088Sab196087 					/* 	(e.g. STB_LOCAL, not LOCL) */
7155088Sab196087 
7165088Sab196087 /*
7175088Sab196087  * Flags that alter standard formatting for conversion routines.
7185088Sab196087  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
7195088Sab196087  */
7205088Sab196087 #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
7211976Sab196087 					/*    integer print as decimal */
7221976Sab196087 					/*    (default is hex) */
7235088Sab196087 #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
7241976Sab196087 					/*    a space after the number.  */
7255088Sab196087 #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
7265088Sab196087 					/*    prefix and suffix strings */
7271976Sab196087 
7281618Srie 
7291618Srie /*
7301618Srie  * The expansion of bit-field data items is driven from a value descriptor and
7311618Srie  * the conv_expn_field() routine.
7321618Srie  */
7331618Srie typedef struct {
7341618Srie 	Xword		v_val;		/* expansion value */
7351618Srie 	const char	*v_msg;		/* associated message string */
7361618Srie } Val_desc;
7371618Srie 
7381618Srie /*
7392352Sab196087  * conv_expn_field() is willing to supply default strings for the
7402352Sab196087  * prefix, separator, and suffix arguments, if they are passed as NULL.
7412352Sab196087  * The caller needs to know how much room to allow for these items.
7422352Sab196087  * These values supply those sizes.
7432352Sab196087  */
7442352Sab196087 #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
7452352Sab196087 #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
7462352Sab196087 #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
7472352Sab196087 
7482352Sab196087 /*
7492352Sab196087  * conv_expn_field() requires a large number of inputs, many of which
7502352Sab196087  * can be NULL to accept default behavior. An argument of the following
7512352Sab196087  * type is used to supply them.
7522352Sab196087  */
7532352Sab196087 typedef struct {
7542352Sab196087 	char *buf;		/* Buffer to receive generated string */
7552352Sab196087 	size_t bufsize;		/* sizeof(buf) */
7562352Sab196087 	const Val_desc *vdp;	/* Array of value descriptors, giving the */
7572352Sab196087 				/*	possible bit values, and their */
7582352Sab196087 				/*	corresponding strings. Note that the */
7592352Sab196087 				/*	final element must contain only NULL */
7602352Sab196087 				/*	values. This terminates the list. */
7612352Sab196087 	const char **lead_str;	/* NULL, or array of pointers to strings to */
7622352Sab196087 				/*	be output at the head of the list. */
7632352Sab196087 				/*	Last entry must be NULL. */
7642352Sab196087 	Xword oflags;		/* Bits for which output strings are desired */
7652352Sab196087 	Xword rflags;		/* Bits for which a numeric value should be */
7662352Sab196087 				/*	output if vdp does not provide str. */
7672352Sab196087 				/*	Must be a proper subset of oflags */
7682352Sab196087 	const char *prefix;	/* NULL, or string to prefix output with */
7692352Sab196087 				/*	If NULL, "[ " is used. */
7702352Sab196087 	const char *sep;	/* NULL, or string to separate output items */
7712352Sab196087 				/*	with. If NULL, " " is used. */
7722352Sab196087 	const char *suffix;	/* NULL, or string to suffix output with */
7732352Sab196087 				/*	If NULL, " ]" is used. */
7742352Sab196087 } CONV_EXPN_FIELD_ARG;
7752352Sab196087 
776*6635Sab196087 
777*6635Sab196087 /*
778*6635Sab196087  * Callback function for conv_str_to_c_literal(). A user supplied function
779*6635Sab196087  * of this type is called by conv_str_to_c_literal() in order to dispatch
780*6635Sab196087  * the translated output characters.
781*6635Sab196087  *
782*6635Sab196087  *	buf - Pointer to output text
783*6635Sab196087  *	n - # of characters to output
784*6635Sab196087  *	uvalue - User value argument to conv_str_to_c_literal(),
785*6635Sab196087  *		passed through without interpretation.
786*6635Sab196087  */
787*6635Sab196087 typedef	void		Conv_str_to_c_literal_func_t(const void *ptr,
788*6635Sab196087 			    size_t size, void *uvalue);
789*6635Sab196087 
7902352Sab196087 /*
7911618Srie  * Define all generic interfaces.
7920Sstevel@tonic-gate  */
7932647Srie extern	uchar_t		conv_check_native(char **, char **);
7944734Sab196087 extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
7954734Sab196087 extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
7961618Srie extern	const char	*conv_config_upm(const char *, const char *,
7971618Srie 			    const char *, size_t);
798*6635Sab196087 extern	const char	*conv_cnote_auxv_af(Word, Conv_fmt_flags_t,
799*6635Sab196087 			    Conv_cnote_auxv_af_buf_t *);
800*6635Sab196087 extern	const char	*conv_cnote_auxv_type(Word, Conv_fmt_flags_t,
801*6635Sab196087 			    Conv_inv_buf_t *);
802*6635Sab196087 extern	const char	*conv_cnote_cc_content(Lword, Conv_fmt_flags_t,
803*6635Sab196087 			    Conv_cnote_cc_content_buf_t *);
804*6635Sab196087 extern	const char	*conv_cnote_errno(int, Conv_fmt_flags_t,
805*6635Sab196087 			    Conv_inv_buf_t *);
806*6635Sab196087 extern	const char	*conv_cnote_fault(Word, Conv_fmt_flags_t,
807*6635Sab196087 			    Conv_inv_buf_t *);
808*6635Sab196087 extern	const char	*conv_cnote_fltset(uint32_t *, int,
809*6635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *);
810*6635Sab196087 extern	const char	*conv_cnote_old_pr_flags(int, Conv_fmt_flags_t,
811*6635Sab196087 			    Conv_cnote_old_pr_flags_buf_t *);
812*6635Sab196087 extern	const char	*conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t,
813*6635Sab196087 			    Conv_inv_buf_t *);
814*6635Sab196087 extern	const char	*conv_cnote_pr_flags(int, Conv_fmt_flags_t,
815*6635Sab196087 			    Conv_cnote_pr_flags_buf_t *);
816*6635Sab196087 extern	const char	*conv_cnote_proc_flag(int, Conv_fmt_flags_t,
817*6635Sab196087 			    Conv_cnote_proc_flag_buf_t *);
818*6635Sab196087 extern	const char	*conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t,
819*6635Sab196087 			    Conv_inv_buf_t *inv_buf);
820*6635Sab196087 extern	const char	*conv_cnote_pr_stype(Word, Conv_fmt_flags_t,
821*6635Sab196087 			    Conv_inv_buf_t *);
822*6635Sab196087 extern	const char	*conv_cnote_pr_what(short, short, Conv_fmt_flags_t,
823*6635Sab196087 			    Conv_inv_buf_t *);
824*6635Sab196087 extern	const char	*conv_cnote_pr_why(short, Conv_fmt_flags_t,
825*6635Sab196087 			    Conv_inv_buf_t *);
826*6635Sab196087 extern	const char	*conv_cnote_priv(int, Conv_fmt_flags_t,
827*6635Sab196087 			    Conv_inv_buf_t *);
828*6635Sab196087 extern	const char	*conv_cnote_psetid(int, Conv_fmt_flags_t,
829*6635Sab196087 			    Conv_inv_buf_t *);
830*6635Sab196087 extern	const char	*conv_cnote_sa_flags(int, Conv_fmt_flags_t,
831*6635Sab196087 			    Conv_cnote_sa_flags_buf_t *);
832*6635Sab196087 extern	const char	*conv_cnote_signal(Word, Conv_fmt_flags_t,
833*6635Sab196087 			    Conv_inv_buf_t *);
834*6635Sab196087 extern	const char	*conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t,
835*6635Sab196087 			    Conv_inv_buf_t *);
836*6635Sab196087 extern	const char	*conv_cnote_sigset(uint32_t *, int,
837*6635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *);
838*6635Sab196087 extern	const char	*conv_cnote_ss_flags(int, Conv_fmt_flags_t,
839*6635Sab196087 			    Conv_cnote_ss_flags_buf_t *);
840*6635Sab196087 extern	const char	*conv_cnote_syscall(Word, Conv_fmt_flags_t,
841*6635Sab196087 			    Conv_inv_buf_t *);
842*6635Sab196087 extern	const char	*conv_cnote_sysset(uint32_t *, int,
843*6635Sab196087 			    Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
844*6635Sab196087 extern	const char	*conv_cnote_type(Word, Conv_fmt_flags_t,
845*6635Sab196087 			    Conv_inv_buf_t *);
8464734Sab196087 extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
8471618Srie extern	const char	*conv_demangle_name(const char *);
8485088Sab196087 extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
8495088Sab196087 			    Conv_dl_flag_buf_t *);
8504734Sab196087 extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
8514734Sab196087 extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
8524734Sab196087 extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
8534734Sab196087 extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
8544734Sab196087 extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
8550Sstevel@tonic-gate extern	Isa_desc	*conv_isalist(void);
8560Sstevel@tonic-gate extern	const char	*conv_lddstub(int);
8574734Sab196087 extern	const char	*conv_seg_flags(Half, Conv_seg_flags_buf_t *);
8580Sstevel@tonic-gate extern	int		conv_sys_eclass();
859*6635Sab196087 extern	void		conv_str_to_c_literal(const char *buf, size_t n,
860*6635Sab196087 			    Conv_str_to_c_literal_func_t *cb_func,
861*6635Sab196087 			    void *uvalue);
8620Sstevel@tonic-gate extern	Uts_desc	*conv_uts(void);
8631618Srie extern	const char	*conv_ver_flags(Half);
8644734Sab196087 extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
8654734Sab196087 
8661618Srie 
8671618Srie /*
8681618Srie  * Define all class specific routines.
8691618Srie  */
8701618Srie #if	defined(_ELF64)
8711618Srie #define	conv_bnd_obj		conv64_bnd_obj
8721618Srie #define	conv_bnd_type		conv64_bnd_type
8731618Srie #define	conv_cap_tag		conv64_cap_tag
8741618Srie #define	conv_cap_val		conv64_cap_val
8751618Srie #define	conv_cap_val_hw1	conv64_cap_val_hw1
8761618Srie #define	conv_cap_val_sf1	conv64_cap_val_sf1
8771618Srie #define	conv_dyn_feature1	conv64_dyn_feature1
8781618Srie #define	conv_dyn_flag1		conv64_dyn_flag1
8791618Srie #define	conv_dyn_flag		conv64_dyn_flag
8801618Srie #define	conv_dyn_posflag1	conv64_dyn_posflag1
8811618Srie #define	conv_dyn_tag		conv64_dyn_tag
8821618Srie #define	conv_ehdr_class		conv64_ehdr_class
8831618Srie #define	conv_ehdr_data		conv64_ehdr_data
8841618Srie #define	conv_ehdr_flags		conv64_ehdr_flags
8851618Srie #define	conv_ehdr_mach		conv64_ehdr_mach
8863850Sab196087 #define	conv_ehdr_osabi		conv64_ehdr_osabi
8871618Srie #define	conv_ehdr_type		conv64_ehdr_type
8881618Srie #define	conv_ehdr_vers		conv64_ehdr_vers
8891618Srie #define	conv_expn_field		conv64_expn_field
8901618Srie #define	conv_invalid_val	conv64_invalid_val
8911618Srie #define	conv_phdr_flags		conv64_phdr_flags
8921618Srie #define	conv_phdr_type		conv64_phdr_type
8931618Srie #define	conv_reject_desc	conv64_reject_desc
8941618Srie #define	conv_reloc_type		conv64_reloc_type
8954734Sab196087 #define	conv_reloc_type_static	conv64_reloc_type_static
8961618Srie #define	conv_reloc_386_type	conv64_reloc_386_type
8971618Srie #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
8981618Srie #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
8991618Srie #define	conv_sec_flags		conv64_sec_flags
9002647Srie #define	conv_sec_linkinfo	conv64_sec_linkinfo
9011618Srie #define	conv_sec_type		conv64_sec_type
9021618Srie #define	conv_sym_info_bind	conv64_sym_info_bind
9031618Srie #define	conv_sym_info_type	conv64_sym_info_type
9041618Srie #define	conv_sym_shndx		conv64_sym_shndx
9051618Srie #define	conv_sym_other		conv64_sym_other
9065088Sab196087 #define	conv_sym_other_vis	conv64_sym_other_vis
9071618Srie #define	conv_sym_value		conv64_sym_value
9081618Srie #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
9095088Sab196087 #define	conv_syminfo_flags	conv64_syminfo_flags
9101618Srie #else
9111618Srie #define	conv_bnd_obj		conv32_bnd_obj
9121618Srie #define	conv_bnd_type		conv32_bnd_type
9131618Srie #define	conv_cap_tag		conv32_cap_tag
9141618Srie #define	conv_cap_val		conv32_cap_val
9151618Srie #define	conv_cap_val_hw1	conv32_cap_val_hw1
9161618Srie #define	conv_cap_val_sf1	conv32_cap_val_sf1
9171618Srie #define	conv_dyn_feature1	conv32_dyn_feature1
9181618Srie #define	conv_dyn_flag1		conv32_dyn_flag1
9191618Srie #define	conv_dyn_flag		conv32_dyn_flag
9201618Srie #define	conv_dyn_posflag1	conv32_dyn_posflag1
9211618Srie #define	conv_dyn_tag		conv32_dyn_tag
9221618Srie #define	conv_ehdr_class		conv32_ehdr_class
9231618Srie #define	conv_ehdr_data		conv32_ehdr_data
9241618Srie #define	conv_ehdr_flags		conv32_ehdr_flags
9251618Srie #define	conv_ehdr_mach		conv32_ehdr_mach
9263850Sab196087 #define	conv_ehdr_osabi		conv32_ehdr_osabi
9271618Srie #define	conv_ehdr_type		conv32_ehdr_type
9281618Srie #define	conv_ehdr_vers		conv32_ehdr_vers
9291618Srie #define	conv_expn_field		conv32_expn_field
9301618Srie #define	conv_invalid_val	conv32_invalid_val
9311618Srie #define	conv_phdr_flags		conv32_phdr_flags
9321618Srie #define	conv_phdr_type		conv32_phdr_type
9331618Srie #define	conv_reject_desc	conv32_reject_desc
9341618Srie #define	conv_reloc_type		conv32_reloc_type
9354734Sab196087 #define	conv_reloc_type_static	conv32_reloc_type_static
9361618Srie #define	conv_reloc_386_type	conv32_reloc_386_type
9371618Srie #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
9381618Srie #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
9391618Srie #define	conv_sec_flags		conv32_sec_flags
9402647Srie #define	conv_sec_linkinfo	conv32_sec_linkinfo
9411618Srie #define	conv_sec_type		conv32_sec_type
9421618Srie #define	conv_sym_info_bind	conv32_sym_info_bind
9431618Srie #define	conv_sym_info_type	conv32_sym_info_type
9441618Srie #define	conv_sym_shndx		conv32_sym_shndx
9451618Srie #define	conv_sym_other		conv32_sym_other
9465088Sab196087 #define	conv_sym_other_vis	conv32_sym_other_vis
9471618Srie #define	conv_sym_value		conv32_sym_value
9481618Srie #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
9495088Sab196087 #define	conv_syminfo_flags	conv32_syminfo_flags
9501618Srie #endif
9511618Srie 
9524734Sab196087 extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
9534734Sab196087 extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
9544734Sab196087 extern	const char	*conv_cap_tag(Xword, Conv_inv_buf_t *);
9554734Sab196087 extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *);
9565088Sab196087 extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
9574734Sab196087 			    Conv_cap_val_hw1_buf_t *);
9585088Sab196087 extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
9594734Sab196087 			    Conv_cap_val_sf1_buf_t *);
9605088Sab196087 extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
9615088Sab196087 			    Conv_dyn_flag1_buf_t *);
9625088Sab196087 extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
9635088Sab196087 			    Conv_dyn_flag_buf_t *);
9645088Sab196087 extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
9654734Sab196087 			    Conv_dyn_posflag1_buf_t *);
9665088Sab196087 extern	const char	*conv_dyn_tag(Xword, Half, Conv_fmt_flags_t,
9675088Sab196087 			    Conv_inv_buf_t *);
9685088Sab196087 extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
9694734Sab196087 			    Conv_dyn_feature1_buf_t *);
9705088Sab196087 extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
9715088Sab196087 			    Conv_inv_buf_t *);
9725088Sab196087 extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
9735088Sab196087 			    Conv_inv_buf_t *);
9745088Sab196087 extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
9755088Sab196087 			    Conv_ehdr_flags_buf_t *);
9765088Sab196087 extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
9775088Sab196087 			    Conv_inv_buf_t *);
9785088Sab196087 extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
9795088Sab196087 			    Conv_inv_buf_t *);
9805088Sab196087 extern	const char	*conv_ehdr_type(Half, Conv_fmt_flags_t,
9815088Sab196087 			    Conv_inv_buf_t *);
9825088Sab196087 extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
9835088Sab196087 			    Conv_inv_buf_t *);
9845088Sab196087 extern	int		conv_expn_field(CONV_EXPN_FIELD_ARG *,
9855088Sab196087 			    Conv_fmt_flags_t);
9865088Sab196087 extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
9875088Sab196087 			    Conv_fmt_flags_t);
9885088Sab196087 extern	const char	*conv_phdr_flags(Word, Conv_fmt_flags_t fmt_flags,
9895088Sab196087 			    Conv_phdr_flags_buf_t *);
9905088Sab196087 extern	const char	*conv_phdr_type(Half, Word, Conv_fmt_flags_t,
9915088Sab196087 			    Conv_inv_buf_t *);
9926206Sab196087 extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *,
9936206Sab196087 			    Half mach);
9945088Sab196087 extern	const char	*conv_reloc_type(Half, Word, Conv_fmt_flags_t,
9955088Sab196087 			    Conv_inv_buf_t *);
9965088Sab196087 extern	const char	*conv_reloc_type_static(Half, Word, Conv_fmt_flags_t);
9975088Sab196087 extern	const char	*conv_reloc_386_type(Word, Conv_fmt_flags_t,
9985088Sab196087 			    Conv_inv_buf_t *);
9995088Sab196087 extern	const char	*conv_reloc_amd64_type(Word, Conv_fmt_flags_t,
10005088Sab196087 			    Conv_inv_buf_t *);
10015088Sab196087 extern	const char	*conv_reloc_SPARC_type(Word, Conv_fmt_flags_t,
10025088Sab196087 			    Conv_inv_buf_t *);
10035088Sab196087 extern	const char	*conv_sec_flags(Xword, Conv_fmt_flags_t,
10045088Sab196087 			    Conv_sec_flags_buf_t *);
10054734Sab196087 extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
10065088Sab196087 extern	const char	*conv_sec_type(Half, Word, Conv_fmt_flags_t,
10075088Sab196087 			    Conv_inv_buf_t *);
10085088Sab196087 extern	const char	*conv_sym_info_bind(uchar_t, Conv_fmt_flags_t,
10095088Sab196087 			    Conv_inv_buf_t *);
10105088Sab196087 extern	const char	*conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t,
10114734Sab196087 			    Conv_inv_buf_t *);
10124734Sab196087 extern	const char	*conv_sym_shndx(Half, Conv_inv_buf_t *);
10134734Sab196087 extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
10145088Sab196087 extern	const char	*conv_sym_other_vis(uchar_t, Conv_fmt_flags_t,
10155088Sab196087 			    Conv_inv_buf_t *);
10164734Sab196087 extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
10175088Sab196087 extern	const char	*conv_sym_SPARC_value(Addr, Conv_fmt_flags_t,
10185088Sab196087 			    Conv_inv_buf_t *);
1019*6635Sab196087 extern	const char	*conv_syminfo_flags(Xword, Conv_fmt_flags_t,
1020*6635Sab196087 			    Conv_syminfo_flags_buf_t *);
10210Sstevel@tonic-gate 
10220Sstevel@tonic-gate #ifdef	__cplusplus
10230Sstevel@tonic-gate }
10240Sstevel@tonic-gate #endif
10250Sstevel@tonic-gate 
10260Sstevel@tonic-gate #endif /* _CONV_H */
1027