xref: /titanic_50/usr/src/cmd/sgs/include/conv.h (revision 380789fc80376bd1573770361cb177a08c7e3524)
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	CONV_EHDR_FLAGS_BASE_BUFSIZE	69
112 #define	CONV32_EHDR_FLAGS_BUFSIZE	\
113 	(CONV_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 	(CONV_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	194
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		175
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	82
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	92
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	CONV_DYN_POSFLAG1_BASE_BUFSIZE	23
292 #define	CONV32_DYN_POSFLAG1_BUFSIZE	\
293 	(CONV_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 	(CONV_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	CONV_DYN_FLAG_BASE_BUFSIZE	48
309 #define	CONV32_DYN_FLAG_BUFSIZE	\
310 	(CONV_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 	(CONV_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	CONV_DYN_FLAG1_BASE_BUFSIZE	265
326 #define	CONV32_DYN_FLAG1_BUFSIZE	\
327 	(CONV_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 	(CONV_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	CONV_DYN_FEATURE1_BASE_BUFSIZE	20
343 #define	CONV32_DYN_FEATURE1_BUFSIZE	\
344 	(CONV_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 	(CONV_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	CONV_BND_TYPE_BASE_BUFSIZE	29
360 #define	CONV32_BND_TYPE_BUFSIZE	\
361 	(CONV_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 	(CONV_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	CONV_BND_OBJ_BASE_BUFSIZE	38
377 #define	CONV32_BND_OBJ_BUFSIZE	\
378 	(CONV_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 	(CONV_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	CONV_PHDR_FLAGS_BASE_BUFSIZE	35
394 #define	CONV32_PHDR_FLAGS_BUFSIZE	\
395 	(CONV_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 	(CONV_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	CONV_SEC_FLAGS_BASE_BUFSIZE	168
411 #define	CONV32_SEC_FLAGS_BUFSIZE	\
412 	(CONV_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 	(CONV_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 /* conv_syminfo_flags() */
439 #define	CONV_SYMINFO_FLAGS_BASE_BUFSIZE	36
440 #define	CONV32_SYMINFO_FLAGS_BUFSIZE	\
441 	(CONV_SYMINFO_FLAGS_BASE_BUFSIZE + CONV32_INV_BUFSIZE)
442 typedef union {
443 	Conv32_inv_buf_t	inv_buf;
444 	char			buf[CONV32_SYMINFO_FLAGS_BUFSIZE];
445 } Conv32_syminfo_flags_buf_t;
446 
447 #define	CONV64_SYMINFO_FLAGS_BUFSIZE	\
448 	(CONV_SYMINFO_FLAGS_BASE_BUFSIZE + CONV64_INV_BUFSIZE)
449 typedef union {
450 	Conv64_inv_buf_t	inv_buf;
451 	char			buf[CONV64_SYMINFO_FLAGS_BUFSIZE];
452 } Conv64_syminfo_flags_buf_t;
453 
454 
455 
456 /*
457  * Generic names for class specific buffer types above
458  */
459 #if	defined(_ELF64)
460 #define	CONV_INV_BUFSIZE		CONV64_INV_BUFSIZE
461 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV64_EHDR_FLAGS_BUFSIZE
462 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV64_DYN_POSFLAG1_BUFSIZE
463 #define	CONV_DYN_FLAG_BUFSIZE		CONV64_DYN_FLAG_BUFSIZE
464 #define	CONV_DYN_FLAG1_BUFSIZE		CONV64_DYN_FLAG1_BUFSIZE
465 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV64_DYN_FEATURE1_BUFSIZE
466 #define	CONV_BND_TYPE_BUFSIZE		CONV64_BND_TYPE_BUFSIZE
467 #define	CONV_BND_OBJ_BUFSIZE		CONV64_BND_OBJ_BUFSIZE
468 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV64_PHDR_FLAGS_BUFSIZE
469 #define	CONV_SEC_FLAGS_BUFSIZE		CONV64_SEC_FLAGS_BUFSIZE
470 #define	CONV_SYMINFO_FLAGS_BUFSIZE	CONV64_SYMINFO_FLAGS_BUFSIZE
471 
472 #define	Conv_inv_buf_t			Conv64_inv_buf_t
473 #define	Conv_ehdr_flags_buf_t		Conv64_ehdr_flags_buf_t
474 #define	Conv_reject_desc_buf_t		Conv64_reject_desc_buf_t
475 #define	Conv_cap_val_hw1_buf_t		Conv64_cap_val_hw1_buf_t
476 #define	Conv_cap_val_sf1_buf_t		Conv64_cap_val_sf1_buf_t
477 #define	Conv_cap_val_buf_t		Conv64_cap_val_buf_t
478 #define	Conv_config_feat_buf_t		Conv64_config_feat_buf_t
479 #define	Conv_config_obj_buf_t		Conv64_config_obj_buf_t
480 #define	Conv_dl_mode_buf_t		Conv64_dl_mode_buf_t
481 #define	Conv_dl_flag_buf_t		Conv64_dl_flag_buf_t
482 #define	Conv_grphdl_flags_buf_t		Conv64_grphdl_flags_buf_t
483 #define	Conv_grpdesc_flags_buf_t	Conv64_grpdesc_flags_buf_t
484 #define	Conv_seg_flags_buf_t		Conv64_seg_flags_buf_t
485 #define	Conv_dyn_posflag1_buf_t		Conv64_dyn_posflag1_buf_t
486 #define	Conv_dyn_flag_buf_t		Conv64_dyn_flag_buf_t
487 #define	Conv_dyn_flag1_buf_t		Conv64_dyn_flag1_buf_t
488 #define	Conv_dyn_feature1_buf_t		Conv64_dyn_feature1_buf_t
489 #define	Conv_bnd_type_buf_t		Conv64_bnd_type_buf_t
490 #define	Conv_bnd_obj_buf_t		Conv64_bnd_obj_buf_t
491 #define	Conv_phdr_flags_buf_t		Conv64_phdr_flags_buf_t
492 #define	Conv_sec_flags_buf_t		Conv64_sec_flags_buf_t
493 #define	Conv_dwarf_ehe_buf_t		Conv64_dwarf_ehe_buf_t
494 #define	Conv_syminfo_flags_buf_t	Conv64_syminfo_flags_buf_t
495 #else
496 #define	CONV_INV_BUFSIZE		CONV32_INV_BUFSIZE
497 #define	CONV_EHDR_FLAGS_BUFSIZE		CONV32_EHDR_FLAGS_BUFSIZE
498 #define	CONV_DYN_POSFLAG1_BUFSIZE	CONV32_DYN_POSFLAG1_BUFSIZE
499 #define	CONV_DYN_FLAG_BUFSIZE		CONV32_DYN_FLAG_BUFSIZE
500 #define	CONV_DYN_FLAG1_BUFSIZE		CONV32_DYN_FLAG1_BUFSIZE
501 #define	CONV_DYN_FEATURE1_BUFSIZE	CONV32_DYN_FEATURE1_BUFSIZE
502 #define	CONV_BND_TYPE_BUFSIZE		CONV32_BND_TYPE_BUFSIZE
503 #define	CONV_BND_OBJ_BUFSIZE		CONV32_BND_OBJ_BUFSIZE
504 #define	CONV_PHDR_FLAGS_BUFSIZE		CONV32_PHDR_FLAGS_BUFSIZE
505 #define	CONV_SEC_FLAGS_BUFSIZE		CONV32_SEC_FLAGS_BUFSIZE
506 #define	CONV_SYMINFO_FLAGS_BUFSIZE	CONV32_SYMINFO_FLAGS_BUFSIZE
507 
508 #define	Conv_inv_buf_t			Conv32_inv_buf_t
509 #define	Conv_ehdr_flags_buf_t		Conv32_ehdr_flags_buf_t
510 #define	Conv_reject_desc_buf_t		Conv32_reject_desc_buf_t
511 #define	Conv_cap_val_hw1_buf_t		Conv32_cap_val_hw1_buf_t
512 #define	Conv_cap_val_sf1_buf_t		Conv32_cap_val_sf1_buf_t
513 #define	Conv_cap_val_buf_t		Conv32_cap_val_buf_t
514 #define	Conv_config_feat_buf_t		Conv32_config_feat_buf_t
515 #define	Conv_config_obj_buf_t		Conv32_config_obj_buf_t
516 #define	Conv_dl_mode_buf_t		Conv32_dl_mode_buf_t
517 #define	Conv_dl_flag_buf_t		Conv32_dl_flag_buf_t
518 #define	Conv_grphdl_flags_buf_t		Conv32_grphdl_flags_buf_t
519 #define	Conv_grpdesc_flags_buf_t	Conv32_grpdesc_flags_buf_t
520 #define	Conv_seg_flags_buf_t		Conv32_seg_flags_buf_t
521 #define	Conv_dyn_posflag1_buf_t		Conv32_dyn_posflag1_buf_t
522 #define	Conv_dyn_flag_buf_t		Conv32_dyn_flag_buf_t
523 #define	Conv_dyn_flag1_buf_t		Conv32_dyn_flag1_buf_t
524 #define	Conv_dyn_feature1_buf_t		Conv32_dyn_feature1_buf_t
525 #define	Conv_bnd_type_buf_t		Conv32_bnd_type_buf_t
526 #define	Conv_bnd_obj_buf_t		Conv32_bnd_obj_buf_t
527 #define	Conv_phdr_flags_buf_t		Conv32_phdr_flags_buf_t
528 #define	Conv_sec_flags_buf_t		Conv32_sec_flags_buf_t
529 #define	Conv_dwarf_ehe_buf_t		Conv32_dwarf_ehe_buf_t
530 #define	Conv_syminfo_flags_buf_t	Conv32_syminfo_flags_buf_t
531 #endif
532 
533 
534 
535 
536 /*
537  * Many conversion routines accept a fmt_flags argument of this type
538  * to allow the caller to modify the output. There are two parts to
539  * this value:
540  *
541  *	(1) Format requests (decimal vs hex, etc...)
542  *	(2) The low order bits specified by CONV_MASK_FMT_ALT
543  *		and retrieved by CONV_TYPE_FMT_ALT are integer
544  *		values that specify that an alternate set of
545  *		strings should be used. This is necessary because
546  *		different utilities evolved to use different strings,
547  *		and there are backward compatability guarantees in
548  *		place that prevent changing them.
549  *
550  * These values are designed such that a caller can always supply a
551  * simple 0 in order to receive "default" behavior.
552  */
553 typedef int Conv_fmt_flags_t;
554 
555 /*
556  * The bottom 8 bits of Conv_fmt_flags_t are used to encode
557  * alternative strings.
558  *
559  * If a given conversion routine does not support alternative strings
560  * for a given CONV_FMT_ALT type, it silently ignores the request and
561  * supplies the default set. This means that a utility like dump(1) is
562  * free to specify its special type in every conversion routine call,
563  * without regard to whether it has any special meaning for that particular
564  * routine. It will receive its special strings if there are any, and
565  * the defaults otherwise.
566  */
567 #define	CONV_MASK_FMT_ALT		0xff
568 #define	CONV_TYPE_FMT_ALT(fmt_flags)	(fmt_flags & CONV_MASK_FMT_ALT)
569 
570 #define	CONV_FMT_ALT_DEFAULT	0	/* "Standard" strings */
571 #define	CONV_FMT_ALT_DUMP	1	/* Style of strings used by dump(1) */
572 #define	CONV_FMT_ALT_FILE	2	/* Style of strings used by file(1) */
573 #define	CONV_FMT_ALT_CRLE	3	/* Style of strings used by crle(1) */
574 #define	CONV_FMT_ALT_FULLNAME	4	/* Strings should be full #define */
575 					/* 	(e.g. STB_LOCAL, not LOCL) */
576 
577 /*
578  * Flags that alter standard formatting for conversion routines.
579  * These bits start after the range occupied by CONV_MASK_FMT_ALT.
580  */
581 #define	CONV_FMT_DECIMAL	0x0100	/* conv_invalid_val() should print */
582 					/*    integer print as decimal */
583 					/*    (default is hex) */
584 #define	CONV_FMT_SPACE		0x0200	/* conv_invalid_val() should append */
585 					/*    a space after the number.  */
586 #define	CONV_FMT_NOBKT		0x0400	/* conv_expn_field() should omit */
587 					/*    prefix and suffix strings */
588 
589 
590 /*
591  * The expansion of bit-field data items is driven from a value descriptor and
592  * the conv_expn_field() routine.
593  */
594 typedef struct {
595 	Xword		v_val;		/* expansion value */
596 	const char	*v_msg;		/* associated message string */
597 } Val_desc;
598 
599 /*
600  * conv_expn_field() is willing to supply default strings for the
601  * prefix, separator, and suffix arguments, if they are passed as NULL.
602  * The caller needs to know how much room to allow for these items.
603  * These values supply those sizes.
604  */
605 #define	CONV_EXPN_FIELD_DEF_PREFIX_SIZE	2	/* Default is "[ " */
606 #define	CONV_EXPN_FIELD_DEF_SEP_SIZE	1	/* Default is " " */
607 #define	CONV_EXPN_FIELD_DEF_SUFFIX_SIZE	2	/* Default is " ]" */
608 
609 /*
610  * conv_expn_field() requires a large number of inputs, many of which
611  * can be NULL to accept default behavior. An argument of the following
612  * type is used to supply them.
613  */
614 typedef struct {
615 	char *buf;		/* Buffer to receive generated string */
616 	size_t bufsize;		/* sizeof(buf) */
617 	const Val_desc *vdp;	/* Array of value descriptors, giving the */
618 				/*	possible bit values, and their */
619 				/*	corresponding strings. Note that the */
620 				/*	final element must contain only NULL */
621 				/*	values. This terminates the list. */
622 	const char **lead_str;	/* NULL, or array of pointers to strings to */
623 				/*	be output at the head of the list. */
624 				/*	Last entry must be NULL. */
625 	Xword oflags;		/* Bits for which output strings are desired */
626 	Xword rflags;		/* Bits for which a numeric value should be */
627 				/*	output if vdp does not provide str. */
628 				/*	Must be a proper subset of oflags */
629 	const char *prefix;	/* NULL, or string to prefix output with */
630 				/*	If NULL, "[ " is used. */
631 	const char *sep;	/* NULL, or string to separate output items */
632 				/*	with. If NULL, " " is used. */
633 	const char *suffix;	/* NULL, or string to suffix output with */
634 				/*	If NULL, " ]" is used. */
635 } CONV_EXPN_FIELD_ARG;
636 
637 /*
638  * Define all generic interfaces.
639  */
640 extern	uchar_t		conv_check_native(char **, char **);
641 extern	const char	*conv_config_feat(int, Conv_config_feat_buf_t *);
642 extern	const char	*conv_config_obj(ushort_t, Conv_config_obj_buf_t *);
643 extern	const char	*conv_config_upm(const char *, const char *,
644 			    const char *, size_t);
645 extern	const char	*conv_def_tag(Symref, Conv_inv_buf_t *);
646 extern	const char	*conv_demangle_name(const char *);
647 extern	const char	*conv_dl_flag(int, Conv_fmt_flags_t,
648 			    Conv_dl_flag_buf_t *);
649 extern	const char	*conv_dl_mode(int, int, Conv_dl_mode_buf_t *);
650 extern	const char	*conv_dwarf_ehe(uint_t, Conv_dwarf_ehe_buf_t *);
651 extern	const char	*conv_elfdata_type(Elf_Type, Conv_inv_buf_t *);
652 extern	const char	*conv_grphdl_flags(uint_t, Conv_grphdl_flags_buf_t *);
653 extern	const char	*conv_grpdesc_flags(uint_t, Conv_grpdesc_flags_buf_t *);
654 extern	Isa_desc	*conv_isalist(void);
655 extern	const char	*conv_lddstub(int);
656 extern	const char	*conv_seg_flags(Half, Conv_seg_flags_buf_t *);
657 extern	int		conv_sys_eclass();
658 extern	Uts_desc	*conv_uts(void);
659 extern	const char	*conv_ver_flags(Half);
660 extern	const char	*conv_ver_index(Versym, int, Conv_inv_buf_t *);
661 
662 
663 /*
664  * Define all class specific routines.
665  */
666 #if	defined(_ELF64)
667 #define	conv_bnd_obj		conv64_bnd_obj
668 #define	conv_bnd_type		conv64_bnd_type
669 #define	conv_cap_tag		conv64_cap_tag
670 #define	conv_cap_val		conv64_cap_val
671 #define	conv_cap_val_hw1	conv64_cap_val_hw1
672 #define	conv_cap_val_sf1	conv64_cap_val_sf1
673 #define	conv_dyn_feature1	conv64_dyn_feature1
674 #define	conv_dyn_flag1		conv64_dyn_flag1
675 #define	conv_dyn_flag		conv64_dyn_flag
676 #define	conv_dyn_posflag1	conv64_dyn_posflag1
677 #define	conv_dyn_tag		conv64_dyn_tag
678 #define	conv_ehdr_class		conv64_ehdr_class
679 #define	conv_ehdr_data		conv64_ehdr_data
680 #define	conv_ehdr_flags		conv64_ehdr_flags
681 #define	conv_ehdr_mach		conv64_ehdr_mach
682 #define	conv_ehdr_osabi		conv64_ehdr_osabi
683 #define	conv_ehdr_type		conv64_ehdr_type
684 #define	conv_ehdr_vers		conv64_ehdr_vers
685 #define	conv_expn_field		conv64_expn_field
686 #define	conv_invalid_val	conv64_invalid_val
687 #define	conv_phdr_flags		conv64_phdr_flags
688 #define	conv_phdr_type		conv64_phdr_type
689 #define	conv_reject_desc	conv64_reject_desc
690 #define	conv_reloc_type		conv64_reloc_type
691 #define	conv_reloc_type_static	conv64_reloc_type_static
692 #define	conv_reloc_386_type	conv64_reloc_386_type
693 #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
694 #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
695 #define	conv_sec_flags		conv64_sec_flags
696 #define	conv_sec_linkinfo	conv64_sec_linkinfo
697 #define	conv_sec_type		conv64_sec_type
698 #define	conv_sym_info_bind	conv64_sym_info_bind
699 #define	conv_sym_info_type	conv64_sym_info_type
700 #define	conv_sym_shndx		conv64_sym_shndx
701 #define	conv_sym_other		conv64_sym_other
702 #define	conv_sym_other_vis	conv64_sym_other_vis
703 #define	conv_sym_value		conv64_sym_value
704 #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
705 #define	conv_syminfo_flags	conv64_syminfo_flags
706 #else
707 #define	conv_bnd_obj		conv32_bnd_obj
708 #define	conv_bnd_type		conv32_bnd_type
709 #define	conv_cap_tag		conv32_cap_tag
710 #define	conv_cap_val		conv32_cap_val
711 #define	conv_cap_val_hw1	conv32_cap_val_hw1
712 #define	conv_cap_val_sf1	conv32_cap_val_sf1
713 #define	conv_dyn_feature1	conv32_dyn_feature1
714 #define	conv_dyn_flag1		conv32_dyn_flag1
715 #define	conv_dyn_flag		conv32_dyn_flag
716 #define	conv_dyn_posflag1	conv32_dyn_posflag1
717 #define	conv_dyn_tag		conv32_dyn_tag
718 #define	conv_ehdr_class		conv32_ehdr_class
719 #define	conv_ehdr_data		conv32_ehdr_data
720 #define	conv_ehdr_flags		conv32_ehdr_flags
721 #define	conv_ehdr_mach		conv32_ehdr_mach
722 #define	conv_ehdr_osabi		conv32_ehdr_osabi
723 #define	conv_ehdr_type		conv32_ehdr_type
724 #define	conv_ehdr_vers		conv32_ehdr_vers
725 #define	conv_expn_field		conv32_expn_field
726 #define	conv_invalid_val	conv32_invalid_val
727 #define	conv_phdr_flags		conv32_phdr_flags
728 #define	conv_phdr_type		conv32_phdr_type
729 #define	conv_reject_desc	conv32_reject_desc
730 #define	conv_reloc_type		conv32_reloc_type
731 #define	conv_reloc_type_static	conv32_reloc_type_static
732 #define	conv_reloc_386_type	conv32_reloc_386_type
733 #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
734 #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
735 #define	conv_sec_flags		conv32_sec_flags
736 #define	conv_sec_linkinfo	conv32_sec_linkinfo
737 #define	conv_sec_type		conv32_sec_type
738 #define	conv_sym_info_bind	conv32_sym_info_bind
739 #define	conv_sym_info_type	conv32_sym_info_type
740 #define	conv_sym_shndx		conv32_sym_shndx
741 #define	conv_sym_other		conv32_sym_other
742 #define	conv_sym_other_vis	conv32_sym_other_vis
743 #define	conv_sym_value		conv32_sym_value
744 #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
745 #define	conv_syminfo_flags	conv32_syminfo_flags
746 #endif
747 
748 extern	const char	*conv_bnd_obj(uint_t, Conv_bnd_obj_buf_t *);
749 extern	const char	*conv_bnd_type(uint_t, Conv_bnd_type_buf_t *);
750 extern	const char	*conv_cap_tag(Xword, Conv_inv_buf_t *);
751 extern	const char	*conv_cap_val(Xword, Xword, Half, Conv_cap_val_buf_t *);
752 extern	const char	*conv_cap_val_hw1(Xword, Half, Conv_fmt_flags_t,
753 			    Conv_cap_val_hw1_buf_t *);
754 extern	const char	*conv_cap_val_sf1(Xword, Half, Conv_fmt_flags_t,
755 			    Conv_cap_val_sf1_buf_t *);
756 extern	const char	*conv_dyn_flag1(Xword, Conv_fmt_flags_t,
757 			    Conv_dyn_flag1_buf_t *);
758 extern	const char	*conv_dyn_flag(Xword, Conv_fmt_flags_t,
759 			    Conv_dyn_flag_buf_t *);
760 extern	const char	*conv_dyn_posflag1(Xword, Conv_fmt_flags_t,
761 			    Conv_dyn_posflag1_buf_t *);
762 extern	const char	*conv_dyn_tag(Xword, Half, Conv_fmt_flags_t,
763 			    Conv_inv_buf_t *);
764 extern	const char	*conv_dyn_feature1(Xword, Conv_fmt_flags_t,
765 			    Conv_dyn_feature1_buf_t *);
766 extern	const char	*conv_ehdr_class(uchar_t, Conv_fmt_flags_t,
767 			    Conv_inv_buf_t *);
768 extern	const char	*conv_ehdr_data(uchar_t, Conv_fmt_flags_t,
769 			    Conv_inv_buf_t *);
770 extern	const char	*conv_ehdr_flags(Half, Word, Conv_fmt_flags_t,
771 			    Conv_ehdr_flags_buf_t *);
772 extern	const char	*conv_ehdr_mach(Half, Conv_fmt_flags_t,
773 			    Conv_inv_buf_t *);
774 extern	const char	*conv_ehdr_osabi(uchar_t, Conv_fmt_flags_t,
775 			    Conv_inv_buf_t *);
776 extern	const char	*conv_ehdr_type(Half, Conv_fmt_flags_t,
777 			    Conv_inv_buf_t *);
778 extern	const char	*conv_ehdr_vers(Word, Conv_fmt_flags_t,
779 			    Conv_inv_buf_t *);
780 extern	int		conv_expn_field(CONV_EXPN_FIELD_ARG *,
781 			    Conv_fmt_flags_t);
782 extern	const char	*conv_invalid_val(Conv_inv_buf_t *, Xword,
783 			    Conv_fmt_flags_t);
784 extern	const char	*conv_phdr_flags(Word, Conv_fmt_flags_t fmt_flags,
785 			    Conv_phdr_flags_buf_t *);
786 extern	const char	*conv_phdr_type(Half, Word, Conv_fmt_flags_t,
787 			    Conv_inv_buf_t *);
788 extern	const char	*conv_reject_desc(Rej_desc *, Conv_reject_desc_buf_t *);
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