xref: /illumos-gate/usr/src/cmd/sgs/include/conv.h (revision 56726c7e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55aefb655Srie  * Common Development and Distribution License (the "License").
65aefb655Srie  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215aefb655Srie 
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  *	Copyright (c) 1988 AT&T
247c478bd9Sstevel@tonic-gate  *	  All Rights Reserved
257c478bd9Sstevel@tonic-gate  *
26f441771bSRod Evans  * Copyright (c) 1992, 2010, Oracle and/or its affiliates. All rights reserved.
2734bdffbfSGarrett D'Amore  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
28161294feSRobert Mustacchi  * Copyright (c) 2018, Joyent, Inc.
2982201043SAndrew Stormont  * Copyright 2016 RackTop Systems.
30*56726c7eSRobert Mustacchi  * Copyright 2022 Oxide Computer Company
317c478bd9Sstevel@tonic-gate  */
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifndef	_CONV_H
347c478bd9Sstevel@tonic-gate #define	_CONV_H
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * Global include file for conversion library.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate #include <stdlib.h>
417c478bd9Sstevel@tonic-gate #include <libelf.h>
427c478bd9Sstevel@tonic-gate #include <dlfcn.h>
437c478bd9Sstevel@tonic-gate #include <libld.h>
447c478bd9Sstevel@tonic-gate #include <sgs.h>
454f680cc6SAli Bahrami #include <sgsmsg.h>
46d2a70789SRichard Lowe #include <sys/secflags.h>
47d2a70789SRichard Lowe 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Configuration features available - maintained here (instead of debug.h)
547c478bd9Sstevel@tonic-gate  * to save libconv from having to include debug.h which results in numerous
557c478bd9Sstevel@tonic-gate  * "declared but not used or defined" lint errors.
56fec04708SRichard Lowe  *
57fec04708SRichard Lowe  * AOUT flags (ADLIBPATH, ASLIBPATH) are unused, but retained so they may
58fec04708SRichard Lowe  * still be fully dumped under LD_DEBUG.
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
617c478bd9Sstevel@tonic-gate #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
627c478bd9Sstevel@tonic-gate #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
637c478bd9Sstevel@tonic-gate #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
647c478bd9Sstevel@tonic-gate #define	CONF_DIRCFG	0x001000	/* directory configuration available */
657c478bd9Sstevel@tonic-gate #define	CONF_OBJALT	0x002000	/* object alternatives available */
667c478bd9Sstevel@tonic-gate #define	CONF_MEMRESV	0x004000	/* memory reservation required */
677c478bd9Sstevel@tonic-gate #define	CONF_ENVS	0x008000	/* environment variables available */
687c478bd9Sstevel@tonic-gate #define	CONF_FLTR	0x010000	/* filter information available */
697c478bd9Sstevel@tonic-gate #define	CONF_FEATMSK	0xffff00
707c478bd9Sstevel@tonic-gate 
71e23c41c9SAli Bahrami 
72e23c41c9SAli Bahrami /*
73e23c41c9SAli Bahrami  * Valid flags for conv_strproc_extract_value().
74e23c41c9SAli Bahrami  */
75e23c41c9SAli Bahrami #define	CONV_SPEXV_F_NOTRIM	0x0001	/* Do not trim whitespace around '=' */
76e23c41c9SAli Bahrami #define	CONV_SPEXV_F_UCASE	0x0002	/* Convert value to uppercase */
77e23c41c9SAli Bahrami #define	CONV_SPEXV_F_NULLOK	0x0004	 /* Empty ("") value is OK */
78e23c41c9SAli Bahrami 
797c478bd9Sstevel@tonic-gate /*
80de777a60Sab  * Buffer types:
81de777a60Sab  *
82de777a60Sab  * Many of the routines in this module require the user to supply a
83de777a60Sab  * buffer into which the desired strings may be written. These are
84de777a60Sab  * all arrays of characters, and might be defined as simple arrays
85de777a60Sab  * of char. The problem with that approach is that when such an array
86de777a60Sab  * is passed to a function, the C language considers it to have the
87de777a60Sab  * type (char *), without any regard to its length. Not all of our
88de777a60Sab  * buffers have the same length, and we want to ensure that the compiler
89de777a60Sab  * will refuse to compile code that passes the wrong type of buffer to
90de777a60Sab  * a given routine. The solution is to define the buffers as unions
91de777a60Sab  * that contain the needed array, and then to pass the given union
92de777a60Sab  * by address. The compiler will catch attempts to pass the wrong type
93de777a60Sab  * of pointer, and the size of a structure/union is implicit in its type.
94de777a60Sab  *
95de777a60Sab  * A nice side effect of this approach is that we can use a union with
96de777a60Sab  * multiple buffers to handle the cases where a given routine needs
97de777a60Sab  * more than one type of buffer. The end result is a single buffer large
98de777a60Sab  * enough to handle any of the subcases, but no larger.
99de777a60Sab  */
100de777a60Sab 
101de777a60Sab /*
102de777a60Sab  * Size of buffer used by conv_invalid_val():
103de777a60Sab  *
1045aefb655Srie  * Various values that can't be matched to a symbolic definition are converted
105de777a60Sab  * to a numeric string.
1065aefb655Srie  *
107de777a60Sab  * The buffer size reflects the maximum number of digits needed to
108de777a60Sab  * display an integer as text, plus a trailing null, and with room for
109de777a60Sab  * a leading "0x" if hexidecimal display is selected.
1104f680cc6SAli Bahrami  *
1114f680cc6SAli Bahrami  * The 32-bit version of this requires 12 characters, and the 64-bit version
1124f680cc6SAli Bahrami  * needs 22. By using the larger value for both, we can have a single
1134f680cc6SAli Bahrami  * definition, which is necessary for code that is ELFCLASS independent. A
1144f680cc6SAli Bahrami  * nice side benefit is that it lets us dispense with a large number of 32/64
1154f680cc6SAli Bahrami  * buffer size definitions that build off CONV_INV_BUFSIZE, and the macros
1164f680cc6SAli Bahrami  * that would then be needed.
117de777a60Sab  */
1184f680cc6SAli Bahrami #define	CONV_INV_BUFSIZE		22
119de777a60Sab typedef union {
1204f680cc6SAli Bahrami 	char				buf[CONV_INV_BUFSIZE];
1214f680cc6SAli Bahrami } Conv_inv_buf_t;
122de777a60Sab 
123de777a60Sab /* conv_ehdr_flags() */
1244f680cc6SAli Bahrami #define	CONV_EHDR_FLAGS_BUFSIZE		91
125de777a60Sab typedef union {
1264f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
1274f680cc6SAli Bahrami 	char				buf[CONV_EHDR_FLAGS_BUFSIZE];
1284f680cc6SAli Bahrami } Conv_ehdr_flags_buf_t;
129de777a60Sab 
130de777a60Sab /* conv_reject_desc() */
131de777a60Sab typedef union {
1324f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
1334f680cc6SAli Bahrami 	Conv_ehdr_flags_buf_t		flags_buf;
1344f680cc6SAli Bahrami } Conv_reject_desc_buf_t;
135de777a60Sab 
1362020b2b6SRod Evans /*
1372020b2b6SRod Evans  * conv_la_bind()
1382020b2b6SRod Evans  */
1392020b2b6SRod Evans #define	CONV_LA_BIND_BUFSIZE		56
1402020b2b6SRod Evans typedef union {
1412020b2b6SRod Evans 	Conv_inv_buf_t			inv_buf;
1422020b2b6SRod Evans 	char				buf[CONV_LA_BIND_BUFSIZE];
1432020b2b6SRod Evans } Conv_la_bind_buf_t;
1442020b2b6SRod Evans 
1452020b2b6SRod Evans /*
1462020b2b6SRod Evans  * conv_la_search()
1472020b2b6SRod Evans  */
1482020b2b6SRod Evans #define	CONV_LA_SEARCH_BUFSIZE		111
1492020b2b6SRod Evans typedef union {
1502020b2b6SRod Evans 	Conv_inv_buf_t			inv_buf;
1512020b2b6SRod Evans 	char				buf[CONV_LA_SEARCH_BUFSIZE];
1522020b2b6SRod Evans } Conv_la_search_buf_t;
1532020b2b6SRod Evans 
1542020b2b6SRod Evans /*
1552020b2b6SRod Evans  * conv_la_symbind()
1562020b2b6SRod Evans  */
1572020b2b6SRod Evans #define	CONV_LA_SYMBIND_BUFSIZE		113
1582020b2b6SRod Evans typedef union {
1592020b2b6SRod Evans 	Conv_inv_buf_t			inv_buf;
1602020b2b6SRod Evans 	char				buf[CONV_LA_SYMBIND_BUFSIZE];
1612020b2b6SRod Evans } Conv_la_symbind_buf_t;
1622020b2b6SRod Evans 
163de777a60Sab /*
16408278a5eSRod Evans  * conv_cap_val_hw/sf()
165de777a60Sab  *
16608278a5eSRod Evans  * These sizes are based on the maximum number of capabilities that exist.
16708278a5eSRod Evans  * See common/elfcap.
168de777a60Sab  */
169*56726c7eSRobert Mustacchi #define	CONV_CAP_VAL_HW1_BUFSIZE	528
170de777a60Sab typedef union {
1714f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
1724f680cc6SAli Bahrami 	char				buf[CONV_CAP_VAL_HW1_BUFSIZE];
1734f680cc6SAli Bahrami } Conv_cap_val_hw1_buf_t;
174de777a60Sab 
175*56726c7eSRobert Mustacchi #define	CONV_CAP_VAL_HW2_BUFSIZE	632
17608278a5eSRod Evans typedef union {
17708278a5eSRod Evans 	Conv_inv_buf_t			inv_buf;
17808278a5eSRod Evans 	char				buf[CONV_CAP_VAL_HW2_BUFSIZE];
17908278a5eSRod Evans } Conv_cap_val_hw2_buf_t;
18008278a5eSRod Evans 
181*56726c7eSRobert Mustacchi #define	CONV_CAP_VAL_SF1_BUFSIZE	73
182de777a60Sab typedef union {
1834f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
1844f680cc6SAli Bahrami 	char				buf[CONV_CAP_VAL_SF1_BUFSIZE];
1854f680cc6SAli Bahrami } Conv_cap_val_sf1_buf_t;
186de777a60Sab 
187*56726c7eSRobert Mustacchi #define	CONV_CAP_VAL_HW3_BUFSIZE	66
188*56726c7eSRobert Mustacchi typedef union {
189*56726c7eSRobert Mustacchi 	Conv_inv_buf_t			inv_buf;
190*56726c7eSRobert Mustacchi 	char				buf[CONV_CAP_VAL_HW3_BUFSIZE];
191*56726c7eSRobert Mustacchi } Conv_cap_val_hw3_buf_t;
192*56726c7eSRobert Mustacchi 
193de777a60Sab /* conv_cap_val_buf() */
194de777a60Sab typedef union {
1954f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
1964f680cc6SAli Bahrami 	Conv_cap_val_hw1_buf_t		cap_val_hw1_buf;
1974f680cc6SAli Bahrami 	Conv_cap_val_sf1_buf_t		cap_val_sf1_buf;
19808278a5eSRod Evans 	Conv_cap_val_hw2_buf_t		cap_val_hw2_buf;
199*56726c7eSRobert Mustacchi 	Conv_cap_val_hw3_buf_t		cap_val_hw3_buf;
2004f680cc6SAli Bahrami } Conv_cap_val_buf_t;
201de777a60Sab 
202de777a60Sab /* conv_config_feat() */
2034f680cc6SAli Bahrami #define	CONV_CONFIG_FEAT_BUFSIZE	204
204de777a60Sab typedef union {
2054f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2064f680cc6SAli Bahrami 	char				buf[CONV_CONFIG_FEAT_BUFSIZE];
2074f680cc6SAli Bahrami } Conv_config_feat_buf_t;
208de777a60Sab 
209de777a60Sab /* conv_config_obj() */
2104f680cc6SAli Bahrami #define	CONV_CONFIG_OBJ_BUFSIZE		164
211de777a60Sab typedef union {
2124f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2134f680cc6SAli Bahrami 	char				buf[CONV_CONFIG_OBJ_BUFSIZE];
2144f680cc6SAli Bahrami } Conv_config_obj_buf_t;
215de777a60Sab 
216de777a60Sab /* conv_dl_mode() */
2174f680cc6SAli Bahrami #define	CONV_DL_MODE_BUFSIZE		132
218de777a60Sab typedef union {
2194f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2204f680cc6SAli Bahrami 	char				buf[CONV_DL_MODE_BUFSIZE];
2214f680cc6SAli Bahrami } Conv_dl_mode_buf_t;
222de777a60Sab 
223de777a60Sab /* conv_dl_flag() */
2244f680cc6SAli Bahrami #define	CONV_DL_FLAG_BUFSIZE		185
225de777a60Sab typedef union {
2264f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2274f680cc6SAli Bahrami 	char				buf[CONV_DL_FLAG_BUFSIZE];
2284f680cc6SAli Bahrami } Conv_dl_flag_buf_t;
229de777a60Sab 
230de777a60Sab /* conv_grphdl_flags() */
231e0e63816SRod Evans #define	CONV_GRPHDL_FLAGS_BUFSIZE	78
232de777a60Sab typedef union {
2334f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2344f680cc6SAli Bahrami 	char				buf[CONV_GRPHDL_FLAGS_BUFSIZE];
2354f680cc6SAli Bahrami } Conv_grphdl_flags_buf_t;
236de777a60Sab 
237de777a60Sab /* conv_grpdesc_flags() */
2382017c965SRod Evans #define	CONV_GRPDESC_FLAGS_BUFSIZE	91
239de777a60Sab typedef union {
2404f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2414f680cc6SAli Bahrami 	char				buf[CONV_GRPDESC_FLAGS_BUFSIZE];
2424f680cc6SAli Bahrami } Conv_grpdesc_flags_buf_t;
243de777a60Sab 
244de777a60Sab /* conv_seg_flags() */
24569112eddSAli Bahrami #define	CONV_SEG_FLAGS_BUFSIZE		241
246de777a60Sab typedef union {
2474f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2484f680cc6SAli Bahrami 	char				buf[CONV_SEG_FLAGS_BUFSIZE];
2494f680cc6SAli Bahrami } Conv_seg_flags_buf_t;
250de777a60Sab 
251de777a60Sab /* conv_dyn_posflag1() */
252f441771bSRod Evans #define	CONV_DYN_POSFLAG1_BUFSIZE	72
253de777a60Sab typedef union {
2544f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2554f680cc6SAli Bahrami 	char				buf[CONV_DYN_POSFLAG1_BUFSIZE];
2564f680cc6SAli Bahrami } Conv_dyn_posflag1_buf_t;
257de777a60Sab 
258de777a60Sab /* conv_dyn_flag() */
2594f680cc6SAli Bahrami #define	CONV_DYN_FLAG_BUFSIZE		85
260de777a60Sab typedef union {
2614f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2624f680cc6SAli Bahrami 	char				buf[CONV_DYN_FLAG_BUFSIZE];
2634f680cc6SAli Bahrami } Conv_dyn_flag_buf_t;
264de777a60Sab 
265de777a60Sab /* conv_dyn_flag1() */
2664f680cc6SAli Bahrami #define	CONV_DYN_FLAG1_BUFSIZE		361
267de777a60Sab typedef union {
2684f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2694f680cc6SAli Bahrami 	char				buf[CONV_DYN_FLAG1_BUFSIZE];
2704f680cc6SAli Bahrami } Conv_dyn_flag1_buf_t;
271de777a60Sab 
272de777a60Sab /* conv_dyn_feature1() */
2734f680cc6SAli Bahrami #define	CONV_DYN_FEATURE1_BUFSIZE	54
274de777a60Sab typedef union {
2754f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2764f680cc6SAli Bahrami 	char				buf[CONV_DYN_FEATURE1_BUFSIZE];
2774f680cc6SAli Bahrami } Conv_dyn_feature1_buf_t;
278de777a60Sab 
279de777a60Sab /* conv_bnd_type() */
2804f680cc6SAli Bahrami #define	CONV_BND_TYPE_BUFSIZE		51
281de777a60Sab typedef union {
2824f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2834f680cc6SAli Bahrami 	char				buf[CONV_BND_TYPE_BUFSIZE];
2844f680cc6SAli Bahrami } Conv_bnd_type_buf_t;
285de777a60Sab 
286de777a60Sab /* conv_bnd_obj() */
2874f680cc6SAli Bahrami #define	CONV_BND_OBJ_BUFSIZE		60
288de777a60Sab typedef union {
2894f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
2904f680cc6SAli Bahrami 	char				buf[CONV_BND_OBJ_BUFSIZE];
2914f680cc6SAli Bahrami } Conv_bnd_obj_buf_t;
292de777a60Sab 
293de777a60Sab /* conv_phdr_flags() */
294f971a346SBryan Cantrill #define	CONV_PHDR_FLAGS_BUFSIZE		88
295de777a60Sab typedef union {
2962017c965SRod Evans 	Conv_inv_buf_t			inv_buf;
2972017c965SRod Evans 	char				buf[CONV_PHDR_FLAGS_BUFSIZE];
2984f680cc6SAli Bahrami } Conv_phdr_flags_buf_t;
299de777a60Sab 
300de777a60Sab /* conv_sec_flags() */
3014f680cc6SAli Bahrami #define	CONV_SEC_FLAGS_BUFSIZE		190
302de777a60Sab typedef union {
3034f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3044f680cc6SAli Bahrami 	char				buf[CONV_SEC_FLAGS_BUFSIZE];
3054f680cc6SAli Bahrami } Conv_sec_flags_buf_t;
306de777a60Sab 
307de777a60Sab /* conv_dwarf_ehe() */
3084f680cc6SAli Bahrami #define	CONV_DWARF_EHE_BUFSIZE		43
309de777a60Sab typedef union {
3104f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3114f680cc6SAli Bahrami 	char				buf[CONV_DWARF_EHE_BUFSIZE];
3124f680cc6SAli Bahrami } Conv_dwarf_ehe_buf_t;
313de777a60Sab 
314d29b2c44Sab /* conv_syminfo_flags() */
315f441771bSRod Evans #define	CONV_SYMINFO_FLAGS_BUFSIZE	230
316d29b2c44Sab typedef union {
3174f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3184f680cc6SAli Bahrami 	char				buf[CONV_SYMINFO_FLAGS_BUFSIZE];
3194f680cc6SAli Bahrami } Conv_syminfo_flags_buf_t;
320d29b2c44Sab 
321c6c9aed4Sab /* conv_cnote_pr_flags() */
3224f680cc6SAli Bahrami #define	CONV_CNOTE_PR_FLAGS_BUFSIZE	254
323c6c9aed4Sab typedef union {
3244f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3254f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
3264f680cc6SAli Bahrami } Conv_cnote_pr_flags_buf_t;
327c6c9aed4Sab 
328c6c9aed4Sab /* conv_cnote_old_pr_flags() */
3294f680cc6SAli Bahrami #define	CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE	174
330c6c9aed4Sab typedef union {
3314f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3324f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
3334f680cc6SAli Bahrami } Conv_cnote_old_pr_flags_buf_t;
334c6c9aed4Sab 
335c6c9aed4Sab /* conv_cnote_proc_flag() */
3364f680cc6SAli Bahrami #define	CONV_CNOTE_PROC_FLAG_BUFSIZE	39
337c6c9aed4Sab typedef union {
3384f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3394f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
3404f680cc6SAli Bahrami } Conv_cnote_proc_flag_buf_t;
341c6c9aed4Sab 
342d2a70789SRichard Lowe /* conv_prsecflags() */
343d2a70789SRichard Lowe #define	CONV_PRSECFLAGS_BUFSIZE		57
344d2a70789SRichard Lowe typedef union {
345d2a70789SRichard Lowe 	Conv_inv_buf_t			inv_buf;
346d2a70789SRichard Lowe 	char				buf[CONV_PRSECFLAGS_BUFSIZE];
347d2a70789SRichard Lowe } Conv_secflags_buf_t;
348c6c9aed4Sab 
349350ffdd5SRobert Mustacchi /* conv_prupanic() */
350350ffdd5SRobert Mustacchi #define	CONV_PRUPANIC_BUFSIZE		56
351350ffdd5SRobert Mustacchi typedef union {
352350ffdd5SRobert Mustacchi 	Conv_inv_buf_t			inv_buf;
353350ffdd5SRobert Mustacchi 	char				buf[CONV_PRUPANIC_BUFSIZE];
354350ffdd5SRobert Mustacchi } Conv_upanic_buf_t;
355350ffdd5SRobert Mustacchi 
356c6c9aed4Sab /* conv_cnote_sigset() */
3574f680cc6SAli Bahrami #define	CONV_CNOTE_SIGSET_BUFSIZE	639
358c6c9aed4Sab typedef union {
3594f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3604f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SIGSET_BUFSIZE];
3614f680cc6SAli Bahrami } Conv_cnote_sigset_buf_t;
362c6c9aed4Sab 
363c6c9aed4Sab /* conv_cnote_fltset() */
3644f680cc6SAli Bahrami #define	CONV_CNOTE_FLTSET_BUFSIZE	511
365c6c9aed4Sab typedef union {
3664f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3674f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_FLTSET_BUFSIZE];
3684f680cc6SAli Bahrami } Conv_cnote_fltset_buf_t;
369c6c9aed4Sab 
370c6c9aed4Sab /* conv_cnote_sysset() */
371350ffdd5SRobert Mustacchi #define	CONV_CNOTE_SYSSET_BUFSIZE	3227
372c6c9aed4Sab typedef union {
3734f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3744f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SYSSET_BUFSIZE];
3754f680cc6SAli Bahrami } Conv_cnote_sysset_buf_t;
376c6c9aed4Sab 
377c6c9aed4Sab /* conv_cnote_sa_flags() */
3784f680cc6SAli Bahrami #define	CONV_CNOTE_SA_FLAGS_BUFSIZE	109
379c6c9aed4Sab typedef union {
3804f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3814f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
3824f680cc6SAli Bahrami } Conv_cnote_sa_flags_buf_t;
383c6c9aed4Sab 
384c6c9aed4Sab /* conv_cnote_ss_flags() */
3854f680cc6SAli Bahrami #define	CONV_CNOTE_SS_FLAGS_BUFSIZE	48
386c6c9aed4Sab typedef union {
3874f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3884f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
3894f680cc6SAli Bahrami } Conv_cnote_ss_flags_buf_t;
390c6c9aed4Sab 
391c6c9aed4Sab /* conv_cnote_cc_content() */
3928e458de0SRobert Mustacchi #define	CONV_CNOTE_CC_CONTENT_BUFSIZE	103
393c6c9aed4Sab typedef union {
3944f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
3954f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
3964f680cc6SAli Bahrami } Conv_cnote_cc_content_buf_t;
397c6c9aed4Sab 
398c6c9aed4Sab /* conv_cnote_auxv_af() */
3994f680cc6SAli Bahrami #define	CONV_CNOTE_AUXV_AF_BUFSIZE	73
400c6c9aed4Sab typedef union {
4014f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
4024f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
4034f680cc6SAli Bahrami } Conv_cnote_auxv_af_buf_t;
404c6c9aed4Sab 
405090a8d9eSAli Bahrami /* conv_ver_flags() */
4064f680cc6SAli Bahrami #define	CONV_VER_FLAGS_BUFSIZE		41
407090a8d9eSAli Bahrami typedef union {
4084f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
4094f680cc6SAli Bahrami 	char				buf[CONV_VER_FLAGS_BUFSIZE];
4104f680cc6SAli Bahrami } Conv_ver_flags_buf_t;
411de777a60Sab 
41269112eddSAli Bahrami /* conv_ent_flags() */
41369112eddSAli Bahrami #define	CONV_ENT_FLAGS_BUFSIZE		69
41469112eddSAli Bahrami typedef union {
41569112eddSAli Bahrami 	Conv_inv_buf_t			inv_buf;
41669112eddSAli Bahrami 	char				buf[CONV_ENT_FLAGS_BUFSIZE];
41769112eddSAli Bahrami } Conv_ent_flags_buf_t;
41869112eddSAli Bahrami 
41969112eddSAli Bahrami /* conv_ent_files_flags() */
42008278a5eSRod Evans #define	CONV_ENT_FILES_FLAGS_BUFSIZE	89
42169112eddSAli Bahrami typedef union {
42269112eddSAli Bahrami 	Conv_inv_buf_t			inv_buf;
42369112eddSAli Bahrami 	char				buf[CONV_ENT_FILES_FLAGS_BUFSIZE];
42469112eddSAli Bahrami } Conv_ent_files_flags_buf_t;
42569112eddSAli Bahrami 
4262017c965SRod Evans /*
4272017c965SRod Evans  * conv_time()
4282017c965SRod Evans  *
4292017c965SRod Evans  * This size is based on the maximum "hour.min.sec.fraction: " time that
4302017c965SRod Evans  * would be expected of ld().
4312017c965SRod Evans  */
4322017c965SRod Evans #define	CONV_TIME_BUFSIZE		18
4332017c965SRod Evans typedef union {
4342017c965SRod Evans 	char				buf[CONV_TIME_BUFSIZE];
4352017c965SRod Evans } Conv_time_buf_t;
4362926dd2eSrie 
437d29b2c44Sab /*
438d29b2c44Sab  * Many conversion routines accept a fmt_flags argument of this type
439d29b2c44Sab  * to allow the caller to modify the output. There are two parts to
440d29b2c44Sab  * this value:
441d29b2c44Sab  *
442d29b2c44Sab  *	(1) Format requests (decimal vs hex, etc...)
443d29b2c44Sab  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
444d29b2c44Sab  *		and retrieved by CONV_TYPE_FMT_ALT are integer
445d29b2c44Sab  *		values that specify that an alternate set of
4464f680cc6SAli Bahrami  *		strings should be used.
447d29b2c44Sab  *
4484f680cc6SAli Bahrami  * The fmt_flags value is designed such that a caller can always
4494f680cc6SAli Bahrami  * supply a 0 in order to receive default behavior.
450d29b2c44Sab  */
451d29b2c44Sab typedef int Conv_fmt_flags_t;
452d29b2c44Sab 
453d29b2c44Sab /*
4544f680cc6SAli Bahrami  * Type used to represent ELF constants within libconv. This relies on
4554f680cc6SAli Bahrami  * the fact that there are no ELF constants that need more than 32-bits,
4564f680cc6SAli Bahrami  * nor are there any signed values.
4574f680cc6SAli Bahrami  */
4584f680cc6SAli Bahrami typedef uint32_t Conv_elfvalue_t;
4594f680cc6SAli Bahrami 
4604f680cc6SAli Bahrami /*
4614f680cc6SAli Bahrami  * Most conversion routines are able to provide strings in one of
4624f680cc6SAli Bahrami  * several alternative styles. The bottom 8 bits of Conv_fmt_flags_t
4634f680cc6SAli Bahrami  * are used to specify which strings should be used for a given call
4644f680cc6SAli Bahrami  * to a conversion routine:
4654f680cc6SAli Bahrami  *
4664f680cc6SAli Bahrami  *   DEFAULT
4674f680cc6SAli Bahrami  *	The default string style used by a given conversion routine is
4684f680cc6SAli Bahrami  *	an independent choice made by that routine. Different routines
4694f680cc6SAli Bahrami  *	make different choices, based largely on historical usage and
4704f680cc6SAli Bahrami  *	the perceived common case. It may be an alias for one of the
4714f680cc6SAli Bahrami  *	specific styles listed below, or it may be unique.
4724f680cc6SAli Bahrami  *
4734f680cc6SAli Bahrami  *   DUMP
4744f680cc6SAli Bahrami  *	Style of strings used by dump(1).
4754f680cc6SAli Bahrami  *
4764f680cc6SAli Bahrami  *   FILE
4774f680cc6SAli Bahrami  *	Style of strings used by file(1).
4784f680cc6SAli Bahrami  *
4794f680cc6SAli Bahrami  *   CRLE
4804f680cc6SAli Bahrami  *	Style of strings used by crle(1).
481d29b2c44Sab  *
4824f680cc6SAli Bahrami  *   CF
4834f680cc6SAli Bahrami  *	Canonical Form: The string is exactly the same as the name
4844f680cc6SAli Bahrami  *	of the #define macro that defines it in the public header files.
4854f680cc6SAli Bahrami  *	(e.g. STB_LOCAL, not LOCL, LOCAL, LOC, or any other variation).
4864f680cc6SAli Bahrami  *
4874f680cc6SAli Bahrami  *   CFNP
4884f680cc6SAli Bahrami  *	No Prefix Canonical Form: The same strings supplied by CF,
4894f680cc6SAli Bahrami  *	but without their standard prefix. (e.g. LOCAL, instead of STT_LOCAL).
4904f680cc6SAli Bahrami  *
4914f680cc6SAli Bahrami  *   NF
4924f680cc6SAli Bahrami  *	Natural Form: The form of the strings that might typically be entered
4934f680cc6SAli Bahrami  *	via a keyboard by an interactive user. These are usually the strings
4944f680cc6SAli Bahrami  *	from CFNP, converted to lowercase, although in some cases they may
4954f680cc6SAli Bahrami  *	take some other "natural" form. In command completion applications,
4964f680cc6SAli Bahrami  *	lowercase strings appear less formal, and are easier on the eye.
4974f680cc6SAli Bahrami  *
4984f680cc6SAli Bahrami  * Every routine is required to have a default style. The others are optional,
4994f680cc6SAli Bahrami  * and may not be provided if not needed. If a given conversion routine does
5004f680cc6SAli Bahrami  * not support alternative strings for a given CONV_FMT_ALT type, it silently
5014f680cc6SAli Bahrami  * ignores the request and supplies the default set. This means that a utility
5024f680cc6SAli Bahrami  * like dump(1) is free to specify a style like DUMP to every conversion
503d29b2c44Sab  * routine. It will receive its special strings if there are any, and
504d29b2c44Sab  * the defaults otherwise.
505d29b2c44Sab  */
506d29b2c44Sab #define	CONV_MASK_FMT_ALT		0xff
507d29b2c44Sab #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
508d29b2c44Sab 
509d29b2c44Sab #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
5104f680cc6SAli Bahrami #define	CONV_FMT_ALT_DUMP	1	/* dump(1) */
5114f680cc6SAli Bahrami #define	CONV_FMT_ALT_FILE	2	/* file(1) */
5124f680cc6SAli Bahrami #define	CONV_FMT_ALT_CRLE	3	/* crle(1) */
5134f680cc6SAli Bahrami #define	CONV_FMT_ALT_CF		4	/* Canonical Form */
5144f680cc6SAli Bahrami #define	CONV_FMT_ALT_CFNP	5	/* No Prefix Canonical Form */
5154f680cc6SAli Bahrami #define	CONV_FMT_ALT_NF		6	/* Natural Form */
516d29b2c44Sab 
5175aefb655Srie /*
518c13de8f6Sab  * Flags that alter standard formatting for conversion routines.
519d29b2c44Sab  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
5205aefb655Srie  */
521d29b2c44Sab #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
522c13de8f6Sab 					/*    integer print as decimal */
523c13de8f6Sab 					/*    (default is hex) */
524d29b2c44Sab #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
525c13de8f6Sab 					/*    a space after the number.  */
526d29b2c44Sab #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
527d29b2c44Sab 					/*    prefix and suffix strings */
528c13de8f6Sab 
5295aefb655Srie /*
5304f680cc6SAli Bahrami  * A Val_desc structure is used to associate an ELF constant and
5314f680cc6SAli Bahrami  * the message code (Msg) for the string that corresponds to it.
5324f680cc6SAli Bahrami  *
5334f680cc6SAli Bahrami  * Val_desc2 adds v_osabi and v_mach fields to Val_desc, which allows
5344f680cc6SAli Bahrami  * for non-generic mappings that apply only to a specific OSABI/machine.
5354f680cc6SAli Bahrami  * Setting v_osabi to 0 (ELFOSABI_NONE) specifies that any OSABI matches.
5364f680cc6SAli Bahrami  * Similarly, setting v_mach to 0 (EM_MACH) matches any machine. Hence,
5374f680cc6SAli Bahrami  * setting v_osabi and v_mach to 0 in a Val_desc2 results in a generic item,
5384f680cc6SAli Bahrami  * and is equivalent to simply using a Val_desc.
5394f680cc6SAli Bahrami  *
5404f680cc6SAli Bahrami  * These structs are used in two different contexts:
5414f680cc6SAli Bahrami  *
5424f680cc6SAli Bahrami  * 1)	To expand bit-field data items, using conv_expn_field() to
5434f680cc6SAli Bahrami  *	process a NULL terminated array of Val_desc, or conv_expn_field2()
5444f680cc6SAli Bahrami  *	to process a null terminated array of Val_desc2.
5454f680cc6SAli Bahrami  *
5464f680cc6SAli Bahrami  * 2)	To represent sparse ranges of non-bitfield values, referenced via
5474f680cc6SAli Bahrami  *	conv_ds_vd_t or conv_ds_vd2_t descriptors, as described below.
5485aefb655Srie  */
5495aefb655Srie typedef struct {
5504f680cc6SAli Bahrami 	Conv_elfvalue_t	v_val;		/* expansion value */
5514f680cc6SAli Bahrami 	Msg		v_msg;		/* associated message string code */
5525aefb655Srie } Val_desc;
5534f680cc6SAli Bahrami typedef struct {
5544f680cc6SAli Bahrami 	Conv_elfvalue_t	v_val;		/* expansion value */
5554f680cc6SAli Bahrami 	uchar_t		v_osabi;	/* OSABI to which entry applies */
5564f680cc6SAli Bahrami 	Half		v_mach;		/* Machine to which entry applies */
5574f680cc6SAli Bahrami 	Msg		v_msg;		/* associated message string code */
5584f680cc6SAli Bahrami } Val_desc2;
5594f680cc6SAli Bahrami 
5604f680cc6SAli Bahrami /*
5614f680cc6SAli Bahrami  * The conv_ds_XXX_t structs are used to pull together the information used
5624f680cc6SAli Bahrami  * to map non-bitfield values to strings. They are a variant family, sharing
5634f680cc6SAli Bahrami  * the same initial fields, with a generic "header" definition that can be
5644f680cc6SAli Bahrami  * used to read those common fields and determine which subcase is being
5654f680cc6SAli Bahrami  * seen. We do this instead of using a single struct containing a type code
5664f680cc6SAli Bahrami  * and a union in order to allow for static compile-time initialization.
5674f680cc6SAli Bahrami  *
5684f680cc6SAli Bahrami  * conv_ds_t is the base type, containing the initial fields common to all
5694f680cc6SAli Bahrami  * the variants. Variables of type conv_ds_t are never instantiated. This
5704f680cc6SAli Bahrami  * type exists only to provide a common pointer type that can reference
5714f680cc6SAli Bahrami  * any of the variants safely. In C++, it would be a virtual base class.
5724f680cc6SAli Bahrami  * The fields common to all the variants are:
5734f680cc6SAli Bahrami  *
5744f680cc6SAli Bahrami  *	ds_type: Identifies the variant
5754f680cc6SAli Bahrami  *	ds_baseval/ds_topval: The lower and upper bound of the range
5764f680cc6SAli Bahrami  *		of values represented by this conv_ds_XXX_t descriptor.
5774f680cc6SAli Bahrami  *
5784f680cc6SAli Bahrami  * There are three different variants:
5794f680cc6SAli Bahrami  *    conv_ds_msg_t (ds_type == CONV_DS_MSGARR)
5804f680cc6SAli Bahrami  *	This structure references an array of message codes corresponding
5814f680cc6SAli Bahrami  *	to consecutive ELF values. The first item in the array is the Msg
5824f680cc6SAli Bahrami  *	code for the value given by ds_baseval. Consecutive strings follow
5834f680cc6SAli Bahrami  *	in consecutive order. The final item corresponds to the value given
5844f680cc6SAli Bahrami  *	by ds_topval. Zero (0) Msg values can be used to represent missing
5854f680cc6SAli Bahrami  *	values. Entries with a 0 are quietly ignored.
5864f680cc6SAli Bahrami  *
5874f680cc6SAli Bahrami  *    conv_ds_vd_t (ds_type == CONV_DS_VD)
5884f680cc6SAli Bahrami  *	This structure employs a NULL terminated array of Val_desc structs.
5894f680cc6SAli Bahrami  *	Each Val_desc supplies a mapping from a value in the range
5904f680cc6SAli Bahrami  *	(ds_baseval <= value <= ds_topval). The values described need not
5914f680cc6SAli Bahrami  *	be consecutive, and can be sparse. ds_baseval does not need to
5924f680cc6SAli Bahrami  *	correspond to the first item, and ds_topval need not correspond to
5934f680cc6SAli Bahrami  *	the final item.
5944f680cc6SAli Bahrami  *
5954f680cc6SAli Bahrami  *    conv_ds_vd2_t (ds_type == CONV_DS_VD2)
5964f680cc6SAli Bahrami  *	This structure employs a NULL terminated array of Val_desc2 structs,
5974f680cc6SAli Bahrami  *	rather than Val_desc, adding the ability to specify OSABI and machine
5984f680cc6SAli Bahrami  *	as part of the value/string mapping. It is otherwise the same thing
5994f680cc6SAli Bahrami  *	as CONV_DS_VD.
6004f680cc6SAli Bahrami  */
6014f680cc6SAli Bahrami typedef enum {
6024f680cc6SAli Bahrami 	CONV_DS_MSGARR = 0,		/* Array of Msg */
6034f680cc6SAli Bahrami 	CONV_DS_VD = 1,			/* Null terminated array of Val_desc */
6044f680cc6SAli Bahrami 	CONV_DS_VD2 = 2,		/* Null terminated array of Val_desc2 */
6054f680cc6SAli Bahrami } conv_ds_type_t;
6064f680cc6SAli Bahrami 
6074f680cc6SAli Bahrami #define	CONV_DS_COMMON_FIELDS \
60869b1fd3fSRichard Lowe 	conv_ds_type_t	ds_type;	/* Type of data structure used */ \
6094f680cc6SAli Bahrami 	uint32_t	ds_baseval;	/* Value of first item */	\
6104f680cc6SAli Bahrami 	uint32_t	ds_topval	/* Value of last item */
6114f680cc6SAli Bahrami 
6124f680cc6SAli Bahrami typedef struct {		/* Virtual base type --- do not instantiate */
6134f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
6144f680cc6SAli Bahrami } conv_ds_t;
6154f680cc6SAli Bahrami typedef struct {
6164f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
6174f680cc6SAli Bahrami 	const Msg		*ds_msg;
6184f680cc6SAli Bahrami } conv_ds_msg_t;
6194f680cc6SAli Bahrami typedef struct {
6204f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
6214f680cc6SAli Bahrami 	const Val_desc		*ds_vd;
6224f680cc6SAli Bahrami } conv_ds_vd_t;
6234f680cc6SAli Bahrami typedef struct {
6244f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
6254f680cc6SAli Bahrami 	const Val_desc2		*ds_vd2;
6264f680cc6SAli Bahrami } conv_ds_vd2_t;
6274f680cc6SAli Bahrami 
6284f680cc6SAli Bahrami /*
6294f680cc6SAli Bahrami  * The initialization of conv_ds_msg_t can be completely derived from
6304f680cc6SAli Bahrami  * its base value and the array of Msg codes. CONV_DS_MSG_INIT() is used
6314f680cc6SAli Bahrami  * to do that.
6324f680cc6SAli Bahrami  */
6334f680cc6SAli Bahrami #define	CONV_DS_MSG_INIT(_baseval, _arr) \
6344f680cc6SAli Bahrami 	CONV_DS_MSGARR, _baseval, \
6354f680cc6SAli Bahrami 	_baseval + (sizeof (_arr) / sizeof (_arr[0])) - 1, _arr
6364f680cc6SAli Bahrami 
6374f680cc6SAli Bahrami /*
6384f680cc6SAli Bahrami  * Null terminated arrays of pointers to conv_ds_XXX_t structs are processed
6394f680cc6SAli Bahrami  * by conv_map_ds() to convert ELF constants to their symbolic names, and by
6404f680cc6SAli Bahrami  * conv_iter_ds() to iterate over all the available value/name combinations.
6414f680cc6SAli Bahrami  *
6424f680cc6SAli Bahrami  * These pointers are formed by casting the address of the specific
6434f680cc6SAli Bahrami  * variant types (described above) to generic base type pointer.
6444f680cc6SAli Bahrami  * CONV_DS_ADDR() is a convenience macro to take the address of
6454f680cc6SAli Bahrami  * one of these variants and turn it into a generic pointer.
6464f680cc6SAli Bahrami  */
6474f680cc6SAli Bahrami #define	CONV_DS_ADDR(_item) ((conv_ds_t *)&(_item))
6484f680cc6SAli Bahrami 
6494f680cc6SAli Bahrami /*
6504f680cc6SAli Bahrami  * Type used by libconv to represent osabi values passed to iteration
6514f680cc6SAli Bahrami  * functions. The type in the ELF header is uchar_t. However, every possible
6524f680cc6SAli Bahrami  * value 0-255 has a valid meaning, leaving us no extra value to assign
6534f680cc6SAli Bahrami  * to mean "ALL". Using Half for osabi leaves us the top byte to use for
6544f680cc6SAli Bahrami  * out of bound values.
6554f680cc6SAli Bahrami  *
6564f680cc6SAli Bahrami  * Non-iteration functions, and any code that does not need to use
6574f680cc6SAli Bahrami  * CONV_OSABI_ALL, should use uchar_t for osabi.
6584f680cc6SAli Bahrami  */
6594f680cc6SAli Bahrami typedef Half conv_iter_osabi_t;
6604f680cc6SAli Bahrami 
6614f680cc6SAli Bahrami /*
6624f680cc6SAli Bahrami  * Many of the iteration functions accept an osabi or mach argument,
6634f680cc6SAli Bahrami  * used to specify the type of object being processed. The following
6644f680cc6SAli Bahrami  * values can be used to specify a wildcard that matches any item. Their
6654f680cc6SAli Bahrami  * values are carefully chosen to ensure that they cannot be interpreted
6664f680cc6SAli Bahrami  * as an otherwise valid osabi or machine.
6674f680cc6SAli Bahrami  */
6684f680cc6SAli Bahrami #define	CONV_OSABI_ALL	1024	/* Larger than can be represented by uchar_t */
6694f680cc6SAli Bahrami #define	CONV_MACH_ALL	EM_NUM	/* Never a valid machine type */
6704f680cc6SAli Bahrami 
6714f680cc6SAli Bahrami /*
6724f680cc6SAli Bahrami  * We compare Val_Desc2 descriptors with a specified osabi and machine
6734f680cc6SAli Bahrami  * to determine whether to use it or not. This macro encapsulates that logic.
6744f680cc6SAli Bahrami  *
6754f680cc6SAli Bahrami  * We consider an osabi to match when any of the following things hold:
6764f680cc6SAli Bahrami  *
6774f680cc6SAli Bahrami  * -	The descriptor osabi is ELFOSABI_NONE.
6784f680cc6SAli Bahrami  * -	The supplied osabi and the descriptor osabi match
6794f680cc6SAli Bahrami  * -	The supplied osabi is ELFOSABI_NONE, and the descriptor osabi is
6804f680cc6SAli Bahrami  *	ELFOSABI_SOLARIS. Many operating systems, Solaris included,
6814f680cc6SAli Bahrami  *	produce or have produced ELFOSABI_NONE native objects, if only
6824f680cc6SAli Bahrami  *	because OSABI ranges are not an original ELF feature. We
6834f680cc6SAli Bahrami  *	give our own objects the home field advantage.
6844f680cc6SAli Bahrami  * -	Iteration Only: An osabi value of CONV_OSABI_ALL is specified.
6854f680cc6SAli Bahrami  *
6864f680cc6SAli Bahrami  * We consider a machine to match when any of the following things hold:
6874f680cc6SAli Bahrami  *
6884f680cc6SAli Bahrami  * -	The descriptor mach is EM_NONE.
6894f680cc6SAli Bahrami  * -	The supplied mach and the descriptor mach match
6904f680cc6SAli Bahrami  * -	Iteration Only: A mach value of CONV_MACH_ALL is specified.
6914f680cc6SAli Bahrami  *
6924f680cc6SAli Bahrami  * The special extra _ALL case for iteration is handled by defining a separate
6934f680cc6SAli Bahrami  * macro with the extra CONV_xxx_ALL tests.
6944f680cc6SAli Bahrami  */
6954f680cc6SAli Bahrami #define	CONV_VD2_SKIP_OSABI(_osabi, _vdp) \
6964f680cc6SAli Bahrami 	((_vdp->v_osabi != ELFOSABI_NONE) && (_vdp->v_osabi != osabi) && \
6974f680cc6SAli Bahrami 	((_osabi != ELFOSABI_NONE) || (_vdp->v_osabi != ELFOSABI_SOLARIS)))
6984f680cc6SAli Bahrami 
6994f680cc6SAli Bahrami #define	CONV_VD2_SKIP_MACH(_mach, _vdp) \
7004f680cc6SAli Bahrami 	((_vdp->v_mach != EM_NONE) && (_vdp->v_mach != _mach))
7014f680cc6SAli Bahrami 
7024f680cc6SAli Bahrami #define	CONV_VD2_SKIP(_osabi, _mach, _vdp) \
7034f680cc6SAli Bahrami 	(CONV_VD2_SKIP_OSABI(_osabi, _vdp) || CONV_VD2_SKIP_MACH(_mach, _vdp))
7044f680cc6SAli Bahrami 
7054f680cc6SAli Bahrami #define	CONV_ITER_VD2_SKIP(_osabi, _mach, _vdp)			      \
7064f680cc6SAli Bahrami 	((CONV_VD2_SKIP_OSABI(_osabi, _vdp) && (_osabi != CONV_OSABI_ALL)) || \
7074f680cc6SAli Bahrami 	(CONV_VD2_SKIP_MACH(_mach, _vdp) && (_mach != CONV_MACH_ALL)))
7084f680cc6SAli Bahrami 
7094f680cc6SAli Bahrami 
7104f680cc6SAli Bahrami /*
7114f680cc6SAli Bahrami  * Possible return values from iteration functions.
7124f680cc6SAli Bahrami  */
7134f680cc6SAli Bahrami typedef enum {
7144f680cc6SAli Bahrami 	CONV_ITER_DONE,		/* Stop: No more iterations are desired */
7154f680cc6SAli Bahrami 	CONV_ITER_CONT		/* Continue with following iterations */
7164f680cc6SAli Bahrami } conv_iter_ret_t;
7174f680cc6SAli Bahrami 
7184f680cc6SAli Bahrami /*
7194f680cc6SAli Bahrami  * Prototype for caller supplied callback function to iteration functions.
7204f680cc6SAli Bahrami  */
7214f680cc6SAli Bahrami typedef conv_iter_ret_t (* conv_iter_cb_t)(const char *str,
7224f680cc6SAli Bahrami     Conv_elfvalue_t value, void *uvalue);
7234f680cc6SAli Bahrami 
7244f680cc6SAli Bahrami /*
7254f680cc6SAli Bahrami  * User value block employed by conv_iter_strtol()
7264f680cc6SAli Bahrami  */
7274f680cc6SAli Bahrami typedef struct {
7284f680cc6SAli Bahrami 	const char	*csl_str;	/* String to search for */
7294f680cc6SAli Bahrami 	size_t		csl_strlen;	/* # chars in csl_str to examine */
7304f680cc6SAli Bahrami 	int		csl_found;	/* Init to 0, set to 1 if item found */
7314f680cc6SAli Bahrami 	Conv_elfvalue_t	csl_value;	/* If csl_found, resulting value */
7324f680cc6SAli Bahrami } conv_strtol_uvalue_t;
7335aefb655Srie 
734ba4e3c84Sab /*
735ba4e3c84Sab  * conv_expn_field() is willing to supply default strings for the
736ba4e3c84Sab  * prefix, separator, and suffix arguments, if they are passed as NULL.
737ba4e3c84Sab  * The caller needs to know how much room to allow for these items.
738ba4e3c84Sab  * These values supply those sizes.
739ba4e3c84Sab  */
740ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
741ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
742ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
743ba4e3c84Sab 
744ba4e3c84Sab /*
745ba4e3c84Sab  * conv_expn_field() requires a large number of inputs, many of which
746ba4e3c84Sab  * can be NULL to accept default behavior. An argument of the following
747ba4e3c84Sab  * type is used to supply them.
748ba4e3c84Sab  */
749ba4e3c84Sab typedef struct {
750ba4e3c84Sab 	char *buf;		/* Buffer to receive generated string */
751ba4e3c84Sab 	size_t bufsize;		/* sizeof(buf) */
752ba4e3c84Sab 	const char **lead_str;	/* NULL, or array of pointers to strings to */
753ba4e3c84Sab 				/*	be output at the head of the list. */
754ba4e3c84Sab 				/*	Last entry must be NULL. */
755ba4e3c84Sab 	Xword oflags;		/* Bits for which output strings are desired */
756ba4e3c84Sab 	Xword rflags;		/* Bits for which a numeric value should be */
757ba4e3c84Sab 				/*	output if vdp does not provide str. */
758ba4e3c84Sab 				/*	Must be a proper subset of oflags */
759ba4e3c84Sab 	const char *prefix;	/* NULL, or string to prefix output with */
760ba4e3c84Sab 				/*	If NULL, "[ " is used. */
761ba4e3c84Sab 	const char *sep;	/* NULL, or string to separate output items */
762ba4e3c84Sab 				/*	with. If NULL, " " is used. */
763ba4e3c84Sab 	const char *suffix;	/* NULL, or string to suffix output with */
764ba4e3c84Sab 				/*	If NULL, " ]" is used. */
765ba4e3c84Sab } CONV_EXPN_FIELD_ARG;
766ba4e3c84Sab 
767c6c9aed4Sab /*
768c6c9aed4Sab  * Callback function for conv_str_to_c_literal(). A user supplied function
769c6c9aed4Sab  * of this type is called by conv_str_to_c_literal() in order to dispatch
770c6c9aed4Sab  * the translated output characters.
771c6c9aed4Sab  *
772c6c9aed4Sab  *	buf - Pointer to output text
773c6c9aed4Sab  *	n - # of characters to output
774c6c9aed4Sab  *	uvalue - User value argument to conv_str_to_c_literal(),
775c6c9aed4Sab  *		passed through without interpretation.
776c6c9aed4Sab  */
777c6c9aed4Sab typedef	void		Conv_str_to_c_literal_func_t(const void *ptr,
778c6c9aed4Sab 			    size_t size, void *uvalue);
779c6c9aed4Sab 
7805aefb655Srie /*
7814f680cc6SAli Bahrami  * Generic miscellaneous interfaces
7827c478bd9Sstevel@tonic-gate  */
7837010c12aSrie extern	uchar_t		conv_check_native(char **, char **);
7844f680cc6SAli Bahrami extern	const char	*conv_lddstub(int);
785e23c41c9SAli Bahrami extern	int		conv_strproc_isspace(int);
786e23c41c9SAli Bahrami extern	char		*conv_strproc_trim(char *);
787e23c41c9SAli Bahrami extern	Boolean		conv_strproc_extract_value(char *, size_t, int,
788e23c41c9SAli Bahrami 			    const char **);
789e23c41c9SAli Bahrami extern	int		conv_sys_eclass(void);
79069112eddSAli Bahrami extern	int		conv_translate_c_esc(char **);
7914f680cc6SAli Bahrami 
7924f680cc6SAli Bahrami /*
7934f680cc6SAli Bahrami  * Generic core formatting and iteration functionality
7944f680cc6SAli Bahrami  */
7954f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_ds(conv_iter_osabi_t, Half,
7964f680cc6SAli Bahrami 			    const conv_ds_t **, conv_iter_cb_t, void *,
7974f680cc6SAli Bahrami 			    const char *);
7984f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_ds_msg(const conv_ds_msg_t *,
7994f680cc6SAli Bahrami 			    conv_iter_cb_t, void *, const char *);
8004f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_vd(const Val_desc *, conv_iter_cb_t,
8014f680cc6SAli Bahrami 			    void *, const char *);
8024f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_vd2(conv_iter_osabi_t, Half,
8034f680cc6SAli Bahrami 			    const Val_desc2 *, conv_iter_cb_t, void *,
8044f680cc6SAli Bahrami 			    const char *);
8054f680cc6SAli Bahrami extern	int		conv_iter_strtol_init(const char *,
8064f680cc6SAli Bahrami 			    conv_strtol_uvalue_t *);
8074f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_strtol(const char *, Conv_elfvalue_t, void *);
8084f680cc6SAli Bahrami extern	const char	*_conv_map_ds(uchar_t, Half, Conv_elfvalue_t,
8094f680cc6SAli Bahrami 			    const conv_ds_t **, Conv_fmt_flags_t,
8104f680cc6SAli Bahrami 			    Conv_inv_buf_t *, const char *);
8114f680cc6SAli Bahrami 
8124f680cc6SAli Bahrami 
8134f680cc6SAli Bahrami /*
8144f680cc6SAli Bahrami  * Generic formatting interfaces.
8154f680cc6SAli Bahrami  */
8164f680cc6SAli Bahrami extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
8174f680cc6SAli Bahrami extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
818de777a60Sab extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
819de777a60Sab extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
8205aefb655Srie extern	const char	*conv_config_upm(const char *, const char *,
8215aefb655Srie 			    const char *, size_t);
822c6c9aed4Sab extern	const char	*conv_cnote_auxv_af(Word, Conv_fmt_flags_t,
823c6c9aed4Sab 			    Conv_cnote_auxv_af_buf_t *);
824c6c9aed4Sab extern	const char	*conv_cnote_auxv_type(Word, Conv_fmt_flags_t,
825c6c9aed4Sab 			    Conv_inv_buf_t *);
826c6c9aed4Sab extern	const char	*conv_cnote_cc_content(Lword, Conv_fmt_flags_t,
827c6c9aed4Sab 			    Conv_cnote_cc_content_buf_t *);
828c6c9aed4Sab extern	const char	*conv_cnote_errno(int, Conv_fmt_flags_t,
829c6c9aed4Sab 			    Conv_inv_buf_t *);
830c6c9aed4Sab extern	const char	*conv_cnote_fault(Word, Conv_fmt_flags_t,
831c6c9aed4Sab 			    Conv_inv_buf_t *);
832c6c9aed4Sab extern	const char	*conv_cnote_fltset(uint32_t *, int,
833c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *);
834c6c9aed4Sab extern	const char	*conv_cnote_old_pr_flags(int, Conv_fmt_flags_t,
835c6c9aed4Sab 			    Conv_cnote_old_pr_flags_buf_t *);
836c6c9aed4Sab extern	const char	*conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t,
837c6c9aed4Sab 			    Conv_inv_buf_t *);
838c6c9aed4Sab extern	const char	*conv_cnote_pr_flags(int, Conv_fmt_flags_t,
839c6c9aed4Sab 			    Conv_cnote_pr_flags_buf_t *);
840c6c9aed4Sab extern	const char	*conv_cnote_proc_flag(int, Conv_fmt_flags_t,
841c6c9aed4Sab 			    Conv_cnote_proc_flag_buf_t *);
842c6c9aed4Sab extern	const char	*conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t,
843c6c9aed4Sab 			    Conv_inv_buf_t *inv_buf);
844c6c9aed4Sab extern	const char	*conv_cnote_pr_stype(Word, Conv_fmt_flags_t,
845c6c9aed4Sab 			    Conv_inv_buf_t *);
846c6c9aed4Sab extern	const char	*conv_cnote_pr_what(short, short, Conv_fmt_flags_t,
847c6c9aed4Sab 			    Conv_inv_buf_t *);
848c6c9aed4Sab extern	const char	*conv_cnote_pr_why(short, Conv_fmt_flags_t,
849c6c9aed4Sab 			    Conv_inv_buf_t *);
850c6c9aed4Sab extern	const char	*conv_cnote_priv(int, Conv_fmt_flags_t,
851c6c9aed4Sab 			    Conv_inv_buf_t *);
852d2a70789SRichard Lowe extern	const char	*conv_prsecflags(secflagset_t, Conv_fmt_flags_t,
853d2a70789SRichard Lowe 			    Conv_secflags_buf_t *);
854350ffdd5SRobert Mustacchi extern	const char	*conv_prupanic(uint32_t, Conv_fmt_flags_t,
855350ffdd5SRobert Mustacchi 			    Conv_upanic_buf_t *);
856c6c9aed4Sab extern	const char	*conv_cnote_psetid(int, Conv_fmt_flags_t,
857c6c9aed4Sab 			    Conv_inv_buf_t *);
858c6c9aed4Sab extern	const char	*conv_cnote_sa_flags(int, Conv_fmt_flags_t,
859c6c9aed4Sab 			    Conv_cnote_sa_flags_buf_t *);
860c6c9aed4Sab extern	const char	*conv_cnote_signal(Word, Conv_fmt_flags_t,
861c6c9aed4Sab 			    Conv_inv_buf_t *);
862c6c9aed4Sab extern	const char	*conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t,
863c6c9aed4Sab 			    Conv_inv_buf_t *);
864c6c9aed4Sab extern	const char	*conv_cnote_sigset(uint32_t *, int,
865c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *);
866c6c9aed4Sab extern	const char	*conv_cnote_ss_flags(int, Conv_fmt_flags_t,
867c6c9aed4Sab 			    Conv_cnote_ss_flags_buf_t *);
868c6c9aed4Sab extern	const char	*conv_cnote_syscall(Word, Conv_fmt_flags_t,
869c6c9aed4Sab 			    Conv_inv_buf_t *);
870c6c9aed4Sab extern	const char	*conv_cnote_sysset(uint32_t *, int,
871c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
87234bdffbfSGarrett D'Amore extern	const char	*conv_cnote_fileflags(uint32_t, Conv_fmt_flags_t,
87334bdffbfSGarrett D'Amore 			    char *, size_t);
87434bdffbfSGarrett D'Amore extern	const char	*conv_cnote_filemode(uint32_t, Conv_fmt_flags_t,
87534bdffbfSGarrett D'Amore 			    char *, size_t);
876c6c9aed4Sab extern	const char	*conv_cnote_type(Word, Conv_fmt_flags_t,
877c6c9aed4Sab 			    Conv_inv_buf_t *);
878de777a60Sab extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
8795aefb655Srie extern	const char	*conv_demangle_name(const char *);
880d29b2c44Sab extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
881d29b2c44Sab 			    Conv_dl_flag_buf_t *);
88298c080d5SRod Evans extern	const char	*conv_dl_info(int);
883de777a60Sab extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
8847e16fca0SAli Bahrami extern	const char	*conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t,
8857e16fca0SAli Bahrami 			    Conv_inv_buf_t *);
886de777a60Sab extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
8877e16fca0SAli Bahrami extern	const char	*conv_dwarf_regname(Half, Word, Conv_fmt_flags_t,
8887e16fca0SAli Bahrami 			    int *, Conv_inv_buf_t *);
8894f680cc6SAli Bahrami extern	const char	*conv_ehdr_abivers(uchar_t, Word, Conv_fmt_flags_t,
8904f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
8914f680cc6SAli Bahrami extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
8924f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
8934f680cc6SAli Bahrami extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
8944f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
8954f680cc6SAli Bahrami extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
8964f680cc6SAli Bahrami 			    Conv_ehdr_flags_buf_t *);
8974f680cc6SAli Bahrami extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
8984f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
8994f680cc6SAli Bahrami extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
9004f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9014f680cc6SAli Bahrami extern	const char	*conv_ehdr_type(uchar_t, Half, Conv_fmt_flags_t,
9024f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9034f680cc6SAli Bahrami extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
9044f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
905de777a60Sab extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
90669112eddSAli Bahrami extern	const char	*conv_ent_flags(ec_flags_t, Conv_ent_flags_buf_t *);
90769112eddSAli Bahrami extern	const char	*conv_ent_files_flags(Word,  Conv_fmt_flags_t fmt_flags,
90869112eddSAli Bahrami 			    Conv_ent_files_flags_buf_t *);
9092020b2b6SRod Evans extern	const char	*conv_la_activity(uint_t, Conv_fmt_flags_t,
9102020b2b6SRod Evans 			    Conv_inv_buf_t *);
9112020b2b6SRod Evans extern	const char	*conv_la_bind(uint_t, Conv_la_bind_buf_t *);
9122020b2b6SRod Evans extern	const char	*conv_la_search(uint_t, Conv_la_search_buf_t *);
9132020b2b6SRod Evans extern	const char	*conv_la_symbind(uint_t, Conv_la_symbind_buf_t *);
914de777a60Sab extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
915de777a60Sab extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
9167c478bd9Sstevel@tonic-gate extern	Isa_desc	*conv_isalist(void);
91769112eddSAli Bahrami extern	const char	*conv_mapfile_version(Word, Conv_fmt_flags_t,
91869112eddSAli Bahrami 			    Conv_inv_buf_t *);
9194f680cc6SAli Bahrami extern	const char	*conv_phdr_flags(uchar_t, Word, Conv_fmt_flags_t,
9204f680cc6SAli Bahrami 			    Conv_phdr_flags_buf_t *);
9214f680cc6SAli Bahrami extern	const char	*conv_phdr_type(uchar_t, Half, Word, Conv_fmt_flags_t,
9224f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9234f680cc6SAli Bahrami extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *,
9244f680cc6SAli Bahrami 			    Half mach);
9254f680cc6SAli Bahrami extern	const char	*conv_reloc_type(Half, Word, Conv_fmt_flags_t,
9264f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9274f680cc6SAli Bahrami extern	const char	*conv_reloc_type_static(Half, Word, Conv_fmt_flags_t);
9284f680cc6SAli Bahrami extern	const char	*conv_reloc_386_type(Word, Conv_fmt_flags_t,
9294f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9304f680cc6SAli Bahrami extern	const char	*conv_reloc_amd64_type(Word, Conv_fmt_flags_t,
9314f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9324f680cc6SAli Bahrami extern	const char	*conv_reloc_SPARC_type(Word, Conv_fmt_flags_t,
9334f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9344f680cc6SAli Bahrami extern	const char	*conv_sec_type(uchar_t, Half, Word, Conv_fmt_flags_t,
9354f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
93669112eddSAli Bahrami extern	const char	*conv_seg_flags(sg_flags_t, Conv_seg_flags_buf_t *);
937c6c9aed4Sab extern	void		conv_str_to_c_literal(const char *buf, size_t n,
938c6c9aed4Sab 			    Conv_str_to_c_literal_func_t *cb_func,
939c6c9aed4Sab 			    void *uvalue);
9404f680cc6SAli Bahrami extern	const char	*conv_sym_info_bind(uchar_t, Conv_fmt_flags_t,
9414f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9424f680cc6SAli Bahrami extern	const char	*conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t,
9434f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9444f680cc6SAli Bahrami extern	const char	*conv_sym_shndx(uchar_t, Half, Half, Conv_fmt_flags_t,
9454f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9464f680cc6SAli Bahrami extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
9474f680cc6SAli Bahrami extern	const char	*conv_sym_other_vis(uchar_t, Conv_fmt_flags_t,
9484f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9494f680cc6SAli Bahrami extern	const char	*conv_syminfo_boundto(Half, Conv_fmt_flags_t,
9504f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
9514f680cc6SAli Bahrami extern	const char	*conv_syminfo_flags(Half, Conv_fmt_flags_t,
9524f680cc6SAli Bahrami 			    Conv_syminfo_flags_buf_t *);
9532017c965SRod Evans extern	const char	*conv_time(struct timeval *, struct timeval *,
9542017c965SRod Evans 			    Conv_time_buf_t *);
9557c478bd9Sstevel@tonic-gate extern	Uts_desc	*conv_uts(void);
956090a8d9eSAli Bahrami extern	const char	*conv_ver_flags(Half, Conv_fmt_flags_t,
957090a8d9eSAli Bahrami 			    Conv_ver_flags_buf_t *);
958de777a60Sab extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
959de777a60Sab 
9605aefb655Srie 
9614f680cc6SAli Bahrami /*
9624f680cc6SAli Bahrami  * Generic iteration interfaces.
9634f680cc6SAli Bahrami  */
9644f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_tags(Conv_fmt_flags_t, conv_iter_cb_t,
9654f680cc6SAli Bahrami 			    void *);
9664f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_val_hw1(Half, Conv_fmt_flags_t,
9674f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
96808278a5eSRod Evans extern	conv_iter_ret_t	conv_iter_cap_val_hw2(Half, Conv_fmt_flags_t,
96908278a5eSRod Evans 			    conv_iter_cb_t, void *);
9704f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t,
9714f680cc6SAli Bahrami 			    void *);
972*56726c7eSRobert Mustacchi extern	conv_iter_ret_t	conv_iter_cap_val_hw3(Half, Conv_fmt_flags_t,
973*56726c7eSRobert Mustacchi 			    conv_iter_cb_t, void *);
9744f680cc6SAli Bahrami 
9754f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t,
9764f680cc6SAli Bahrami 			    void *);
9774f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_flag(Conv_fmt_flags_t, conv_iter_cb_t,
9784f680cc6SAli Bahrami 			    void *);
9794f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_flag1(Conv_fmt_flags_t, conv_iter_cb_t,
9804f680cc6SAli Bahrami 			    void *);
9814f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_posflag1(Conv_fmt_flags_t, conv_iter_cb_t,
9824f680cc6SAli Bahrami 			    void *);
9834f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_tag(conv_iter_osabi_t, Half,
9844f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9854f680cc6SAli Bahrami 
9864f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_abivers(conv_iter_osabi_t,
9874f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
9884f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_class(Conv_fmt_flags_t, conv_iter_cb_t,
9894f680cc6SAli Bahrami 			    void *);
9904f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_data(Conv_fmt_flags_t, conv_iter_cb_t,
9914f680cc6SAli Bahrami 			    void *);
9924f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_eident(Conv_fmt_flags_t, conv_iter_cb_t,
9934f680cc6SAli Bahrami 			    void *);
9944f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_flags(Half, Conv_fmt_flags_t,
9954f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
9964f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_mach(Conv_fmt_flags_t, conv_iter_cb_t,
9974f680cc6SAli Bahrami 			    void *);
9984f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_osabi(Conv_fmt_flags_t, conv_iter_cb_t,
9994f680cc6SAli Bahrami 			    void *);
10004f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
10014f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10024f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_vers(Conv_fmt_flags_t, conv_iter_cb_t,
10034f680cc6SAli Bahrami 			    void *);
10044f680cc6SAli Bahrami 
10054f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_phdr_flags(conv_iter_osabi_t,
10064f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
10074f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_phdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
10084f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10094f680cc6SAli Bahrami 
10104f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_flags(conv_iter_osabi_t, Half,
10114f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
10124f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_symtab(conv_iter_osabi_t,
10134f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
10144f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_type(conv_iter_osabi_t, Half,
10154f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
10164f680cc6SAli Bahrami 
10174f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_info_bind(Conv_fmt_flags_t,
10184f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10194f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_other_vis(Conv_fmt_flags_t,
10204f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10214f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_shndx(conv_iter_osabi_t, Half,
10224f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
10234f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_info_type(Half, Conv_fmt_flags_t,
10244f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10254f680cc6SAli Bahrami 
10264f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_syminfo_boundto(Conv_fmt_flags_t,
10274f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10284f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_syminfo_flags(Conv_fmt_flags_t,
10294f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
10304f680cc6SAli Bahrami 
10315aefb655Srie /*
10325aefb655Srie  * Define all class specific routines.
10335aefb655Srie  */
10345aefb655Srie #if	defined(_ELF64)
10355aefb655Srie #define	conv_cap_tag		conv64_cap_tag
10365aefb655Srie #define	conv_cap_val		conv64_cap_val
10375aefb655Srie #define	conv_cap_val_hw1	conv64_cap_val_hw1
103808278a5eSRod Evans #define	conv_cap_val_hw2	conv64_cap_val_hw2
1039*56726c7eSRobert Mustacchi #define	conv_cap_val_hw3	conv64_cap_val_hw3
10405aefb655Srie #define	conv_cap_val_sf1	conv64_cap_val_sf1
10415aefb655Srie #define	conv_dyn_feature1	conv64_dyn_feature1
10425aefb655Srie #define	conv_dyn_flag1		conv64_dyn_flag1
10435aefb655Srie #define	conv_dyn_flag		conv64_dyn_flag
10445aefb655Srie #define	conv_dyn_posflag1	conv64_dyn_posflag1
10455aefb655Srie #define	conv_dyn_tag		conv64_dyn_tag
10464f680cc6SAli Bahrami #define	_conv_expn_field	_conv64_expn_field
10474f680cc6SAli Bahrami #define	_conv_expn_field2	_conv64_expn_field2
10485aefb655Srie #define	conv_invalid_val	conv64_invalid_val
10495aefb655Srie #define	conv_sec_flags		conv64_sec_flags
10507010c12aSrie #define	conv_sec_linkinfo	conv64_sec_linkinfo
10515aefb655Srie #define	conv_sym_value		conv64_sym_value
10525aefb655Srie #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
10535aefb655Srie #else
10545aefb655Srie #define	conv_cap_tag		conv32_cap_tag
10555aefb655Srie #define	conv_cap_val		conv32_cap_val
10565aefb655Srie #define	conv_cap_val_hw1	conv32_cap_val_hw1
105708278a5eSRod Evans #define	conv_cap_val_hw2	conv32_cap_val_hw2
1058*56726c7eSRobert Mustacchi #define	conv_cap_val_hw3	conv32_cap_val_hw3
10595aefb655Srie #define	conv_cap_val_sf1	conv32_cap_val_sf1
10605aefb655Srie #define	conv_dyn_feature1	conv32_dyn_feature1
10615aefb655Srie #define	conv_dyn_flag1		conv32_dyn_flag1
10625aefb655Srie #define	conv_dyn_flag		conv32_dyn_flag
10635aefb655Srie #define	conv_dyn_posflag1	conv32_dyn_posflag1
10645aefb655Srie #define	conv_dyn_tag		conv32_dyn_tag
10654f680cc6SAli Bahrami #define	_conv_expn_field	_conv32_expn_field
10664f680cc6SAli Bahrami #define	_conv_expn_field2	_conv32_expn_field2
10675aefb655Srie #define	conv_invalid_val	conv32_invalid_val
10685aefb655Srie #define	conv_sec_flags		conv32_sec_flags
10697010c12aSrie #define	conv_sec_linkinfo	conv32_sec_linkinfo
10705aefb655Srie #define	conv_sym_value		conv32_sym_value
10715aefb655Srie #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
10725aefb655Srie #endif
10735aefb655Srie 
10744f680cc6SAli Bahrami /*
10754f680cc6SAli Bahrami  * ELFCLASS-specific core formatting functionality
10764f680cc6SAli Bahrami  */
10774f680cc6SAli Bahrami extern	int		_conv_expn_field(CONV_EXPN_FIELD_ARG *,
10784f680cc6SAli Bahrami 			    const Val_desc *, Conv_fmt_flags_t, const char *);
10794f680cc6SAli Bahrami extern	int		_conv_expn_field2(CONV_EXPN_FIELD_ARG *, uchar_t,
10804f680cc6SAli Bahrami 			    Half, const Val_desc2 *, Conv_fmt_flags_t,
10814f680cc6SAli Bahrami 			    const char *);
10824f680cc6SAli Bahrami extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
10834f680cc6SAli Bahrami 			    Conv_fmt_flags_t);
10844f680cc6SAli Bahrami 
10854f680cc6SAli Bahrami /*
10864f680cc6SAli Bahrami  * ELFCLASS-specific formatting interfaces.
10874f680cc6SAli Bahrami  */
10884f680cc6SAli Bahrami extern	const char	*conv_cap_tag(Xword, Conv_fmt_flags_t,
10894f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
109008278a5eSRod Evans extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_fmt_flags_t,
109108278a5eSRod Evans 			    Conv_cap_val_buf_t *);
1092d29b2c44Sab extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
1093de777a60Sab 			    Conv_cap_val_hw1_buf_t *);
109408278a5eSRod Evans extern	const char	*conv_cap_val_hw2(Xword, Half, Conv_fmt_flags_t,
109508278a5eSRod Evans 			    Conv_cap_val_hw2_buf_t *);
1096*56726c7eSRobert Mustacchi extern	const char	*conv_cap_val_hw3(Xword, Half, Conv_fmt_flags_t,
1097*56726c7eSRobert Mustacchi 			    Conv_cap_val_hw3_buf_t *);
1098d29b2c44Sab extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
1099de777a60Sab 			    Conv_cap_val_sf1_buf_t *);
1100d29b2c44Sab extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
1101d29b2c44Sab 			    Conv_dyn_flag1_buf_t *);
1102d29b2c44Sab extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
1103d29b2c44Sab 			    Conv_dyn_flag_buf_t *);
1104d29b2c44Sab extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
1105de777a60Sab 			    Conv_dyn_posflag1_buf_t *);
11064f680cc6SAli Bahrami extern	const char	*conv_dyn_tag(Xword, uchar_t, Half, Conv_fmt_flags_t,
1107d29b2c44Sab 			    Conv_inv_buf_t *);
1108d29b2c44Sab extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
1109de777a60Sab 			    Conv_dyn_feature1_buf_t *);
11104f680cc6SAli Bahrami extern	const char	*conv_sec_flags(uchar_t osabi, Half mach, Xword,
11114f680cc6SAli Bahrami 			    Conv_fmt_flags_t, Conv_sec_flags_buf_t *);
1112de777a60Sab extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
1113de777a60Sab extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
1114d29b2c44Sab extern	const char	*conv_sym_SPARC_value(Addr, Conv_fmt_flags_t,
1115d29b2c44Sab 			    Conv_inv_buf_t *);
11164f680cc6SAli Bahrami 
11174f680cc6SAli Bahrami /*
11184f680cc6SAli Bahrami  * Define macros for _conv_XXX() routines that accept local_sgs_msg as the
11194f680cc6SAli Bahrami  * final argument. The macros hide that argument from the caller's view and
11204f680cc6SAli Bahrami  * supply the SGS message array for the file from which the macro is used
11214f680cc6SAli Bahrami  * in its place. This trick is used to allow these functions to access the
11224f680cc6SAli Bahrami  * message strings from any source file they are called from.
11234f680cc6SAli Bahrami  */
11244f680cc6SAli Bahrami #define	conv_expn_field(_arg, _vdp, _fmt_flags) \
11254f680cc6SAli Bahrami     _conv_expn_field(_arg, _vdp, _fmt_flags, MSG_SGS_LOCAL_ARRAY)
11264f680cc6SAli Bahrami 
11274f680cc6SAli Bahrami #define	conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags) \
11284f680cc6SAli Bahrami     _conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags, \
11294f680cc6SAli Bahrami     MSG_SGS_LOCAL_ARRAY)
11304f680cc6SAli Bahrami 
11314f680cc6SAli Bahrami #define	conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue) \
11324f680cc6SAli Bahrami     _conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
11334f680cc6SAli Bahrami 
11344f680cc6SAli Bahrami #define	conv_iter_vd(_vdp, _func, _uvalue)	\
11354f680cc6SAli Bahrami     _conv_iter_vd(_vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
11364f680cc6SAli Bahrami 
11374f680cc6SAli Bahrami #define	conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue)		\
11384f680cc6SAli Bahrami     _conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
11394f680cc6SAli Bahrami 
11404f680cc6SAli Bahrami #define	conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf) \
11414f680cc6SAli Bahrami     _conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf, \
11424f680cc6SAli Bahrami     MSG_SGS_LOCAL_ARRAY)
11434f680cc6SAli Bahrami 
11447c478bd9Sstevel@tonic-gate 
11457c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
11467c478bd9Sstevel@tonic-gate }
11477c478bd9Sstevel@tonic-gate #endif
11487c478bd9Sstevel@tonic-gate 
11497c478bd9Sstevel@tonic-gate #endif /* _CONV_H */
1150