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