xref: /illumos-gate/usr/src/cmd/sgs/include/conv.h (revision 4f680cc6)
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  *
267e16fca0SAli Bahrami  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
275aefb655Srie  * Use is subject to license terms.
287c478bd9Sstevel@tonic-gate  */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifndef	_CONV_H
317c478bd9Sstevel@tonic-gate #define	_CONV_H
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /*
347c478bd9Sstevel@tonic-gate  * Global include file for conversion library.
357c478bd9Sstevel@tonic-gate  */
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <stdlib.h>
387c478bd9Sstevel@tonic-gate #include <libelf.h>
397c478bd9Sstevel@tonic-gate #include <dlfcn.h>
407c478bd9Sstevel@tonic-gate #include <libld.h>
417c478bd9Sstevel@tonic-gate #include <sgs.h>
42*4f680cc6SAli Bahrami #include <sgsmsg.h>
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
457c478bd9Sstevel@tonic-gate extern "C" {
467c478bd9Sstevel@tonic-gate #endif
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * Configuration features available - maintained here (instead of debug.h)
507c478bd9Sstevel@tonic-gate  * to save libconv from having to include debug.h which results in numerous
517c478bd9Sstevel@tonic-gate  * "declared but not used or defined" lint errors.
527c478bd9Sstevel@tonic-gate  */
537c478bd9Sstevel@tonic-gate #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
547c478bd9Sstevel@tonic-gate #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
557c478bd9Sstevel@tonic-gate #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
567c478bd9Sstevel@tonic-gate #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
577c478bd9Sstevel@tonic-gate #define	CONF_DIRCFG	0x001000	/* directory configuration available */
587c478bd9Sstevel@tonic-gate #define	CONF_OBJALT	0x002000	/* object alternatives available */
597c478bd9Sstevel@tonic-gate #define	CONF_MEMRESV	0x004000	/* memory reservation required */
607c478bd9Sstevel@tonic-gate #define	CONF_ENVS	0x008000	/* environment variables available */
617c478bd9Sstevel@tonic-gate #define	CONF_FLTR	0x010000	/* filter information available */
627c478bd9Sstevel@tonic-gate #define	CONF_FEATMSK	0xffff00
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
65de777a60Sab  * Buffer types:
66de777a60Sab  *
67de777a60Sab  * Many of the routines in this module require the user to supply a
68de777a60Sab  * buffer into which the desired strings may be written. These are
69de777a60Sab  * all arrays of characters, and might be defined as simple arrays
70de777a60Sab  * of char. The problem with that approach is that when such an array
71de777a60Sab  * is passed to a function, the C language considers it to have the
72de777a60Sab  * type (char *), without any regard to its length. Not all of our
73de777a60Sab  * buffers have the same length, and we want to ensure that the compiler
74de777a60Sab  * will refuse to compile code that passes the wrong type of buffer to
75de777a60Sab  * a given routine. The solution is to define the buffers as unions
76de777a60Sab  * that contain the needed array, and then to pass the given union
77de777a60Sab  * by address. The compiler will catch attempts to pass the wrong type
78de777a60Sab  * of pointer, and the size of a structure/union is implicit in its type.
79de777a60Sab  *
80de777a60Sab  * A nice side effect of this approach is that we can use a union with
81de777a60Sab  * multiple buffers to handle the cases where a given routine needs
82de777a60Sab  * more than one type of buffer. The end result is a single buffer large
83de777a60Sab  * enough to handle any of the subcases, but no larger.
84de777a60Sab  */
85de777a60Sab 
86de777a60Sab /*
87de777a60Sab  * Size of buffer used by conv_invalid_val():
88de777a60Sab  *
895aefb655Srie  * Various values that can't be matched to a symbolic definition are converted
90de777a60Sab  * to a numeric string.
915aefb655Srie  *
92de777a60Sab  * The buffer size reflects the maximum number of digits needed to
93de777a60Sab  * display an integer as text, plus a trailing null, and with room for
94de777a60Sab  * a leading "0x" if hexidecimal display is selected.
95*4f680cc6SAli Bahrami  *
96*4f680cc6SAli Bahrami  * The 32-bit version of this requires 12 characters, and the 64-bit version
97*4f680cc6SAli Bahrami  * needs 22. By using the larger value for both, we can have a single
98*4f680cc6SAli Bahrami  * definition, which is necessary for code that is ELFCLASS independent. A
99*4f680cc6SAli Bahrami  * nice side benefit is that it lets us dispense with a large number of 32/64
100*4f680cc6SAli Bahrami  * buffer size definitions that build off CONV_INV_BUFSIZE, and the macros
101*4f680cc6SAli Bahrami  * that would then be needed.
102de777a60Sab  */
103*4f680cc6SAli Bahrami #define	CONV_INV_BUFSIZE		22
104de777a60Sab typedef union {
105*4f680cc6SAli Bahrami 	char				buf[CONV_INV_BUFSIZE];
106*4f680cc6SAli Bahrami } Conv_inv_buf_t;
107de777a60Sab 
108de777a60Sab /* conv_ehdr_flags() */
109*4f680cc6SAli Bahrami #define	CONV_EHDR_FLAGS_BUFSIZE		91
110de777a60Sab typedef union {
111*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
112*4f680cc6SAli Bahrami 	char				buf[CONV_EHDR_FLAGS_BUFSIZE];
113*4f680cc6SAli Bahrami } Conv_ehdr_flags_buf_t;
114de777a60Sab 
115de777a60Sab /* conv_reject_desc() */
116de777a60Sab typedef union {
117*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
118*4f680cc6SAli Bahrami 	Conv_ehdr_flags_buf_t		flags_buf;
119*4f680cc6SAli Bahrami } Conv_reject_desc_buf_t;
120de777a60Sab 
121de777a60Sab /*
122de777a60Sab  * conv_cap_val_hw1()
123de777a60Sab  *
124de777a60Sab  * This size is based on the maximum number of hardware capabilities
125de777a60Sab  * that exist.  See common/elfcap.
126de777a60Sab  */
127de777a60Sab #define	CONV_CAP_VAL_HW1_BUFSIZE	195
128de777a60Sab typedef union {
129*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
130*4f680cc6SAli Bahrami 	char				buf[CONV_CAP_VAL_HW1_BUFSIZE];
131*4f680cc6SAli Bahrami } Conv_cap_val_hw1_buf_t;
132de777a60Sab 
133de777a60Sab /*
134de777a60Sab  * conv_cap_val_sf1()
135de777a60Sab  *
136de777a60Sab  * This size is based on the maximum number of software capabilities
137de777a60Sab  * that exist.  See common/elfcap.
138de777a60Sab  */
139de777a60Sab #define	CONV_CAP_VAL_SF1_BUFSIZE	45
140de777a60Sab typedef union {
141*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
142*4f680cc6SAli Bahrami 	char				buf[CONV_CAP_VAL_SF1_BUFSIZE];
143*4f680cc6SAli Bahrami } Conv_cap_val_sf1_buf_t;
144de777a60Sab 
145de777a60Sab /* conv_cap_val_buf() */
146de777a60Sab typedef union {
147*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
148*4f680cc6SAli Bahrami 	Conv_cap_val_hw1_buf_t		cap_val_hw1_buf;
149*4f680cc6SAli Bahrami 	Conv_cap_val_sf1_buf_t		cap_val_sf1_buf;
150*4f680cc6SAli Bahrami } Conv_cap_val_buf_t;
151de777a60Sab 
152de777a60Sab /* conv_config_feat() */
153*4f680cc6SAli Bahrami #define	CONV_CONFIG_FEAT_BUFSIZE	204
154de777a60Sab typedef union {
155*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
156*4f680cc6SAli Bahrami 	char				buf[CONV_CONFIG_FEAT_BUFSIZE];
157*4f680cc6SAli Bahrami } Conv_config_feat_buf_t;
158de777a60Sab 
159de777a60Sab /* conv_config_obj() */
160*4f680cc6SAli Bahrami #define	CONV_CONFIG_OBJ_BUFSIZE		164
161de777a60Sab typedef union {
162*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
163*4f680cc6SAli Bahrami 	char				buf[CONV_CONFIG_OBJ_BUFSIZE];
164*4f680cc6SAli Bahrami } Conv_config_obj_buf_t;
165de777a60Sab 
166de777a60Sab /* conv_dl_mode() */
167*4f680cc6SAli Bahrami #define	CONV_DL_MODE_BUFSIZE		132
168de777a60Sab typedef union {
169*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
170*4f680cc6SAli Bahrami 	char				buf[CONV_DL_MODE_BUFSIZE];
171*4f680cc6SAli Bahrami } Conv_dl_mode_buf_t;
172de777a60Sab 
173de777a60Sab /* conv_dl_flag() */
174*4f680cc6SAli Bahrami #define	CONV_DL_FLAG_BUFSIZE		185
175de777a60Sab typedef union {
176*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
177*4f680cc6SAli Bahrami 	char				buf[CONV_DL_FLAG_BUFSIZE];
178*4f680cc6SAli Bahrami } Conv_dl_flag_buf_t;
179de777a60Sab 
180de777a60Sab /* conv_grphdl_flags() */
181*4f680cc6SAli Bahrami #define	CONV_GRPHDL_FLAGS_BUFSIZE	92
182de777a60Sab typedef union {
183*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
184*4f680cc6SAli Bahrami 	char				buf[CONV_GRPHDL_FLAGS_BUFSIZE];
185*4f680cc6SAli Bahrami } Conv_grphdl_flags_buf_t;
186de777a60Sab 
187de777a60Sab /* conv_grpdesc_flags() */
188*4f680cc6SAli Bahrami #define	CONV_GRPDESC_FLAGS_BUFSIZE	102
189de777a60Sab typedef union {
190*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
191*4f680cc6SAli Bahrami 	char				buf[CONV_GRPDESC_FLAGS_BUFSIZE];
192*4f680cc6SAli Bahrami } Conv_grpdesc_flags_buf_t;
193de777a60Sab 
194de777a60Sab /* conv_seg_flags() */
195*4f680cc6SAli Bahrami #define	CONV_SEG_FLAGS_BUFSIZE		196
196de777a60Sab typedef union {
197*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
198*4f680cc6SAli Bahrami 	char				buf[CONV_SEG_FLAGS_BUFSIZE];
199*4f680cc6SAli Bahrami } Conv_seg_flags_buf_t;
200de777a60Sab 
201de777a60Sab /* conv_dyn_posflag1() */
202*4f680cc6SAli Bahrami #define	CONV_DYN_POSFLAG1_BUFSIZE	57
203de777a60Sab typedef union {
204*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
205*4f680cc6SAli Bahrami 	char				buf[CONV_DYN_POSFLAG1_BUFSIZE];
206*4f680cc6SAli Bahrami } Conv_dyn_posflag1_buf_t;
207de777a60Sab 
208de777a60Sab /* conv_dyn_flag() */
209*4f680cc6SAli Bahrami #define	CONV_DYN_FLAG_BUFSIZE		85
210de777a60Sab typedef union {
211*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
212*4f680cc6SAli Bahrami 	char				buf[CONV_DYN_FLAG_BUFSIZE];
213*4f680cc6SAli Bahrami } Conv_dyn_flag_buf_t;
214de777a60Sab 
215de777a60Sab /* conv_dyn_flag1() */
216*4f680cc6SAli Bahrami #define	CONV_DYN_FLAG1_BUFSIZE		361
217de777a60Sab typedef union {
218*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
219*4f680cc6SAli Bahrami 	char				buf[CONV_DYN_FLAG1_BUFSIZE];
220*4f680cc6SAli Bahrami } Conv_dyn_flag1_buf_t;
221de777a60Sab 
222de777a60Sab /* conv_dyn_feature1() */
223*4f680cc6SAli Bahrami #define	CONV_DYN_FEATURE1_BUFSIZE	54
224de777a60Sab typedef union {
225*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
226*4f680cc6SAli Bahrami 	char				buf[CONV_DYN_FEATURE1_BUFSIZE];
227*4f680cc6SAli Bahrami } Conv_dyn_feature1_buf_t;
228de777a60Sab 
229de777a60Sab /* conv_bnd_type() */
230*4f680cc6SAli Bahrami #define	CONV_BND_TYPE_BUFSIZE		51
231de777a60Sab typedef union {
232*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
233*4f680cc6SAli Bahrami 	char				buf[CONV_BND_TYPE_BUFSIZE];
234*4f680cc6SAli Bahrami } Conv_bnd_type_buf_t;
235de777a60Sab 
236de777a60Sab /* conv_bnd_obj() */
237*4f680cc6SAli Bahrami #define	CONV_BND_OBJ_BUFSIZE		60
238de777a60Sab typedef union {
239*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
240*4f680cc6SAli Bahrami 	char				buf[CONV_BND_OBJ_BUFSIZE];
241*4f680cc6SAli Bahrami } Conv_bnd_obj_buf_t;
242de777a60Sab 
243de777a60Sab /* conv_phdr_flags() */
244*4f680cc6SAli Bahrami #define	CONV_PHDR_FLAGS_BUFSIZE		57
245de777a60Sab typedef union {
246*4f680cc6SAli Bahrami 	Conv_inv_buf_t		inv_buf;
247*4f680cc6SAli Bahrami 	char			buf[CONV_PHDR_FLAGS_BUFSIZE];
248*4f680cc6SAli Bahrami } Conv_phdr_flags_buf_t;
249de777a60Sab 
250de777a60Sab /* conv_sec_flags() */
251*4f680cc6SAli Bahrami #define	CONV_SEC_FLAGS_BUFSIZE		190
252de777a60Sab typedef union {
253*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
254*4f680cc6SAli Bahrami 	char				buf[CONV_SEC_FLAGS_BUFSIZE];
255*4f680cc6SAli Bahrami } Conv_sec_flags_buf_t;
256de777a60Sab 
257de777a60Sab /* conv_dwarf_ehe() */
258*4f680cc6SAli Bahrami #define	CONV_DWARF_EHE_BUFSIZE		43
259de777a60Sab typedef union {
260*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
261*4f680cc6SAli Bahrami 	char				buf[CONV_DWARF_EHE_BUFSIZE];
262*4f680cc6SAli Bahrami } Conv_dwarf_ehe_buf_t;
263de777a60Sab 
264d29b2c44Sab /* conv_syminfo_flags() */
265*4f680cc6SAli Bahrami #define	CONV_SYMINFO_FLAGS_BUFSIZE	193
266d29b2c44Sab typedef union {
267*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
268*4f680cc6SAli Bahrami 	char				buf[CONV_SYMINFO_FLAGS_BUFSIZE];
269*4f680cc6SAli Bahrami } Conv_syminfo_flags_buf_t;
270d29b2c44Sab 
271c6c9aed4Sab /* conv_cnote_pr_flags() */
272*4f680cc6SAli Bahrami #define	CONV_CNOTE_PR_FLAGS_BUFSIZE	254
273c6c9aed4Sab typedef union {
274*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
275*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_PR_FLAGS_BUFSIZE];
276*4f680cc6SAli Bahrami } Conv_cnote_pr_flags_buf_t;
277c6c9aed4Sab 
278c6c9aed4Sab /* conv_cnote_old_pr_flags() */
279*4f680cc6SAli Bahrami #define	CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE	174
280c6c9aed4Sab typedef union {
281*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
282*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_OLD_PR_FLAGS_BUFSIZE];
283*4f680cc6SAli Bahrami } Conv_cnote_old_pr_flags_buf_t;
284c6c9aed4Sab 
285c6c9aed4Sab /* conv_cnote_proc_flag() */
286*4f680cc6SAli Bahrami #define	CONV_CNOTE_PROC_FLAG_BUFSIZE	39
287c6c9aed4Sab typedef union {
288*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
289*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_PROC_FLAG_BUFSIZE];
290*4f680cc6SAli Bahrami } Conv_cnote_proc_flag_buf_t;
291c6c9aed4Sab 
292c6c9aed4Sab 
293c6c9aed4Sab /* conv_cnote_sigset() */
294*4f680cc6SAli Bahrami #define	CONV_CNOTE_SIGSET_BUFSIZE	639
295c6c9aed4Sab typedef union {
296*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
297*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SIGSET_BUFSIZE];
298*4f680cc6SAli Bahrami } Conv_cnote_sigset_buf_t;
299c6c9aed4Sab 
300c6c9aed4Sab /* conv_cnote_fltset() */
301*4f680cc6SAli Bahrami #define	CONV_CNOTE_FLTSET_BUFSIZE	511
302c6c9aed4Sab typedef union {
303*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
304*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_FLTSET_BUFSIZE];
305*4f680cc6SAli Bahrami } Conv_cnote_fltset_buf_t;
306c6c9aed4Sab 
307c6c9aed4Sab /* conv_cnote_sysset() */
308*4f680cc6SAli Bahrami #define	CONV_CNOTE_SYSSET_BUFSIZE	3222
309c6c9aed4Sab typedef union {
310*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
311*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SYSSET_BUFSIZE];
312*4f680cc6SAli Bahrami } Conv_cnote_sysset_buf_t;
313c6c9aed4Sab 
314c6c9aed4Sab /* conv_cnote_sa_flags() */
315*4f680cc6SAli Bahrami #define	CONV_CNOTE_SA_FLAGS_BUFSIZE	109
316c6c9aed4Sab typedef union {
317*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
318*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SA_FLAGS_BUFSIZE];
319*4f680cc6SAli Bahrami } Conv_cnote_sa_flags_buf_t;
320c6c9aed4Sab 
321c6c9aed4Sab /* conv_cnote_ss_flags() */
322*4f680cc6SAli Bahrami #define	CONV_CNOTE_SS_FLAGS_BUFSIZE	48
323c6c9aed4Sab typedef union {
324*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
325*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_SS_FLAGS_BUFSIZE];
326*4f680cc6SAli Bahrami } Conv_cnote_ss_flags_buf_t;
327c6c9aed4Sab 
328c6c9aed4Sab /* conv_cnote_cc_content() */
329*4f680cc6SAli Bahrami #define	CONV_CNOTE_CC_CONTENT_BUFSIZE	97
330c6c9aed4Sab typedef union {
331*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
332*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_CC_CONTENT_BUFSIZE];
333*4f680cc6SAli Bahrami } Conv_cnote_cc_content_buf_t;
334c6c9aed4Sab 
335c6c9aed4Sab /* conv_cnote_auxv_af() */
336*4f680cc6SAli Bahrami #define	CONV_CNOTE_AUXV_AF_BUFSIZE	73
337c6c9aed4Sab typedef union {
338*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
339*4f680cc6SAli Bahrami 	char				buf[CONV_CNOTE_AUXV_AF_BUFSIZE];
340*4f680cc6SAli Bahrami } Conv_cnote_auxv_af_buf_t;
341c6c9aed4Sab 
342090a8d9eSAli Bahrami /* conv_ver_flags() */
343*4f680cc6SAli Bahrami #define	CONV_VER_FLAGS_BUFSIZE		41
344090a8d9eSAli Bahrami typedef union {
345*4f680cc6SAli Bahrami 	Conv_inv_buf_t			inv_buf;
346*4f680cc6SAli Bahrami 	char				buf[CONV_VER_FLAGS_BUFSIZE];
347*4f680cc6SAli Bahrami } Conv_ver_flags_buf_t;
348de777a60Sab 
349de777a60Sab 
3502926dd2eSrie 
351d29b2c44Sab /*
352d29b2c44Sab  * Many conversion routines accept a fmt_flags argument of this type
353d29b2c44Sab  * to allow the caller to modify the output. There are two parts to
354d29b2c44Sab  * this value:
355d29b2c44Sab  *
356d29b2c44Sab  *	(1) Format requests (decimal vs hex, etc...)
357d29b2c44Sab  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
358d29b2c44Sab  *		and retrieved by CONV_TYPE_FMT_ALT are integer
359d29b2c44Sab  *		values that specify that an alternate set of
360*4f680cc6SAli Bahrami  *		strings should be used.
361d29b2c44Sab  *
362*4f680cc6SAli Bahrami  * The fmt_flags value is designed such that a caller can always
363*4f680cc6SAli Bahrami  * supply a 0 in order to receive default behavior.
364d29b2c44Sab  */
365d29b2c44Sab typedef int Conv_fmt_flags_t;
366d29b2c44Sab 
367d29b2c44Sab /*
368*4f680cc6SAli Bahrami  * Type used to represent ELF constants within libconv. This relies on
369*4f680cc6SAli Bahrami  * the fact that there are no ELF constants that need more than 32-bits,
370*4f680cc6SAli Bahrami  * nor are there any signed values.
371*4f680cc6SAli Bahrami  */
372*4f680cc6SAli Bahrami typedef uint32_t Conv_elfvalue_t;
373*4f680cc6SAli Bahrami 
374*4f680cc6SAli Bahrami /*
375*4f680cc6SAli Bahrami  * Most conversion routines are able to provide strings in one of
376*4f680cc6SAli Bahrami  * several alternative styles. The bottom 8 bits of Conv_fmt_flags_t
377*4f680cc6SAli Bahrami  * are used to specify which strings should be used for a given call
378*4f680cc6SAli Bahrami  * to a conversion routine:
379*4f680cc6SAli Bahrami  *
380*4f680cc6SAli Bahrami  *   DEFAULT
381*4f680cc6SAli Bahrami  *	The default string style used by a given conversion routine is
382*4f680cc6SAli Bahrami  *	an independent choice made by that routine. Different routines
383*4f680cc6SAli Bahrami  *	make different choices, based largely on historical usage and
384*4f680cc6SAli Bahrami  *	the perceived common case. It may be an alias for one of the
385*4f680cc6SAli Bahrami  *	specific styles listed below, or it may be unique.
386*4f680cc6SAli Bahrami  *
387*4f680cc6SAli Bahrami  *   DUMP
388*4f680cc6SAli Bahrami  *	Style of strings used by dump(1).
389*4f680cc6SAli Bahrami  *
390*4f680cc6SAli Bahrami  *   FILE
391*4f680cc6SAli Bahrami  *	Style of strings used by file(1).
392*4f680cc6SAli Bahrami  *
393*4f680cc6SAli Bahrami  *   CRLE
394*4f680cc6SAli Bahrami  *	Style of strings used by crle(1).
395d29b2c44Sab  *
396*4f680cc6SAli Bahrami  *   CF
397*4f680cc6SAli Bahrami  *	Canonical Form: The string is exactly the same as the name
398*4f680cc6SAli Bahrami  *	of the #define macro that defines it in the public header files.
399*4f680cc6SAli Bahrami  *	(e.g. STB_LOCAL, not LOCL, LOCAL, LOC, or any other variation).
400*4f680cc6SAli Bahrami  *
401*4f680cc6SAli Bahrami  *   CFNP
402*4f680cc6SAli Bahrami  *	No Prefix Canonical Form: The same strings supplied by CF,
403*4f680cc6SAli Bahrami  *	but without their standard prefix. (e.g. LOCAL, instead of STT_LOCAL).
404*4f680cc6SAli Bahrami  *
405*4f680cc6SAli Bahrami  *   NF
406*4f680cc6SAli Bahrami  *	Natural Form: The form of the strings that might typically be entered
407*4f680cc6SAli Bahrami  *	via a keyboard by an interactive user. These are usually the strings
408*4f680cc6SAli Bahrami  *	from CFNP, converted to lowercase, although in some cases they may
409*4f680cc6SAli Bahrami  *	take some other "natural" form. In command completion applications,
410*4f680cc6SAli Bahrami  *	lowercase strings appear less formal, and are easier on the eye.
411*4f680cc6SAli Bahrami  *
412*4f680cc6SAli Bahrami  * Every routine is required to have a default style. The others are optional,
413*4f680cc6SAli Bahrami  * and may not be provided if not needed. If a given conversion routine does
414*4f680cc6SAli Bahrami  * not support alternative strings for a given CONV_FMT_ALT type, it silently
415*4f680cc6SAli Bahrami  * ignores the request and supplies the default set. This means that a utility
416*4f680cc6SAli Bahrami  * like dump(1) is free to specify a style like DUMP to every conversion
417d29b2c44Sab  * routine. It will receive its special strings if there are any, and
418d29b2c44Sab  * the defaults otherwise.
419d29b2c44Sab  */
420d29b2c44Sab #define	CONV_MASK_FMT_ALT		0xff
421d29b2c44Sab #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
422d29b2c44Sab 
423d29b2c44Sab #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
424*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_DUMP	1	/* dump(1) */
425*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_FILE	2	/* file(1) */
426*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_CRLE	3	/* crle(1) */
427*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_CF		4	/* Canonical Form */
428*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_CFNP	5	/* No Prefix Canonical Form */
429*4f680cc6SAli Bahrami #define	CONV_FMT_ALT_NF		6	/* Natural Form */
430d29b2c44Sab 
4315aefb655Srie /*
432c13de8f6Sab  * Flags that alter standard formatting for conversion routines.
433d29b2c44Sab  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
4345aefb655Srie  */
435d29b2c44Sab #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
436c13de8f6Sab 					/*    integer print as decimal */
437c13de8f6Sab 					/*    (default is hex) */
438d29b2c44Sab #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
439c13de8f6Sab 					/*    a space after the number.  */
440d29b2c44Sab #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
441d29b2c44Sab 					/*    prefix and suffix strings */
442c13de8f6Sab 
4435aefb655Srie /*
444*4f680cc6SAli Bahrami  * A Val_desc structure is used to associate an ELF constant and
445*4f680cc6SAli Bahrami  * the message code (Msg) for the string that corresponds to it.
446*4f680cc6SAli Bahrami  *
447*4f680cc6SAli Bahrami  * Val_desc2 adds v_osabi and v_mach fields to Val_desc, which allows
448*4f680cc6SAli Bahrami  * for non-generic mappings that apply only to a specific OSABI/machine.
449*4f680cc6SAli Bahrami  * Setting v_osabi to 0 (ELFOSABI_NONE) specifies that any OSABI matches.
450*4f680cc6SAli Bahrami  * Similarly, setting v_mach to 0 (EM_MACH) matches any machine. Hence,
451*4f680cc6SAli Bahrami  * setting v_osabi and v_mach to 0 in a Val_desc2 results in a generic item,
452*4f680cc6SAli Bahrami  * and is equivalent to simply using a Val_desc.
453*4f680cc6SAli Bahrami  *
454*4f680cc6SAli Bahrami  * These structs are used in two different contexts:
455*4f680cc6SAli Bahrami  *
456*4f680cc6SAli Bahrami  * 1)	To expand bit-field data items, using conv_expn_field() to
457*4f680cc6SAli Bahrami  *	process a NULL terminated array of Val_desc, or conv_expn_field2()
458*4f680cc6SAli Bahrami  *	to process a null terminated array of Val_desc2.
459*4f680cc6SAli Bahrami  *
460*4f680cc6SAli Bahrami  * 2)	To represent sparse ranges of non-bitfield values, referenced via
461*4f680cc6SAli Bahrami  *	conv_ds_vd_t or conv_ds_vd2_t descriptors, as described below.
4625aefb655Srie  */
4635aefb655Srie typedef struct {
464*4f680cc6SAli Bahrami 	Conv_elfvalue_t	v_val;		/* expansion value */
465*4f680cc6SAli Bahrami 	Msg		v_msg;		/* associated message string code */
4665aefb655Srie } Val_desc;
467*4f680cc6SAli Bahrami typedef struct {
468*4f680cc6SAli Bahrami 	Conv_elfvalue_t	v_val;		/* expansion value */
469*4f680cc6SAli Bahrami 	uchar_t		v_osabi;	/* OSABI to which entry applies */
470*4f680cc6SAli Bahrami 	Half		v_mach;		/* Machine to which entry applies */
471*4f680cc6SAli Bahrami 	Msg		v_msg;		/* associated message string code */
472*4f680cc6SAli Bahrami } Val_desc2;
473*4f680cc6SAli Bahrami 
474*4f680cc6SAli Bahrami /*
475*4f680cc6SAli Bahrami  * The conv_ds_XXX_t structs are used to pull together the information used
476*4f680cc6SAli Bahrami  * to map non-bitfield values to strings. They are a variant family, sharing
477*4f680cc6SAli Bahrami  * the same initial fields, with a generic "header" definition that can be
478*4f680cc6SAli Bahrami  * used to read those common fields and determine which subcase is being
479*4f680cc6SAli Bahrami  * seen. We do this instead of using a single struct containing a type code
480*4f680cc6SAli Bahrami  * and a union in order to allow for static compile-time initialization.
481*4f680cc6SAli Bahrami  *
482*4f680cc6SAli Bahrami  * conv_ds_t is the base type, containing the initial fields common to all
483*4f680cc6SAli Bahrami  * the variants. Variables of type conv_ds_t are never instantiated. This
484*4f680cc6SAli Bahrami  * type exists only to provide a common pointer type that can reference
485*4f680cc6SAli Bahrami  * any of the variants safely. In C++, it would be a virtual base class.
486*4f680cc6SAli Bahrami  * The fields common to all the variants are:
487*4f680cc6SAli Bahrami  *
488*4f680cc6SAli Bahrami  *	ds_type: Identifies the variant
489*4f680cc6SAli Bahrami  *	ds_baseval/ds_topval: The lower and upper bound of the range
490*4f680cc6SAli Bahrami  *		of values represented by this conv_ds_XXX_t descriptor.
491*4f680cc6SAli Bahrami  *
492*4f680cc6SAli Bahrami  * There are three different variants:
493*4f680cc6SAli Bahrami  *    conv_ds_msg_t (ds_type == CONV_DS_MSGARR)
494*4f680cc6SAli Bahrami  *	This structure references an array of message codes corresponding
495*4f680cc6SAli Bahrami  *	to consecutive ELF values. The first item in the array is the Msg
496*4f680cc6SAli Bahrami  *	code for the value given by ds_baseval. Consecutive strings follow
497*4f680cc6SAli Bahrami  *	in consecutive order. The final item corresponds to the value given
498*4f680cc6SAli Bahrami  *	by ds_topval. Zero (0) Msg values can be used to represent missing
499*4f680cc6SAli Bahrami  *	values. Entries with a 0 are quietly ignored.
500*4f680cc6SAli Bahrami  *
501*4f680cc6SAli Bahrami  *    conv_ds_vd_t (ds_type == CONV_DS_VD)
502*4f680cc6SAli Bahrami  *	This structure employs a NULL terminated array of Val_desc structs.
503*4f680cc6SAli Bahrami  *	Each Val_desc supplies a mapping from a value in the range
504*4f680cc6SAli Bahrami  *	(ds_baseval <= value <= ds_topval). The values described need not
505*4f680cc6SAli Bahrami  *	be consecutive, and can be sparse. ds_baseval does not need to
506*4f680cc6SAli Bahrami  *	correspond to the first item, and ds_topval need not correspond to
507*4f680cc6SAli Bahrami  *	the final item.
508*4f680cc6SAli Bahrami  *
509*4f680cc6SAli Bahrami  *    conv_ds_vd2_t (ds_type == CONV_DS_VD2)
510*4f680cc6SAli Bahrami  *	This structure employs a NULL terminated array of Val_desc2 structs,
511*4f680cc6SAli Bahrami  *	rather than Val_desc, adding the ability to specify OSABI and machine
512*4f680cc6SAli Bahrami  *	as part of the value/string mapping. It is otherwise the same thing
513*4f680cc6SAli Bahrami  *	as CONV_DS_VD.
514*4f680cc6SAli Bahrami  */
515*4f680cc6SAli Bahrami typedef enum {
516*4f680cc6SAli Bahrami 	CONV_DS_MSGARR = 0,		/* Array of Msg */
517*4f680cc6SAli Bahrami 	CONV_DS_VD = 1,			/* Null terminated array of Val_desc */
518*4f680cc6SAli Bahrami 	CONV_DS_VD2 = 2,		/* Null terminated array of Val_desc2 */
519*4f680cc6SAli Bahrami } conv_ds_type_t;
520*4f680cc6SAli Bahrami 
521*4f680cc6SAli Bahrami #define	CONV_DS_COMMON_FIELDS \
522*4f680cc6SAli Bahrami 	conv_ds_type_t	ds_type;   	/* Type of data structure used */ \
523*4f680cc6SAli Bahrami 	uint32_t	ds_baseval;	/* Value of first item */	\
524*4f680cc6SAli Bahrami 	uint32_t	ds_topval	/* Value of last item */
525*4f680cc6SAli Bahrami 
526*4f680cc6SAli Bahrami typedef struct {		/* Virtual base type --- do not instantiate */
527*4f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
528*4f680cc6SAli Bahrami } conv_ds_t;
529*4f680cc6SAli Bahrami typedef struct {
530*4f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
531*4f680cc6SAli Bahrami 	const Msg		*ds_msg;
532*4f680cc6SAli Bahrami } conv_ds_msg_t;
533*4f680cc6SAli Bahrami typedef struct {
534*4f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
535*4f680cc6SAli Bahrami 	const Val_desc		*ds_vd;
536*4f680cc6SAli Bahrami } conv_ds_vd_t;
537*4f680cc6SAli Bahrami typedef struct {
538*4f680cc6SAli Bahrami 	CONV_DS_COMMON_FIELDS;
539*4f680cc6SAli Bahrami 	const Val_desc2		*ds_vd2;
540*4f680cc6SAli Bahrami } conv_ds_vd2_t;
541*4f680cc6SAli Bahrami 
542*4f680cc6SAli Bahrami /*
543*4f680cc6SAli Bahrami  * The initialization of conv_ds_msg_t can be completely derived from
544*4f680cc6SAli Bahrami  * its base value and the array of Msg codes. CONV_DS_MSG_INIT() is used
545*4f680cc6SAli Bahrami  * to do that.
546*4f680cc6SAli Bahrami  */
547*4f680cc6SAli Bahrami #define	CONV_DS_MSG_INIT(_baseval, _arr) \
548*4f680cc6SAli Bahrami 	CONV_DS_MSGARR, _baseval, \
549*4f680cc6SAli Bahrami 	_baseval + (sizeof (_arr) / sizeof (_arr[0])) - 1, _arr
550*4f680cc6SAli Bahrami 
551*4f680cc6SAli Bahrami /*
552*4f680cc6SAli Bahrami  * Null terminated arrays of pointers to conv_ds_XXX_t structs are processed
553*4f680cc6SAli Bahrami  * by conv_map_ds() to convert ELF constants to their symbolic names, and by
554*4f680cc6SAli Bahrami  * conv_iter_ds() to iterate over all the available value/name combinations.
555*4f680cc6SAli Bahrami  *
556*4f680cc6SAli Bahrami  * These pointers are formed by casting the address of the specific
557*4f680cc6SAli Bahrami  * variant types (described above) to generic base type pointer.
558*4f680cc6SAli Bahrami  * CONV_DS_ADDR() is a convenience macro to take the address of
559*4f680cc6SAli Bahrami  * one of these variants and turn it into a generic pointer.
560*4f680cc6SAli Bahrami  */
561*4f680cc6SAli Bahrami #define	CONV_DS_ADDR(_item) ((conv_ds_t *)&(_item))
562*4f680cc6SAli Bahrami 
563*4f680cc6SAli Bahrami /*
564*4f680cc6SAli Bahrami  * Type used by libconv to represent osabi values passed to iteration
565*4f680cc6SAli Bahrami  * functions. The type in the ELF header is uchar_t. However, every possible
566*4f680cc6SAli Bahrami  * value 0-255 has a valid meaning, leaving us no extra value to assign
567*4f680cc6SAli Bahrami  * to mean "ALL". Using Half for osabi leaves us the top byte to use for
568*4f680cc6SAli Bahrami  * out of bound values.
569*4f680cc6SAli Bahrami  *
570*4f680cc6SAli Bahrami  * Non-iteration functions, and any code that does not need to use
571*4f680cc6SAli Bahrami  * CONV_OSABI_ALL, should use uchar_t for osabi.
572*4f680cc6SAli Bahrami  */
573*4f680cc6SAli Bahrami typedef Half conv_iter_osabi_t;
574*4f680cc6SAli Bahrami 
575*4f680cc6SAli Bahrami /*
576*4f680cc6SAli Bahrami  * Many of the iteration functions accept an osabi or mach argument,
577*4f680cc6SAli Bahrami  * used to specify the type of object being processed. The following
578*4f680cc6SAli Bahrami  * values can be used to specify a wildcard that matches any item. Their
579*4f680cc6SAli Bahrami  * values are carefully chosen to ensure that they cannot be interpreted
580*4f680cc6SAli Bahrami  * as an otherwise valid osabi or machine.
581*4f680cc6SAli Bahrami  */
582*4f680cc6SAli Bahrami #define	CONV_OSABI_ALL	1024	/* Larger than can be represented by uchar_t */
583*4f680cc6SAli Bahrami #define	CONV_MACH_ALL	EM_NUM	/* Never a valid machine type */
584*4f680cc6SAli Bahrami 
585*4f680cc6SAli Bahrami /*
586*4f680cc6SAli Bahrami  * We compare Val_Desc2 descriptors with a specified osabi and machine
587*4f680cc6SAli Bahrami  * to determine whether to use it or not. This macro encapsulates that logic.
588*4f680cc6SAli Bahrami  *
589*4f680cc6SAli Bahrami  * We consider an osabi to match when any of the following things hold:
590*4f680cc6SAli Bahrami  *
591*4f680cc6SAli Bahrami  * -	The descriptor osabi is ELFOSABI_NONE.
592*4f680cc6SAli Bahrami  * -	The supplied osabi and the descriptor osabi match
593*4f680cc6SAli Bahrami  * -	The supplied osabi is ELFOSABI_NONE, and the descriptor osabi is
594*4f680cc6SAli Bahrami  *	ELFOSABI_SOLARIS. Many operating systems, Solaris included,
595*4f680cc6SAli Bahrami  *	produce or have produced ELFOSABI_NONE native objects, if only
596*4f680cc6SAli Bahrami  *	because OSABI ranges are not an original ELF feature. We
597*4f680cc6SAli Bahrami  *	give our own objects the home field advantage.
598*4f680cc6SAli Bahrami  * -	Iteration Only: An osabi value of CONV_OSABI_ALL is specified.
599*4f680cc6SAli Bahrami  *
600*4f680cc6SAli Bahrami  * We consider a machine to match when any of the following things hold:
601*4f680cc6SAli Bahrami  *
602*4f680cc6SAli Bahrami  * -	The descriptor mach is EM_NONE.
603*4f680cc6SAli Bahrami  * -	The supplied mach and the descriptor mach match
604*4f680cc6SAli Bahrami  * -	Iteration Only: A mach value of CONV_MACH_ALL is specified.
605*4f680cc6SAli Bahrami  *
606*4f680cc6SAli Bahrami  * The special extra _ALL case for iteration is handled by defining a separate
607*4f680cc6SAli Bahrami  * macro with the extra CONV_xxx_ALL tests.
608*4f680cc6SAli Bahrami  */
609*4f680cc6SAli Bahrami #define	CONV_VD2_SKIP_OSABI(_osabi, _vdp) \
610*4f680cc6SAli Bahrami 	((_vdp->v_osabi != ELFOSABI_NONE) && (_vdp->v_osabi != osabi) && \
611*4f680cc6SAli Bahrami 	((_osabi != ELFOSABI_NONE) || (_vdp->v_osabi != ELFOSABI_SOLARIS)))
612*4f680cc6SAli Bahrami 
613*4f680cc6SAli Bahrami #define	CONV_VD2_SKIP_MACH(_mach, _vdp) \
614*4f680cc6SAli Bahrami 	((_vdp->v_mach != EM_NONE) && (_vdp->v_mach != _mach))
615*4f680cc6SAli Bahrami 
616*4f680cc6SAli Bahrami #define	CONV_VD2_SKIP(_osabi, _mach, _vdp) \
617*4f680cc6SAli Bahrami 	(CONV_VD2_SKIP_OSABI(_osabi, _vdp) || CONV_VD2_SKIP_MACH(_mach, _vdp))
618*4f680cc6SAli Bahrami 
619*4f680cc6SAli Bahrami #define	CONV_ITER_VD2_SKIP(_osabi, _mach, _vdp)			      \
620*4f680cc6SAli Bahrami 	((CONV_VD2_SKIP_OSABI(_osabi, _vdp) && (_osabi != CONV_OSABI_ALL)) || \
621*4f680cc6SAli Bahrami 	(CONV_VD2_SKIP_MACH(_mach, _vdp) && (_mach != CONV_MACH_ALL)))
622*4f680cc6SAli Bahrami 
623*4f680cc6SAli Bahrami 
624*4f680cc6SAli Bahrami /*
625*4f680cc6SAli Bahrami  * Possible return values from iteration functions.
626*4f680cc6SAli Bahrami  */
627*4f680cc6SAli Bahrami typedef enum {
628*4f680cc6SAli Bahrami 	CONV_ITER_DONE,		/* Stop: No more iterations are desired */
629*4f680cc6SAli Bahrami 	CONV_ITER_CONT		/* Continue with following iterations */
630*4f680cc6SAli Bahrami } conv_iter_ret_t;
631*4f680cc6SAli Bahrami 
632*4f680cc6SAli Bahrami /*
633*4f680cc6SAli Bahrami  * Prototype for caller supplied callback function to iteration functions.
634*4f680cc6SAli Bahrami  */
635*4f680cc6SAli Bahrami typedef conv_iter_ret_t (* conv_iter_cb_t)(const char *str,
636*4f680cc6SAli Bahrami     Conv_elfvalue_t value, void *uvalue);
637*4f680cc6SAli Bahrami 
638*4f680cc6SAli Bahrami /*
639*4f680cc6SAli Bahrami  * User value block employed by conv_iter_strtol()
640*4f680cc6SAli Bahrami  */
641*4f680cc6SAli Bahrami typedef struct {
642*4f680cc6SAli Bahrami 	const char	*csl_str;	/* String to search for */
643*4f680cc6SAli Bahrami 	size_t		csl_strlen;	/* # chars in csl_str to examine */
644*4f680cc6SAli Bahrami 	int		csl_found;	/* Init to 0, set to 1 if item found */
645*4f680cc6SAli Bahrami 	Conv_elfvalue_t	csl_value;	/* If csl_found, resulting value */
646*4f680cc6SAli Bahrami } conv_strtol_uvalue_t;
6475aefb655Srie 
648ba4e3c84Sab /*
649ba4e3c84Sab  * conv_expn_field() is willing to supply default strings for the
650ba4e3c84Sab  * prefix, separator, and suffix arguments, if they are passed as NULL.
651ba4e3c84Sab  * The caller needs to know how much room to allow for these items.
652ba4e3c84Sab  * These values supply those sizes.
653ba4e3c84Sab  */
654ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
655ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
656ba4e3c84Sab #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
657ba4e3c84Sab 
658ba4e3c84Sab /*
659ba4e3c84Sab  * conv_expn_field() requires a large number of inputs, many of which
660ba4e3c84Sab  * can be NULL to accept default behavior. An argument of the following
661ba4e3c84Sab  * type is used to supply them.
662ba4e3c84Sab  */
663ba4e3c84Sab typedef struct {
664ba4e3c84Sab 	char *buf;		/* Buffer to receive generated string */
665ba4e3c84Sab 	size_t bufsize;		/* sizeof(buf) */
666ba4e3c84Sab 	const char **lead_str;	/* NULL, or array of pointers to strings to */
667ba4e3c84Sab 				/*	be output at the head of the list. */
668ba4e3c84Sab 				/*	Last entry must be NULL. */
669ba4e3c84Sab 	Xword oflags;		/* Bits for which output strings are desired */
670ba4e3c84Sab 	Xword rflags;		/* Bits for which a numeric value should be */
671ba4e3c84Sab 				/*	output if vdp does not provide str. */
672ba4e3c84Sab 				/*	Must be a proper subset of oflags */
673ba4e3c84Sab 	const char *prefix;	/* NULL, or string to prefix output with */
674ba4e3c84Sab 				/*	If NULL, "[ " is used. */
675ba4e3c84Sab 	const char *sep;	/* NULL, or string to separate output items */
676ba4e3c84Sab 				/*	with. If NULL, " " is used. */
677ba4e3c84Sab 	const char *suffix;	/* NULL, or string to suffix output with */
678ba4e3c84Sab 				/*	If NULL, " ]" is used. */
679ba4e3c84Sab } CONV_EXPN_FIELD_ARG;
680ba4e3c84Sab 
681c6c9aed4Sab /*
682c6c9aed4Sab  * Callback function for conv_str_to_c_literal(). A user supplied function
683c6c9aed4Sab  * of this type is called by conv_str_to_c_literal() in order to dispatch
684c6c9aed4Sab  * the translated output characters.
685c6c9aed4Sab  *
686c6c9aed4Sab  *	buf - Pointer to output text
687c6c9aed4Sab  *	n - # of characters to output
688c6c9aed4Sab  *	uvalue - User value argument to conv_str_to_c_literal(),
689c6c9aed4Sab  *		passed through without interpretation.
690c6c9aed4Sab  */
691c6c9aed4Sab typedef	void		Conv_str_to_c_literal_func_t(const void *ptr,
692c6c9aed4Sab 			    size_t size, void *uvalue);
693c6c9aed4Sab 
6945aefb655Srie /*
695*4f680cc6SAli Bahrami  * Generic miscellaneous interfaces
6967c478bd9Sstevel@tonic-gate  */
6977010c12aSrie extern	uchar_t		conv_check_native(char **, char **);
698*4f680cc6SAli Bahrami extern	const char	*conv_lddstub(int);
699*4f680cc6SAli Bahrami extern	int		conv_sys_eclass();
700*4f680cc6SAli Bahrami 
701*4f680cc6SAli Bahrami /*
702*4f680cc6SAli Bahrami  * Generic core formatting and iteration functionality
703*4f680cc6SAli Bahrami  */
704*4f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_ds(conv_iter_osabi_t, Half,
705*4f680cc6SAli Bahrami 			    const conv_ds_t **, conv_iter_cb_t, void *,
706*4f680cc6SAli Bahrami 			    const char *);
707*4f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_ds_msg(const conv_ds_msg_t *,
708*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *, const char *);
709*4f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_vd(const Val_desc *, conv_iter_cb_t,
710*4f680cc6SAli Bahrami 			    void *, const char *);
711*4f680cc6SAli Bahrami extern	conv_iter_ret_t	_conv_iter_vd2(conv_iter_osabi_t, Half,
712*4f680cc6SAli Bahrami 			    const Val_desc2 *, conv_iter_cb_t, void *,
713*4f680cc6SAli Bahrami 			    const char *);
714*4f680cc6SAli Bahrami extern	int		conv_iter_strtol_init(const char *,
715*4f680cc6SAli Bahrami 			    conv_strtol_uvalue_t *);
716*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_strtol(const char *, Conv_elfvalue_t, void *);
717*4f680cc6SAli Bahrami extern	const char	*_conv_map_ds(uchar_t, Half, Conv_elfvalue_t,
718*4f680cc6SAli Bahrami 			    const conv_ds_t **, Conv_fmt_flags_t,
719*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *, const char *);
720*4f680cc6SAli Bahrami 
721*4f680cc6SAli Bahrami 
722*4f680cc6SAli Bahrami /*
723*4f680cc6SAli Bahrami  * Generic formatting interfaces.
724*4f680cc6SAli Bahrami  */
725*4f680cc6SAli Bahrami extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
726*4f680cc6SAli Bahrami extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
727de777a60Sab extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
728de777a60Sab extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
7295aefb655Srie extern	const char	*conv_config_upm(const char *, const char *,
7305aefb655Srie 			    const char *, size_t);
731c6c9aed4Sab extern	const char	*conv_cnote_auxv_af(Word, Conv_fmt_flags_t,
732c6c9aed4Sab 			    Conv_cnote_auxv_af_buf_t *);
733c6c9aed4Sab extern	const char	*conv_cnote_auxv_type(Word, Conv_fmt_flags_t,
734c6c9aed4Sab 			    Conv_inv_buf_t *);
735c6c9aed4Sab extern	const char	*conv_cnote_cc_content(Lword, Conv_fmt_flags_t,
736c6c9aed4Sab 			    Conv_cnote_cc_content_buf_t *);
737c6c9aed4Sab extern	const char	*conv_cnote_errno(int, Conv_fmt_flags_t,
738c6c9aed4Sab 			    Conv_inv_buf_t *);
739c6c9aed4Sab extern	const char	*conv_cnote_fault(Word, Conv_fmt_flags_t,
740c6c9aed4Sab 			    Conv_inv_buf_t *);
741c6c9aed4Sab extern	const char	*conv_cnote_fltset(uint32_t *, int,
742c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_fltset_buf_t *);
743c6c9aed4Sab extern	const char	*conv_cnote_old_pr_flags(int, Conv_fmt_flags_t,
744c6c9aed4Sab 			    Conv_cnote_old_pr_flags_buf_t *);
745c6c9aed4Sab extern	const char	*conv_cnote_pr_dmodel(Word, Conv_fmt_flags_t,
746c6c9aed4Sab 			    Conv_inv_buf_t *);
747c6c9aed4Sab extern	const char	*conv_cnote_pr_flags(int, Conv_fmt_flags_t,
748c6c9aed4Sab 			    Conv_cnote_pr_flags_buf_t *);
749c6c9aed4Sab extern	const char	*conv_cnote_proc_flag(int, Conv_fmt_flags_t,
750c6c9aed4Sab 			    Conv_cnote_proc_flag_buf_t *);
751c6c9aed4Sab extern	const char	*conv_cnote_pr_regname(Half, int, Conv_fmt_flags_t,
752c6c9aed4Sab 			    Conv_inv_buf_t *inv_buf);
753c6c9aed4Sab extern	const char	*conv_cnote_pr_stype(Word, Conv_fmt_flags_t,
754c6c9aed4Sab 			    Conv_inv_buf_t *);
755c6c9aed4Sab extern	const char	*conv_cnote_pr_what(short, short, Conv_fmt_flags_t,
756c6c9aed4Sab 			    Conv_inv_buf_t *);
757c6c9aed4Sab extern	const char	*conv_cnote_pr_why(short, Conv_fmt_flags_t,
758c6c9aed4Sab 			    Conv_inv_buf_t *);
759c6c9aed4Sab extern	const char	*conv_cnote_priv(int, Conv_fmt_flags_t,
760c6c9aed4Sab 			    Conv_inv_buf_t *);
761c6c9aed4Sab extern	const char	*conv_cnote_psetid(int, Conv_fmt_flags_t,
762c6c9aed4Sab 			    Conv_inv_buf_t *);
763c6c9aed4Sab extern	const char	*conv_cnote_sa_flags(int, Conv_fmt_flags_t,
764c6c9aed4Sab 			    Conv_cnote_sa_flags_buf_t *);
765c6c9aed4Sab extern	const char	*conv_cnote_signal(Word, Conv_fmt_flags_t,
766c6c9aed4Sab 			    Conv_inv_buf_t *);
767c6c9aed4Sab extern	const char	*conv_cnote_si_code(Half, int, int, Conv_fmt_flags_t,
768c6c9aed4Sab 			    Conv_inv_buf_t *);
769c6c9aed4Sab extern	const char	*conv_cnote_sigset(uint32_t *, int,
770c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_sigset_buf_t *);
771c6c9aed4Sab extern	const char	*conv_cnote_ss_flags(int, Conv_fmt_flags_t,
772c6c9aed4Sab 			    Conv_cnote_ss_flags_buf_t *);
773c6c9aed4Sab extern	const char	*conv_cnote_syscall(Word, Conv_fmt_flags_t,
774c6c9aed4Sab 			    Conv_inv_buf_t *);
775c6c9aed4Sab extern	const char	*conv_cnote_sysset(uint32_t *, int,
776c6c9aed4Sab 			    Conv_fmt_flags_t, Conv_cnote_sysset_buf_t *);
777c6c9aed4Sab extern	const char	*conv_cnote_type(Word, Conv_fmt_flags_t,
778c6c9aed4Sab 			    Conv_inv_buf_t *);
779de777a60Sab extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
7805aefb655Srie extern	const char	*conv_demangle_name(const char *);
781d29b2c44Sab extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
782d29b2c44Sab 			    Conv_dl_flag_buf_t *);
783de777a60Sab extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
7847e16fca0SAli Bahrami extern	const char	*conv_dwarf_cfa(uchar_t, Conv_fmt_flags_t,
7857e16fca0SAli Bahrami 			    Conv_inv_buf_t *);
786de777a60Sab extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
7877e16fca0SAli Bahrami extern	const char	*conv_dwarf_regname(Half, Word, Conv_fmt_flags_t,
7887e16fca0SAli Bahrami 			    int *, Conv_inv_buf_t *);
789*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_abivers(uchar_t, Word, Conv_fmt_flags_t,
790*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
791*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
792*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
793*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
794*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
795*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
796*4f680cc6SAli Bahrami 			    Conv_ehdr_flags_buf_t *);
797*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
798*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
799*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
800*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
801*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_type(uchar_t, Half, Conv_fmt_flags_t,
802*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
803*4f680cc6SAli Bahrami extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
804*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
805de777a60Sab extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
806de777a60Sab extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
807de777a60Sab extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
8087c478bd9Sstevel@tonic-gate extern	Isa_desc	*conv_isalist(void);
809*4f680cc6SAli Bahrami extern	const char	*conv_phdr_flags(uchar_t, Word, Conv_fmt_flags_t,
810*4f680cc6SAli Bahrami 			    Conv_phdr_flags_buf_t *);
811*4f680cc6SAli Bahrami extern	const char	*conv_phdr_type(uchar_t, Half, Word, Conv_fmt_flags_t,
812*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
813*4f680cc6SAli Bahrami extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *,
814*4f680cc6SAli Bahrami 			    Half mach);
815*4f680cc6SAli Bahrami extern	const char	*conv_reloc_type(Half, Word, Conv_fmt_flags_t,
816*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
817*4f680cc6SAli Bahrami extern	const char	*conv_reloc_type_static(Half, Word, Conv_fmt_flags_t);
818*4f680cc6SAli Bahrami extern	const char	*conv_reloc_386_type(Word, Conv_fmt_flags_t,
819*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
820*4f680cc6SAli Bahrami extern	const char	*conv_reloc_amd64_type(Word, Conv_fmt_flags_t,
821*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
822*4f680cc6SAli Bahrami extern	const char	*conv_reloc_SPARC_type(Word, Conv_fmt_flags_t,
823*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
824*4f680cc6SAli Bahrami extern	const char	*conv_sec_type(uchar_t, Half, Word, Conv_fmt_flags_t,
825*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
826de777a60Sab extern	const char	*conv_seg_flags(Half, Conv_seg_flags_buf_t *);
827c6c9aed4Sab extern	void		conv_str_to_c_literal(const char *buf, size_t n,
828c6c9aed4Sab 			    Conv_str_to_c_literal_func_t *cb_func,
829c6c9aed4Sab 			    void *uvalue);
830*4f680cc6SAli Bahrami extern	const char	*conv_sym_info_bind(uchar_t, Conv_fmt_flags_t,
831*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
832*4f680cc6SAli Bahrami extern	const char	*conv_sym_info_type(Half, uchar_t, Conv_fmt_flags_t,
833*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
834*4f680cc6SAli Bahrami extern	const char	*conv_sym_shndx(uchar_t, Half, Half, Conv_fmt_flags_t,
835*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
836*4f680cc6SAli Bahrami extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
837*4f680cc6SAli Bahrami extern	const char	*conv_sym_other_vis(uchar_t, Conv_fmt_flags_t,
838*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
839*4f680cc6SAli Bahrami extern	const char	*conv_syminfo_boundto(Half, Conv_fmt_flags_t,
840*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
841*4f680cc6SAli Bahrami extern	const char	*conv_syminfo_flags(Half, Conv_fmt_flags_t,
842*4f680cc6SAli Bahrami 			    Conv_syminfo_flags_buf_t *);
8437c478bd9Sstevel@tonic-gate extern	Uts_desc	*conv_uts(void);
844090a8d9eSAli Bahrami extern	const char	*conv_ver_flags(Half, Conv_fmt_flags_t,
845090a8d9eSAli Bahrami 			    Conv_ver_flags_buf_t *);
846de777a60Sab extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
847de777a60Sab 
8485aefb655Srie 
849*4f680cc6SAli Bahrami /*
850*4f680cc6SAli Bahrami  * Generic iteration interfaces.
851*4f680cc6SAli Bahrami  */
852*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_tags(Conv_fmt_flags_t, conv_iter_cb_t,
853*4f680cc6SAli Bahrami 			    void *);
854*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_val_hw1(Half, Conv_fmt_flags_t,
855*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
856*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_cap_val_sf1(Conv_fmt_flags_t, conv_iter_cb_t,
857*4f680cc6SAli Bahrami 			    void *);
858*4f680cc6SAli Bahrami 
859*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_feature1(Conv_fmt_flags_t, conv_iter_cb_t,
860*4f680cc6SAli Bahrami 			    void *);
861*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_flag(Conv_fmt_flags_t, conv_iter_cb_t,
862*4f680cc6SAli Bahrami 			    void *);
863*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_flag1(Conv_fmt_flags_t, conv_iter_cb_t,
864*4f680cc6SAli Bahrami 			    void *);
865*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_posflag1(Conv_fmt_flags_t, conv_iter_cb_t,
866*4f680cc6SAli Bahrami 			    void *);
867*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_dyn_tag(conv_iter_osabi_t, Half,
868*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
869*4f680cc6SAli Bahrami 
870*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_abivers(conv_iter_osabi_t,
871*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
872*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_class(Conv_fmt_flags_t, conv_iter_cb_t,
873*4f680cc6SAli Bahrami 			    void *);
874*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_data(Conv_fmt_flags_t, conv_iter_cb_t,
875*4f680cc6SAli Bahrami 			    void *);
876*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_eident(Conv_fmt_flags_t, conv_iter_cb_t,
877*4f680cc6SAli Bahrami 			    void *);
878*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_flags(Half, Conv_fmt_flags_t,
879*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
880*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_mach(Conv_fmt_flags_t, conv_iter_cb_t,
881*4f680cc6SAli Bahrami 			    void *);
882*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_osabi(Conv_fmt_flags_t, conv_iter_cb_t,
883*4f680cc6SAli Bahrami 			    void *);
884*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
885*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
886*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_ehdr_vers(Conv_fmt_flags_t, conv_iter_cb_t,
887*4f680cc6SAli Bahrami 			    void *);
888*4f680cc6SAli Bahrami 
889*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_phdr_flags(conv_iter_osabi_t,
890*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
891*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_phdr_type(conv_iter_osabi_t, Conv_fmt_flags_t,
892*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
893*4f680cc6SAli Bahrami 
894*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_flags(conv_iter_osabi_t, Half,
895*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
896*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_symtab(conv_iter_osabi_t,
897*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
898*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sec_type(conv_iter_osabi_t, Half,
899*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
900*4f680cc6SAli Bahrami 
901*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_info_bind(Conv_fmt_flags_t,
902*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
903*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_other_vis(Conv_fmt_flags_t,
904*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
905*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_shndx(conv_iter_osabi_t, Half,
906*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, conv_iter_cb_t, void *);
907*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_sym_info_type(Half, Conv_fmt_flags_t,
908*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
909*4f680cc6SAli Bahrami 
910*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_syminfo_boundto(Conv_fmt_flags_t,
911*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
912*4f680cc6SAli Bahrami extern	conv_iter_ret_t	conv_iter_syminfo_flags(Conv_fmt_flags_t,
913*4f680cc6SAli Bahrami 			    conv_iter_cb_t, void *);
914*4f680cc6SAli Bahrami 
9155aefb655Srie /*
9165aefb655Srie  * Define all class specific routines.
9175aefb655Srie  */
9185aefb655Srie #if	defined(_ELF64)
9195aefb655Srie #define	conv_cap_tag		conv64_cap_tag
9205aefb655Srie #define	conv_cap_val		conv64_cap_val
9215aefb655Srie #define	conv_cap_val_hw1	conv64_cap_val_hw1
9225aefb655Srie #define	conv_cap_val_sf1	conv64_cap_val_sf1
9235aefb655Srie #define	conv_dyn_feature1	conv64_dyn_feature1
9245aefb655Srie #define	conv_dyn_flag1		conv64_dyn_flag1
9255aefb655Srie #define	conv_dyn_flag		conv64_dyn_flag
9265aefb655Srie #define	conv_dyn_posflag1	conv64_dyn_posflag1
9275aefb655Srie #define	conv_dyn_tag		conv64_dyn_tag
928*4f680cc6SAli Bahrami #define	_conv_expn_field	_conv64_expn_field
929*4f680cc6SAli Bahrami #define	_conv_expn_field2	_conv64_expn_field2
9305aefb655Srie #define	conv_invalid_val	conv64_invalid_val
9315aefb655Srie #define	conv_sec_flags		conv64_sec_flags
9327010c12aSrie #define	conv_sec_linkinfo	conv64_sec_linkinfo
9335aefb655Srie #define	conv_sym_value		conv64_sym_value
9345aefb655Srie #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
9355aefb655Srie #else
9365aefb655Srie #define	conv_cap_tag		conv32_cap_tag
9375aefb655Srie #define	conv_cap_val		conv32_cap_val
9385aefb655Srie #define	conv_cap_val_hw1	conv32_cap_val_hw1
9395aefb655Srie #define	conv_cap_val_sf1	conv32_cap_val_sf1
9405aefb655Srie #define	conv_dyn_feature1	conv32_dyn_feature1
9415aefb655Srie #define	conv_dyn_flag1		conv32_dyn_flag1
9425aefb655Srie #define	conv_dyn_flag		conv32_dyn_flag
9435aefb655Srie #define	conv_dyn_posflag1	conv32_dyn_posflag1
9445aefb655Srie #define	conv_dyn_tag		conv32_dyn_tag
945*4f680cc6SAli Bahrami #define	_conv_expn_field	_conv32_expn_field
946*4f680cc6SAli Bahrami #define	_conv_expn_field2	_conv32_expn_field2
9475aefb655Srie #define	conv_invalid_val	conv32_invalid_val
9485aefb655Srie #define	conv_sec_flags		conv32_sec_flags
9497010c12aSrie #define	conv_sec_linkinfo	conv32_sec_linkinfo
9505aefb655Srie #define	conv_sym_value		conv32_sym_value
9515aefb655Srie #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
9525aefb655Srie #endif
9535aefb655Srie 
954*4f680cc6SAli Bahrami /*
955*4f680cc6SAli Bahrami  * ELFCLASS-specific core formatting functionality
956*4f680cc6SAli Bahrami  */
957*4f680cc6SAli Bahrami extern	int		_conv_expn_field(CONV_EXPN_FIELD_ARG *,
958*4f680cc6SAli Bahrami 			    const Val_desc *, Conv_fmt_flags_t, const char *);
959*4f680cc6SAli Bahrami extern	int		_conv_expn_field2(CONV_EXPN_FIELD_ARG *, uchar_t,
960*4f680cc6SAli Bahrami 			    Half, const Val_desc2 *, Conv_fmt_flags_t,
961*4f680cc6SAli Bahrami 			    const char *);
962*4f680cc6SAli Bahrami extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
963*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t);
964*4f680cc6SAli Bahrami 
965*4f680cc6SAli Bahrami /*
966*4f680cc6SAli Bahrami  * ELFCLASS-specific formatting interfaces.
967*4f680cc6SAli Bahrami  */
968*4f680cc6SAli Bahrami extern	const char	*conv_cap_tag(Xword, Conv_fmt_flags_t,
969*4f680cc6SAli Bahrami 			    Conv_inv_buf_t *);
970de777a60Sab extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *);
971d29b2c44Sab extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
972de777a60Sab 			    Conv_cap_val_hw1_buf_t *);
973d29b2c44Sab extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
974de777a60Sab 			    Conv_cap_val_sf1_buf_t *);
975d29b2c44Sab extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
976d29b2c44Sab 			    Conv_dyn_flag1_buf_t *);
977d29b2c44Sab extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
978d29b2c44Sab 			    Conv_dyn_flag_buf_t *);
979d29b2c44Sab extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
980de777a60Sab 			    Conv_dyn_posflag1_buf_t *);
981*4f680cc6SAli Bahrami extern	const char	*conv_dyn_tag(Xword, uchar_t, Half, Conv_fmt_flags_t,
982d29b2c44Sab 			    Conv_inv_buf_t *);
983d29b2c44Sab extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
984de777a60Sab 			    Conv_dyn_feature1_buf_t *);
985*4f680cc6SAli Bahrami extern	const char	*conv_sec_flags(uchar_t osabi, Half mach, Xword,
986*4f680cc6SAli Bahrami 			    Conv_fmt_flags_t, Conv_sec_flags_buf_t *);
987de777a60Sab extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
988de777a60Sab extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
989d29b2c44Sab extern	const char	*conv_sym_SPARC_value(Addr, Conv_fmt_flags_t,
990d29b2c44Sab 			    Conv_inv_buf_t *);
991*4f680cc6SAli Bahrami 
992*4f680cc6SAli Bahrami /*
993*4f680cc6SAli Bahrami  * Define macros for _conv_XXX() routines that accept local_sgs_msg as the
994*4f680cc6SAli Bahrami  * final argument. The macros hide that argument from the caller's view and
995*4f680cc6SAli Bahrami  * supply the SGS message array for the file from which the macro is used
996*4f680cc6SAli Bahrami  * in its place. This trick is used to allow these functions to access the
997*4f680cc6SAli Bahrami  * message strings from any source file they are called from.
998*4f680cc6SAli Bahrami  */
999*4f680cc6SAli Bahrami #define	conv_expn_field(_arg, _vdp, _fmt_flags) \
1000*4f680cc6SAli Bahrami     _conv_expn_field(_arg, _vdp, _fmt_flags, MSG_SGS_LOCAL_ARRAY)
1001*4f680cc6SAli Bahrami 
1002*4f680cc6SAli Bahrami #define	conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags) \
1003*4f680cc6SAli Bahrami     _conv_expn_field2(_arg, _osabi, _mach, _vdp, _fmt_flags, \
1004*4f680cc6SAli Bahrami     MSG_SGS_LOCAL_ARRAY)
1005*4f680cc6SAli Bahrami 
1006*4f680cc6SAli Bahrami #define	conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue) \
1007*4f680cc6SAli Bahrami     _conv_iter_ds(_osabi, _mach, _dsp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
1008*4f680cc6SAli Bahrami 
1009*4f680cc6SAli Bahrami #define	conv_iter_vd(_vdp, _func, _uvalue)	\
1010*4f680cc6SAli Bahrami     _conv_iter_vd(_vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
1011*4f680cc6SAli Bahrami 
1012*4f680cc6SAli Bahrami #define	conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue)		\
1013*4f680cc6SAli Bahrami     _conv_iter_vd2(_osabi, _mach, _vdp, _func, _uvalue, MSG_SGS_LOCAL_ARRAY)
1014*4f680cc6SAli Bahrami 
1015*4f680cc6SAli Bahrami #define	conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf) \
1016*4f680cc6SAli Bahrami     _conv_map_ds(_osabi, _mach, _value, _dsp, _fmt_flags, _inv_buf, \
1017*4f680cc6SAli Bahrami     MSG_SGS_LOCAL_ARRAY)
1018*4f680cc6SAli Bahrami 
10197c478bd9Sstevel@tonic-gate 
10207c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
10217c478bd9Sstevel@tonic-gate }
10227c478bd9Sstevel@tonic-gate #endif
10237c478bd9Sstevel@tonic-gate 
10247c478bd9Sstevel@tonic-gate #endif /* _CONV_H */
1025