xref: /titanic_51/usr/src/cmd/sgs/include/conv.h (revision 37774979c2601819ef2cdb4ae1469d9111ccf52b)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 /*
36  * Global include file for conversion library.
37  */
38 
39 #include <stdlib.h>
40 #include <libelf.h>
41 #include <dlfcn.h>
42 #include <libld.h>
43 #include <sgs.h>
44 #include <machdep.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 /*
51  * Configuration features available - maintained here (instead of debug.h)
52  * to save libconv from having to include debug.h which results in numerous
53  * "declared but not used or defined" lint errors.
54  */
55 #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
56 #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
57 #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
58 #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
59 #define	CONF_DIRCFG	0x001000	/* directory configuration available */
60 #define	CONF_OBJALT	0x002000	/* object alternatives available */
61 #define	CONF_MEMRESV	0x004000	/* memory reservation required */
62 #define	CONF_ENVS	0x008000	/* environment variables available */
63 #define	CONF_FLTR	0x010000	/* filter information available */
64 #define	CONF_FEATMSK	0xffff00
65 
66 /*
67  * Buffer types:
68  *
69  * Many of the routines in this module require the user to supply a
70  * buffer into which the desired strings may be written. These are
71  * all arrays of characters, and might be defined as simple arrays
72  * of char. The problem with that approach is that when such an array
73  * is passed to a function, the C language considers it to have the
74  * type (char *), without any regard to its length. Not all of our
75  * buffers have the same length, and we want to ensure that the compiler
76  * will refuse to compile code that passes the wrong type of buffer to
77  * a given routine. The solution is to define the buffers as unions
78  * that contain the needed array, and then to pass the given union
79  * by address. The compiler will catch attempts to pass the wrong type
80  * of pointer, and the size of a structure/union is implicit in its type.
81  *
82  * A nice side effect of this approach is that we can use a union with
83  * multiple buffers to handle the cases where a given routine needs
84  * more than one type of buffer. The end result is a single buffer large
85  * enough to handle any of the subcases, but no larger.
86  */
87 
88 /*
89  * Size of buffer used by conv_invalid_val():
90  *
91  * Various values that can't be matched to a symbolic definition are converted
92  * to a numeric string.
93  *
94  * The buffer size reflects the maximum number of digits needed to
95  * display an integer as text, plus a trailing null, and with room for
96  * a leading "0x" if hexidecimal display is selected.
97  */
98 #define	CONV32_INV_BUFSIZE	12
99 typedef union {
100 	char			buf[CONV32_INV_BUFSIZE];
101 } Conv32_inv_buf_t;
102 
103 #define	CONV64_INV_BUFSIZE	22
104 typedef union {
105 	char			buf[CONV64_INV_BUFSIZE];
106 } Conv64_inv_buf_t;
107 
108 
109 
110 /* conv_ehdr_flags() */
111 #define	CONF_EHDR_FLAGS_BASE_BUFSIZE	69
112 #define	CONV32_EHDR_FLAGS_BUFSIZE	\
113 	(CONF_EHDR_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
114 typedef union {
115 	Conv32_inv_buf_t	inv_buf;
116 	char			buf[CONV32_EHDR_FLAGS_BUFSIZE];
117 } Conv32_ehdr_flags_buf_t;
118 
119 #define	CONV64_EHDR_FLAGS_BUFSIZE	\
120 	(CONF_EHDR_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
121 typedef union {
122 	Conv64_inv_buf_t	inv_buf;
123 	char			buf[CONV64_EHDR_FLAGS_BUFSIZE];
124 } Conv64_ehdr_flags_buf_t;
125 
126 
127 /* conv_reject_desc() */
128 typedef union {
129 	Conv32_inv_buf_t	inv_buf;
130 	Conv32_ehdr_flags_buf_t	flags_buf;
131 } Conv32_reject_desc_buf_t;
132 
133 typedef union {
134 	Conv64_inv_buf_t	inv_buf;
135 	Conv64_ehdr_flags_buf_t	flags_buf;
136 } Conv64_reject_desc_buf_t;
137 
138 
139 /*
140  * conv_cap_val_hw1()
141  *
142  * This size is based on the maximum number of hardware capabilities
143  * that exist.  See common/elfcap.
144  */
145 #define	CONV_CAP_VAL_HW1_BUFSIZE	195
146 
147 typedef union {
148 	Conv32_inv_buf_t	inv_buf;
149 	char			buf[CONV_CAP_VAL_HW1_BUFSIZE];
150 } Conv32_cap_val_hw1_buf_t;
151 
152 typedef union {
153 	Conv64_inv_buf_t	inv_buf;
154 	char			buf[CONV_CAP_VAL_HW1_BUFSIZE];
155 } Conv64_cap_val_hw1_buf_t;
156 
157 
158 /*
159  * conv_cap_val_sf1()
160  *
161  * This size is based on the maximum number of software capabilities
162  * that exist.  See common/elfcap.
163  */
164 #define	CONV_CAP_VAL_SF1_BUFSIZE	45
165 
166 typedef union {
167 	Conv32_inv_buf_t	inv_buf;
168 	char			buf[CONV_CAP_VAL_SF1_BUFSIZE];
169 } Conv32_cap_val_sf1_buf_t;
170 
171 typedef union {
172 	Conv64_inv_buf_t	inv_buf;
173 	char			buf[CONV_CAP_VAL_SF1_BUFSIZE];
174 } Conv64_cap_val_sf1_buf_t;
175 
176 
177 
178 /* conv_cap_val_buf() */
179 typedef union {
180 	Conv32_inv_buf_t		inv_buf;
181 	Conv32_cap_val_hw1_buf_t	cap_val_hw1_buf;
182 	Conv32_cap_val_sf1_buf_t	cap_val_sf1_buf;
183 } Conv32_cap_val_buf_t;
184 
185 typedef union {
186 	Conv64_inv_buf_t		inv_buf;
187 	Conv64_cap_val_hw1_buf_t	cap_val_hw1_buf;
188 	Conv64_cap_val_sf1_buf_t	cap_val_sf1_buf;
189 } Conv64_cap_val_buf_t;
190 
191 
192 /* conv_config_feat() */
193 #define	CONV_CONFIG_FEAT_BUFSIZE	195
194 
195 typedef union {
196 	Conv32_inv_buf_t	inv_buf;
197 	char			buf[CONV_CONFIG_FEAT_BUFSIZE];
198 } Conv32_config_feat_buf_t;
199 
200 typedef union {
201 	Conv64_inv_buf_t	inv_buf;
202 	char			buf[CONV_CONFIG_FEAT_BUFSIZE];
203 } Conv64_config_feat_buf_t;
204 
205 
206 /* conv_config_obj() */
207 #define	CONV_CONFIG_OBJ_BUFSIZE		154
208 
209 typedef union {
210 	Conv32_inv_buf_t	inv_buf;
211 	char			buf[CONV_CONFIG_OBJ_BUFSIZE];
212 } Conv32_config_obj_buf_t;
213 
214 typedef union {
215 	Conv64_inv_buf_t	inv_buf;
216 	char			buf[CONV_CONFIG_OBJ_BUFSIZE];
217 } Conv64_config_obj_buf_t;
218 
219 
220 /* conv_dl_mode() */
221 #define	CONV_DL_MODE_BUFSIZE		122
222 
223 typedef union {
224 	Conv32_inv_buf_t	inv_buf;
225 	char			buf[CONV_DL_MODE_BUFSIZE];
226 } Conv32_dl_mode_buf_t;
227 
228 typedef union {
229 	Conv64_inv_buf_t	inv_buf;
230 	char			buf[CONV_DL_MODE_BUFSIZE];
231 } Conv64_dl_mode_buf_t;
232 
233 
234 /* conv_dl_flag() */
235 #define	CONV_DL_FLAG_BUFSIZE		195
236 
237 typedef union {
238 	Conv32_inv_buf_t	inv_buf;
239 	char			buf[CONV_DL_FLAG_BUFSIZE];
240 } Conv32_dl_flag_buf_t;
241 
242 typedef union {
243 	Conv64_inv_buf_t	inv_buf;
244 	char			buf[CONV_DL_FLAG_BUFSIZE];
245 } Conv64_dl_flag_buf_t;
246 
247 
248 /* conv_grphdl_flags() */
249 #define	CONV_GRPHDL_FLAGS_BUFSIZE	80
250 
251 typedef union {
252 	Conv32_inv_buf_t	inv_buf;
253 	char			buf[CONV_GRPHDL_FLAGS_BUFSIZE];
254 } Conv32_grphdl_flags_buf_t;
255 
256 typedef union {
257 	Conv64_inv_buf_t	inv_buf;
258 	char			buf[CONV_GRPHDL_FLAGS_BUFSIZE];
259 } Conv64_grphdl_flags_buf_t;
260 
261 
262 /* conv_grpdesc_flags() */
263 #define	CONV_GRPDESC_FLAGS_BUFSIZE	80
264 
265 typedef union {
266 	Conv32_inv_buf_t	inv_buf;
267 	char			buf[CONV_GRPDESC_FLAGS_BUFSIZE];
268 } Conv32_grpdesc_flags_buf_t;
269 
270 typedef union {
271 	Conv64_inv_buf_t	inv_buf;
272 	char			buf[CONV_GRPDESC_FLAGS_BUFSIZE];
273 } Conv64_grpdesc_flags_buf_t;
274 
275 
276 /* conv_seg_flags() */
277 #define	CONV_SEG_FLAGS_BUFSIZE		186
278 
279 typedef union {
280 	Conv32_inv_buf_t	inv_buf;
281 	char			buf[CONV_SEG_FLAGS_BUFSIZE];
282 } Conv32_seg_flags_buf_t;
283 
284 typedef union {
285 	Conv64_inv_buf_t	inv_buf;
286 	char			buf[CONV_SEG_FLAGS_BUFSIZE];
287 } Conv64_seg_flags_buf_t;
288 
289 
290 /* conv_dyn_posflag1() */
291 #define	CONF_DYN_POSFLAG1_BASE_BUFSIZE	23
292 #define	CONV32_DYN_POSFLAG1_BUFSIZE	\
293 	(CONF_DYN_POSFLAG1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
294 typedef union {
295 	Conv32_inv_buf_t	inv_buf;
296 	char			buf[CONV32_DYN_POSFLAG1_BUFSIZE];
297 } Conv32_dyn_posflag1_buf_t;
298 
299 #define	CONV64_DYN_POSFLAG1_BUFSIZE	\
300 	(CONF_DYN_POSFLAG1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
301 typedef union {
302 	Conv64_inv_buf_t	inv_buf;
303 	char			buf[CONV64_DYN_POSFLAG1_BUFSIZE];
304 } Conv64_dyn_posflag1_buf_t;
305 
306 
307 /* conv_dyn_flag() */
308 #define	CONF_DYN_FLAG_BASE_BUFSIZE	48
309 #define	CONV32_DYN_FLAG_BUFSIZE	\
310 	(CONF_DYN_FLAG_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
311 typedef union {
312 	Conv32_inv_buf_t	inv_buf;
313 	char			buf[CONV32_DYN_FLAG_BUFSIZE];
314 } Conv32_dyn_flag_buf_t;
315 
316 #define	CONV64_DYN_FLAG_BUFSIZE	\
317 	(CONF_DYN_FLAG_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
318 typedef union {
319 	Conv64_inv_buf_t	inv_buf;
320 	char			buf[CONV64_DYN_FLAG_BUFSIZE];
321 } Conv64_dyn_flag_buf_t;
322 
323 
324 /* conv_dyn_flag1() */
325 #define	CONF_DYN_FLAG1_BASE_BUFSIZE	223
326 #define	CONV32_DYN_FLAG1_BUFSIZE	\
327 	(CONF_DYN_FLAG1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
328 typedef union {
329 	Conv32_inv_buf_t	inv_buf;
330 	char			buf[CONV32_DYN_FLAG1_BUFSIZE];
331 } Conv32_dyn_flag1_buf_t;
332 
333 #define	CONV64_DYN_FLAG1_BUFSIZE	\
334 	(CONF_DYN_FLAG1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
335 typedef union {
336 	Conv64_inv_buf_t	inv_buf;
337 	char			buf[CONV64_DYN_FLAG1_BUFSIZE];
338 } Conv64_dyn_flag1_buf_t;
339 
340 
341 /* conv_dyn_feature1() */
342 #define	CONF_DYN_FEATURE1_BASE_BUFSIZE	20
343 #define	CONV32_DYN_FEATURE1_BUFSIZE	\
344 	(CONF_DYN_FEATURE1_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
345 typedef union {
346 	Conv32_inv_buf_t	inv_buf;
347 	char			buf[CONV32_DYN_FEATURE1_BUFSIZE];
348 } Conv32_dyn_feature1_buf_t;
349 
350 #define	CONV64_DYN_FEATURE1_BUFSIZE	\
351 	(CONF_DYN_FEATURE1_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
352 typedef union {
353 	Conv64_inv_buf_t	inv_buf;
354 	char			buf[CONV64_DYN_FEATURE1_BUFSIZE];
355 } Conv64_dyn_feature1_buf_t;
356 
357 
358 /* conv_bnd_type() */
359 #define	CONF_BND_TYPE_BASE_BUFSIZE	29
360 #define	CONV32_BND_TYPE_BUFSIZE	\
361 	(CONF_BND_TYPE_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
362 typedef union {
363 	Conv32_inv_buf_t	inv_buf;
364 	char			buf[CONV32_BND_TYPE_BUFSIZE];
365 } Conv32_bnd_type_buf_t;
366 
367 #define	CONV64_BND_TYPE_BUFSIZE	\
368 	(CONF_BND_TYPE_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
369 typedef union {
370 	Conv64_inv_buf_t	inv_buf;
371 	char			buf[CONV64_BND_TYPE_BUFSIZE];
372 } Conv64_bnd_type_buf_t;
373 
374 
375 /* conv_bnd_obj() */
376 #define	CONF_BND_OBJ_BASE_BUFSIZE	38
377 #define	CONV32_BND_OBJ_BUFSIZE	\
378 	(CONF_BND_OBJ_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
379 typedef union {
380 	Conv32_inv_buf_t	inv_buf;
381 	char			buf[CONV32_BND_OBJ_BUFSIZE];
382 } Conv32_bnd_obj_buf_t;
383 
384 #define	CONV64_BND_OBJ_BUFSIZE	\
385 	(CONF_BND_OBJ_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
386 typedef union {
387 	Conv64_inv_buf_t	inv_buf;
388 	char			buf[CONV64_BND_OBJ_BUFSIZE];
389 } Conv64_bnd_obj_buf_t;
390 
391 
392 /* conv_phdr_flags() */
393 #define	CONF_PHDR_FLAGS_BASE_BUFSIZE	35
394 #define	CONV32_PHDR_FLAGS_BUFSIZE	\
395 	(CONF_PHDR_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
396 typedef union {
397 	Conv32_inv_buf_t	inv_buf;
398 	char			buf[CONV32_PHDR_FLAGS_BUFSIZE];
399 } Conv32_phdr_flags_buf_t;
400 
401 #define	CONV64_PHDR_FLAGS_BUFSIZE	\
402 	(CONF_PHDR_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
403 typedef union {
404 	Conv64_inv_buf_t	inv_buf;
405 	char			buf[CONV64_PHDR_FLAGS_BUFSIZE];
406 } Conv64_phdr_flags_buf_t;
407 
408 
409 /* conv_sec_flags() */
410 #define	CONF_SEC_FLAGS_BASE_BUFSIZE	168
411 #define	CONV32_SEC_FLAGS_BUFSIZE	\
412 	(CONF_SEC_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
413 typedef union {
414 	Conv32_inv_buf_t	inv_buf;
415 	char			buf[CONV32_SEC_FLAGS_BUFSIZE];
416 } Conv32_sec_flags_buf_t;
417 
418 #define	CONV64_SEC_FLAGS_BUFSIZE	\
419 	(CONF_SEC_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
420 typedef union {
421 	Conv64_inv_buf_t	inv_buf;
422 	char			buf[CONV64_SEC_FLAGS_BUFSIZE];
423 } Conv64_sec_flags_buf_t;
424 
425 
426 /* conv_dwarf_ehe() */
427 #define	CONV_DWARF_EHE_BUFSIZE		33
428 typedef union {
429 	Conv32_inv_buf_t	inv_buf;
430 	char			buf[CONV_DWARF_EHE_BUFSIZE];
431 } Conv32_dwarf_ehe_buf_t;
432 typedef union {
433 	Conv64_inv_buf_t	inv_buf;
434 	char			buf[CONV_DWARF_EHE_BUFSIZE];
435 } Conv64_dwarf_ehe_buf_t;
436 
437 
438 
439 /*
440  * Generic names for class specific buffer types above
441  */
442 #if	defined(_ELF64)
443 #define	CONV_INV_BUFSIZE		CONV64_INV_BUFSIZE
444 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV64_EHDR_FLAGS_BUFSIZE
445 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV64_DYN_POSFLAG1_BUFSIZE
446 #define	CONV_DYN_FLAG_BUFSIZE		CONV64_DYN_FLAG_BUFSIZE
447 #define	CONV_DYN_FLAG1_BUFSIZE		CONV64_DYN_FLAG1_BUFSIZE
448 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV64_DYN_FEATURE1_BUFSIZE
449 #define	CONV_BND_TYPE_BUFSIZE		CONV64_BND_TYPE_BUFSIZE
450 #define	CONV_BND_OBJ_BUFSIZE		CONV64_BND_OBJ_BUFSIZE
451 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV64_PHDR_FLAGS_BUFSIZE
452 #define	CONV_SEC_FLAGS_BUFSIZE		CONV64_SEC_FLAGS_BUFSIZE
453 
454 #define	Conv_inv_buf_t			Conv64_inv_buf_t
455 #define	Conv_ehdr_flags_buf_t		Conv64_ehdr_flags_buf_t
456 #define	Conv_reject_desc_buf_t		Conv64_reject_desc_buf_t
457 #define	Conv_cap_val_hw1_buf_t		Conv64_cap_val_hw1_buf_t
458 #define	Conv_cap_val_sf1_buf_t		Conv64_cap_val_sf1_buf_t
459 #define	Conv_cap_val_buf_t		Conv64_cap_val_buf_t
460 #define	Conv_config_feat_buf_t		Conv64_config_feat_buf_t
461 #define	Conv_config_obj_buf_t		Conv64_config_obj_buf_t
462 #define	Conv_dl_mode_buf_t		Conv64_dl_mode_buf_t
463 #define	Conv_dl_flag_buf_t		Conv64_dl_flag_buf_t
464 #define	Conv_grphdl_flags_buf_t		Conv64_grphdl_flags_buf_t
465 #define	Conv_grpdesc_flags_buf_t	Conv64_grpdesc_flags_buf_t
466 #define	Conv_seg_flags_buf_t		Conv64_seg_flags_buf_t
467 #define	Conv_dyn_posflag1_buf_t		Conv64_dyn_posflag1_buf_t
468 #define	Conv_dyn_flag_buf_t		Conv64_dyn_flag_buf_t
469 #define	Conv_dyn_flag1_buf_t		Conv64_dyn_flag1_buf_t
470 #define	Conv_dyn_feature1_buf_t		Conv64_dyn_feature1_buf_t
471 #define	Conv_bnd_type_buf_t		Conv64_bnd_type_buf_t
472 #define	Conv_bnd_obj_buf_t		Conv64_bnd_obj_buf_t
473 #define	Conv_phdr_flags_buf_t		Conv64_phdr_flags_buf_t
474 #define	Conv_sec_flags_buf_t		Conv64_sec_flags_buf_t
475 #define	Conv_dwarf_ehe_buf_t		Conv64_dwarf_ehe_buf_t
476 #else
477 #define	CONV_INV_BUFSIZE		CONV32_INV_BUFSIZE
478 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV32_EHDR_FLAGS_BUFSIZE
479 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV32_DYN_POSFLAG1_BUFSIZE
480 #define	CONV_DYN_FLAG_BUFSIZE		CONV32_DYN_FLAG_BUFSIZE
481 #define	CONV_DYN_FLAG1_BUFSIZE		CONV32_DYN_FLAG1_BUFSIZE
482 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV32_DYN_FEATURE1_BUFSIZE
483 #define	CONV_BND_TYPE_BUFSIZE		CONV32_BND_TYPE_BUFSIZE
484 #define	CONV_BND_OBJ_BUFSIZE		CONV32_BND_OBJ_BUFSIZE
485 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV32_PHDR_FLAGS_BUFSIZE
486 #define	CONV_SEC_FLAGS_BUFSIZE		CONV32_SEC_FLAGS_BUFSIZE
487 
488 #define	Conv_inv_buf_t			Conv32_inv_buf_t
489 #define	Conv_ehdr_flags_buf_t		Conv32_ehdr_flags_buf_t
490 #define	Conv_reject_desc_buf_t		Conv32_reject_desc_buf_t
491 #define	Conv_cap_val_hw1_buf_t		Conv32_cap_val_hw1_buf_t
492 #define	Conv_cap_val_sf1_buf_t		Conv32_cap_val_sf1_buf_t
493 #define	Conv_cap_val_buf_t		Conv32_cap_val_buf_t
494 #define	Conv_config_feat_buf_t		Conv32_config_feat_buf_t
495 #define	Conv_config_obj_buf_t		Conv32_config_obj_buf_t
496 #define	Conv_dl_mode_buf_t		Conv32_dl_mode_buf_t
497 #define	Conv_dl_flag_buf_t		Conv32_dl_flag_buf_t
498 #define	Conv_grphdl_flags_buf_t		Conv32_grphdl_flags_buf_t
499 #define	Conv_grpdesc_flags_buf_t	Conv32_grpdesc_flags_buf_t
500 #define	Conv_seg_flags_buf_t		Conv32_seg_flags_buf_t
501 #define	Conv_dyn_posflag1_buf_t		Conv32_dyn_posflag1_buf_t
502 #define	Conv_dyn_flag_buf_t		Conv32_dyn_flag_buf_t
503 #define	Conv_dyn_flag1_buf_t		Conv32_dyn_flag1_buf_t
504 #define	Conv_dyn_feature1_buf_t		Conv32_dyn_feature1_buf_t
505 #define	Conv_bnd_type_buf_t		Conv32_bnd_type_buf_t
506 #define	Conv_bnd_obj_buf_t		Conv32_bnd_obj_buf_t
507 #define	Conv_phdr_flags_buf_t		Conv32_phdr_flags_buf_t
508 #define	Conv_sec_flags_buf_t		Conv32_sec_flags_buf_t
509 #define	Conv_dwarf_ehe_buf_t		Conv32_dwarf_ehe_buf_t
510 #endif
511 
512 
513 
514 
515 /*
516  * Flags that alter standard formatting for conversion routines.
517  */
518 #define	CONV_FMT_DECIMAL	0x01	/* conv_invalid_val() should print */
519 					/*    integer print as decimal */
520 					/*    (default is hex) */
521 #define	CONV_FMT_SPACE		0x02	/* conv_invalid_val() should append */
522 					/*    a space after the number.  */
523 #define	CONV_FMT_ALTDUMP	0x04	/* Output strings using the versions */
524 					/*    used by the dump program. */
525 #define	CONV_FMT_ALTFILE	0x08	/* Output strings in the form used */
526 					/*    by the file(1) command */
527 #define	CONV_FMT_ALTCRLE	0x10	/* Output strings in the form used */
528 					/*    by the crle(1) command */
529 
530 /*
531  * Mask of CONV_FMT bits that reflect a desire to use alternate strings.
532  */
533 #define	CONV_FMTALTMASK	(CONV_FMT_ALTDUMP | CONV_FMT_ALTFILE)
534 
535 /*
536  * The expansion of bit-field data items is driven from a value descriptor and
537  * the conv_expn_field() routine.
538  */
539 typedef struct {
540 	Xword		v_val;		/* expansion value */
541 	const char	*v_msg;		/* associated message string */
542 } Val_desc;
543 
544 /*
545  * conv_expn_field() is willing to supply default strings for the
546  * prefix, separator, and suffix arguments, if they are passed as NULL.
547  * The caller needs to know how much room to allow for these items.
548  * These values supply those sizes.
549  */
550 #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
551 #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
552 #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
553 
554 /*
555  * conv_expn_field() requires a large number of inputs, many of which
556  * can be NULL to accept default behavior. An argument of the following
557  * type is used to supply them.
558  */
559 typedef struct {
560 	char *buf;		/* Buffer to receive generated string */
561 	size_t bufsize;		/* sizeof(buf) */
562 	const Val_desc *vdp;	/* Array of value descriptors, giving the */
563 				/*	possible bit values, and their */
564 				/*	corresponding strings. Note that the */
565 				/*	final element must contain only NULL */
566 				/*	values. This terminates the list. */
567 	const char **lead_str;	/* NULL, or array of pointers to strings to */
568 				/*	be output at the head of the list. */
569 				/*	Last entry must be NULL. */
570 	Xword oflags;		/* Bits for which output strings are desired */
571 	Xword rflags;		/* Bits for which a numeric value should be */
572 				/*	output if vdp does not provide str. */
573 				/*	Must be a proper subset of oflags */
574 	const char *prefix;	/* NULL, or string to prefix output with */
575 				/*	If NULL, "[ " is used. */
576 	const char *sep;	/* NULL, or string to separate output items */
577 				/*	with. If NULL, " " is used. */
578 	const char *suffix;	/* NULL, or string to suffix output with */
579 				/*	If NULL, " ]" is used. */
580 } CONV_EXPN_FIELD_ARG;
581 
582 /*
583  * Define all generic interfaces.
584  */
585 extern	uchar_t		conv_check_native(char **, char **);
586 extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
587 extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
588 extern	const char	*conv_config_upm(const char *, const char *,
589 			    const char *, size_t);
590 extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
591 extern	const char	*conv_demangle_name(const char *);
592 extern	const char	*conv_dl_flag(int, int, Conv_dl_flag_buf_t *);
593 extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
594 extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
595 extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
596 extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
597 extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
598 extern	Isa_desc	*conv_isalist(void);
599 extern	const char	*conv_lddstub(int);
600 extern	const char	*conv_seg_flags(Half, Conv_seg_flags_buf_t *);
601 extern	int		conv_sys_eclass();
602 extern	Uts_desc	*conv_uts(void);
603 extern	const char	*conv_ver_flags(Half);
604 extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
605 
606 
607 /*
608  * Define all class specific routines.
609  */
610 #if	defined(_ELF64)
611 #define	conv_bnd_obj		conv64_bnd_obj
612 #define	conv_bnd_type		conv64_bnd_type
613 #define	conv_cap_tag		conv64_cap_tag
614 #define	conv_cap_val		conv64_cap_val
615 #define	conv_cap_val_hw1	conv64_cap_val_hw1
616 #define	conv_cap_val_sf1	conv64_cap_val_sf1
617 #define	conv_dyn_feature1	conv64_dyn_feature1
618 #define	conv_dyn_flag1		conv64_dyn_flag1
619 #define	conv_dyn_flag		conv64_dyn_flag
620 #define	conv_dyn_posflag1	conv64_dyn_posflag1
621 #define	conv_dyn_tag		conv64_dyn_tag
622 #define	conv_ehdr_class		conv64_ehdr_class
623 #define	conv_ehdr_data		conv64_ehdr_data
624 #define	conv_ehdr_flags		conv64_ehdr_flags
625 #define	conv_ehdr_mach		conv64_ehdr_mach
626 #define	conv_ehdr_osabi		conv64_ehdr_osabi
627 #define	conv_ehdr_type		conv64_ehdr_type
628 #define	conv_ehdr_vers		conv64_ehdr_vers
629 #define	conv_expn_field		conv64_expn_field
630 #define	conv_invalid_val	conv64_invalid_val
631 #define	conv_phdr_flags		conv64_phdr_flags
632 #define	conv_phdr_type		conv64_phdr_type
633 #define	conv_reject_desc	conv64_reject_desc
634 #define	conv_reloc_type		conv64_reloc_type
635 #define	conv_reloc_type_static	conv64_reloc_type_static
636 #define	conv_reloc_386_type	conv64_reloc_386_type
637 #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
638 #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
639 #define	conv_sec_flags		conv64_sec_flags
640 #define	conv_sec_linkinfo	conv64_sec_linkinfo
641 #define	conv_sec_type		conv64_sec_type
642 #define	conv_sym_info_bind	conv64_sym_info_bind
643 #define	conv_sym_info_type	conv64_sym_info_type
644 #define	conv_sym_shndx		conv64_sym_shndx
645 #define	conv_sym_other		conv64_sym_other
646 #define	conv_sym_value		conv64_sym_value
647 #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
648 #else
649 #define	conv_bnd_obj		conv32_bnd_obj
650 #define	conv_bnd_type		conv32_bnd_type
651 #define	conv_cap_tag		conv32_cap_tag
652 #define	conv_cap_val		conv32_cap_val
653 #define	conv_cap_val_hw1	conv32_cap_val_hw1
654 #define	conv_cap_val_sf1	conv32_cap_val_sf1
655 #define	conv_dyn_feature1	conv32_dyn_feature1
656 #define	conv_dyn_flag1		conv32_dyn_flag1
657 #define	conv_dyn_flag		conv32_dyn_flag
658 #define	conv_dyn_posflag1	conv32_dyn_posflag1
659 #define	conv_dyn_tag		conv32_dyn_tag
660 #define	conv_ehdr_class		conv32_ehdr_class
661 #define	conv_ehdr_data		conv32_ehdr_data
662 #define	conv_ehdr_flags		conv32_ehdr_flags
663 #define	conv_ehdr_mach		conv32_ehdr_mach
664 #define	conv_ehdr_osabi		conv32_ehdr_osabi
665 #define	conv_ehdr_type		conv32_ehdr_type
666 #define	conv_ehdr_vers		conv32_ehdr_vers
667 #define	conv_expn_field		conv32_expn_field
668 #define	conv_invalid_val	conv32_invalid_val
669 #define	conv_phdr_flags		conv32_phdr_flags
670 #define	conv_phdr_type		conv32_phdr_type
671 #define	conv_reject_desc	conv32_reject_desc
672 #define	conv_reloc_type		conv32_reloc_type
673 #define	conv_reloc_type_static	conv32_reloc_type_static
674 #define	conv_reloc_386_type	conv32_reloc_386_type
675 #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
676 #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
677 #define	conv_sec_flags		conv32_sec_flags
678 #define	conv_sec_linkinfo	conv32_sec_linkinfo
679 #define	conv_sec_type		conv32_sec_type
680 #define	conv_sym_info_bind	conv32_sym_info_bind
681 #define	conv_sym_info_type	conv32_sym_info_type
682 #define	conv_sym_shndx		conv32_sym_shndx
683 #define	conv_sym_other		conv32_sym_other
684 #define	conv_sym_value		conv32_sym_value
685 #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
686 #endif
687 
688 extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
689 extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
690 extern	const char	*conv_cap_tag(Xword, Conv_inv_buf_t *);
691 extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *);
692 extern	const char	*conv_cap_val_hw1(Xword, Half,
693 			    Conv_cap_val_hw1_buf_t *);
694 extern	const char	*conv_cap_val_sf1(Xword, Half,
695 			    Conv_cap_val_sf1_buf_t *);
696 extern	const char	*conv_dyn_flag1(Xword, Conv_dyn_flag1_buf_t *);
697 extern	const char	*conv_dyn_flag(Xword, int, Conv_dyn_flag_buf_t *);
698 extern	const char	*conv_dyn_posflag1(Xword, int,
699 			    Conv_dyn_posflag1_buf_t *);
700 extern	const char	*conv_dyn_tag(Xword, Half, int, Conv_inv_buf_t *);
701 extern	const char	*conv_dyn_feature1(Xword, int,
702 			    Conv_dyn_feature1_buf_t *);
703 extern	const char	*conv_ehdr_class(uchar_t, int, Conv_inv_buf_t *);
704 extern	const char	*conv_ehdr_data(uchar_t, int, Conv_inv_buf_t *);
705 extern	const char	*conv_ehdr_flags(Half, Word, Conv_ehdr_flags_buf_t *);
706 extern	const char	*conv_ehdr_mach(Half, int, Conv_inv_buf_t *);
707 extern	const char	*conv_ehdr_osabi(uchar_t, int, Conv_inv_buf_t *);
708 extern	const char	*conv_ehdr_type(Half, int, Conv_inv_buf_t *);
709 extern	const char	*conv_ehdr_vers(Word, int, Conv_inv_buf_t *);
710 extern	int		conv_expn_field(CONV_EXPN_FIELD_ARG *);
711 extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword, int);
712 extern	const char	*conv_phdr_flags(Word, Conv_phdr_flags_buf_t *);
713 extern	const char	*conv_phdr_type(Half, Word, int, Conv_inv_buf_t *);
714 extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *);
715 extern	const char	*conv_reloc_type(Half, Word, int, Conv_inv_buf_t *);
716 extern	const char	*conv_reloc_type_static(Half, Word, int);
717 extern	const char	*conv_reloc_386_type(Word, int, Conv_inv_buf_t *);
718 extern	const char	*conv_reloc_amd64_type(Word, int, Conv_inv_buf_t *);
719 extern	const char	*conv_reloc_SPARC_type(Word, int, Conv_inv_buf_t *);
720 extern	const char	*conv_sec_flags(Xword, Conv_sec_flags_buf_t *);
721 extern	const char	*conv_sec_linkinfo(Word, Xword, Conv_inv_buf_t *);
722 extern	const char	*conv_sec_type(Half, Word, int, Conv_inv_buf_t *);
723 extern	const char	*conv_sym_info_bind(uchar_t, int, Conv_inv_buf_t *);
724 extern	const char	*conv_sym_info_type(Half, uchar_t, int,
725 			    Conv_inv_buf_t *);
726 extern	const char	*conv_sym_shndx(Half, Conv_inv_buf_t *);
727 extern	const char	*conv_sym_other(uchar_t, Conv_inv_buf_t *);
728 extern	const char	*conv_sym_value(Half, uchar_t, Addr, Conv_inv_buf_t *);
729 extern	const char	*conv_sym_SPARC_value(Addr, int, Conv_inv_buf_t *);
730 
731 #ifdef	__cplusplus
732 }
733 #endif
734 
735 #endif /* _CONV_H */
736