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