xref: /onnv-gate/usr/src/cmd/sgs/include/conv.h (revision 1618:8c9a4f31d225)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*1618Srie  * Common Development and Distribution License (the "License").
6*1618Srie  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
21*1618Srie 
220Sstevel@tonic-gate /*
230Sstevel@tonic-gate  *	Copyright (c) 1988 AT&T
240Sstevel@tonic-gate  *	  All Rights Reserved
250Sstevel@tonic-gate  *
26*1618Srie  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27*1618Srie  * Use is subject to license terms.
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #ifndef	_CONV_H
310Sstevel@tonic-gate #define	_CONV_H
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
340Sstevel@tonic-gate 
350Sstevel@tonic-gate /*
360Sstevel@tonic-gate  * Global include file for conversion library.
370Sstevel@tonic-gate  */
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #include <stdlib.h>
400Sstevel@tonic-gate #include <libelf.h>
410Sstevel@tonic-gate #include <dlfcn.h>
420Sstevel@tonic-gate #include <libld.h>
430Sstevel@tonic-gate #include <sgs.h>
440Sstevel@tonic-gate #include <machdep.h>
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #ifdef	__cplusplus
470Sstevel@tonic-gate extern "C" {
480Sstevel@tonic-gate #endif
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
510Sstevel@tonic-gate  * Configuration features available - maintained here (instead of debug.h)
520Sstevel@tonic-gate  * to save libconv from having to include debug.h which results in numerous
530Sstevel@tonic-gate  * "declared but not used or defined" lint errors.
540Sstevel@tonic-gate  */
550Sstevel@tonic-gate #define	CONF_EDLIBPATH	0x000100	/* ELF default library path */
560Sstevel@tonic-gate #define	CONF_ESLIBPATH	0x000200	/* ELF secure library path */
570Sstevel@tonic-gate #define	CONF_ADLIBPATH	0x000400	/* AOUT default library path */
580Sstevel@tonic-gate #define	CONF_ASLIBPATH	0x000800	/* AOUT secure library path */
590Sstevel@tonic-gate #define	CONF_DIRCFG	0x001000	/* directory configuration available */
600Sstevel@tonic-gate #define	CONF_OBJALT	0x002000	/* object alternatives available */
610Sstevel@tonic-gate #define	CONF_MEMRESV	0x004000	/* memory reservation required */
620Sstevel@tonic-gate #define	CONF_ENVS	0x008000	/* environment variables available */
630Sstevel@tonic-gate #define	CONF_FLTR	0x010000	/* filter information available */
640Sstevel@tonic-gate #define	CONF_FEATMSK	0xffff00
650Sstevel@tonic-gate 
660Sstevel@tonic-gate /*
67*1618Srie  * Various values that can't be matched to a symbolic definition are converted
68*1618Srie  * to a numeric string.  Each function that may require this fallback maintains
69*1618Srie  * its own static string buffer, as many conversion routines may be called for
70*1618Srie  * one final diagnostic.  See conv_invalid_val().
71*1618Srie  *
72*1618Srie  * The string size reflects the largest possible decimal number plus a trailing
73*1618Srie  * null.  Typically however, values are hex with a leading "0x".
74*1618Srie  */
75*1618Srie #if	defined(_ELF64)
76*1618Srie #define	CONV_INV_STRSIZE	22
77*1618Srie #else
78*1618Srie #define	CONV_INV_STRSIZE	12
79*1618Srie #endif
80*1618Srie 
81*1618Srie /*
82*1618Srie  * Flags for conv_invalid_val().
83*1618Srie  */
84*1618Srie #define	CONV_INV_DECIMAL	0x1	/* print as decimal (default is hex) */
85*1618Srie #define	CONV_INV_SPACE		0x2	/* append a space */
86*1618Srie 
87*1618Srie /*
88*1618Srie  * The expansion of bit-field data items is driven from a value descriptor and
89*1618Srie  * the conv_expn_field() routine.
90*1618Srie  */
91*1618Srie typedef struct {
92*1618Srie 	Xword		v_val;		/* expansion value */
93*1618Srie 	const char	*v_msg;		/* associated message string */
94*1618Srie } Val_desc;
95*1618Srie 
96*1618Srie /*
97*1618Srie  * Define all generic interfaces.
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate extern	void		conv_check_native(char **, char **);
100*1618Srie extern	const char	*conv_config_feat(int);
1010Sstevel@tonic-gate extern	const char	*conv_config_obj(ushort_t);
102*1618Srie extern	const char	*conv_config_upm(const char *, const char *,
103*1618Srie 			    const char *, size_t);
104*1618Srie extern	const char	*conv_def_tag(Symref);
105*1618Srie extern	const char	*conv_demangle_name(const char *);
106*1618Srie extern	const char	*conv_dl_flag(int, int);
107*1618Srie extern	const char	*conv_dl_mode(int, int);
108*1618Srie extern	const char	*conv_dwarf_ehe(uint_t);
109*1618Srie extern	const char	*conv_elfdata_type(Elf_Type);
110*1618Srie extern	const char	*conv_grphdl_flags(uint_t);
1110Sstevel@tonic-gate extern	Isa_desc	*conv_isalist(void);
1120Sstevel@tonic-gate extern	const char	*conv_lddstub(int);
113*1618Srie extern	const char	*conv_seg_flags(Half);
1140Sstevel@tonic-gate extern	int		conv_sys_eclass();
1150Sstevel@tonic-gate extern	Uts_desc	*conv_uts(void);
116*1618Srie extern	const char	*conv_ver_flags(Half);
117*1618Srie 
118*1618Srie /*
119*1618Srie  * Define all class specific routines.
120*1618Srie  */
121*1618Srie #if	defined(_ELF64)
122*1618Srie #define	conv_bnd_obj		conv64_bnd_obj
123*1618Srie #define	conv_bnd_type		conv64_bnd_type
124*1618Srie #define	conv_cap_tag		conv64_cap_tag
125*1618Srie #define	conv_cap_val		conv64_cap_val
126*1618Srie #define	conv_cap_val_hw1	conv64_cap_val_hw1
127*1618Srie #define	conv_cap_val_sf1	conv64_cap_val_sf1
128*1618Srie #define	conv_dyn_feature1	conv64_dyn_feature1
129*1618Srie #define	conv_dyn_flag1		conv64_dyn_flag1
130*1618Srie #define	conv_dyn_flag		conv64_dyn_flag
131*1618Srie #define	conv_dyn_posflag1	conv64_dyn_posflag1
132*1618Srie #define	conv_dyn_tag		conv64_dyn_tag
133*1618Srie #define	conv_ehdr_class		conv64_ehdr_class
134*1618Srie #define	conv_ehdr_data		conv64_ehdr_data
135*1618Srie #define	conv_ehdr_flags		conv64_ehdr_flags
136*1618Srie #define	conv_ehdr_mach		conv64_ehdr_mach
137*1618Srie #define	conv_ehdr_type		conv64_ehdr_type
138*1618Srie #define	conv_ehdr_vers		conv64_ehdr_vers
139*1618Srie #define	conv_expn_field		conv64_expn_field
140*1618Srie #define	conv_invalid_val	conv64_invalid_val
141*1618Srie #define	conv_phdr_flags		conv64_phdr_flags
142*1618Srie #define	conv_phdr_type		conv64_phdr_type
143*1618Srie #define	conv_reject_desc	conv64_reject_desc
144*1618Srie #define	conv_reloc_type		conv64_reloc_type
145*1618Srie #define	conv_reloc_386_type	conv64_reloc_386_type
146*1618Srie #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
147*1618Srie #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
148*1618Srie #define	conv_sec_flags		conv64_sec_flags
149*1618Srie #define	conv_sec_info		conv64_sec_info
150*1618Srie #define	conv_sec_type		conv64_sec_type
151*1618Srie #define	conv_sym_info_bind	conv64_sym_info_bind
152*1618Srie #define	conv_sym_info_type	conv64_sym_info_type
153*1618Srie #define	conv_sym_shndx		conv64_sym_shndx
154*1618Srie #define	conv_sym_other		conv64_sym_other
155*1618Srie #define	conv_sym_value		conv64_sym_value
156*1618Srie #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
157*1618Srie #else
158*1618Srie #define	conv_bnd_obj		conv32_bnd_obj
159*1618Srie #define	conv_bnd_type		conv32_bnd_type
160*1618Srie #define	conv_cap_tag		conv32_cap_tag
161*1618Srie #define	conv_cap_val		conv32_cap_val
162*1618Srie #define	conv_cap_val_hw1	conv32_cap_val_hw1
163*1618Srie #define	conv_cap_val_sf1	conv32_cap_val_sf1
164*1618Srie #define	conv_dyn_feature1	conv32_dyn_feature1
165*1618Srie #define	conv_dyn_flag1		conv32_dyn_flag1
166*1618Srie #define	conv_dyn_flag		conv32_dyn_flag
167*1618Srie #define	conv_dyn_posflag1	conv32_dyn_posflag1
168*1618Srie #define	conv_dyn_tag		conv32_dyn_tag
169*1618Srie #define	conv_ehdr_class		conv32_ehdr_class
170*1618Srie #define	conv_ehdr_data		conv32_ehdr_data
171*1618Srie #define	conv_ehdr_flags		conv32_ehdr_flags
172*1618Srie #define	conv_ehdr_mach		conv32_ehdr_mach
173*1618Srie #define	conv_ehdr_type		conv32_ehdr_type
174*1618Srie #define	conv_ehdr_vers		conv32_ehdr_vers
175*1618Srie #define	conv_expn_field		conv32_expn_field
176*1618Srie #define	conv_invalid_val	conv32_invalid_val
177*1618Srie #define	conv_phdr_flags		conv32_phdr_flags
178*1618Srie #define	conv_phdr_type		conv32_phdr_type
179*1618Srie #define	conv_reject_desc	conv32_reject_desc
180*1618Srie #define	conv_reloc_type		conv32_reloc_type
181*1618Srie #define	conv_reloc_386_type	conv32_reloc_386_type
182*1618Srie #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
183*1618Srie #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
184*1618Srie #define	conv_sec_flags		conv32_sec_flags
185*1618Srie #define	conv_sec_info		conv32_sec_info
186*1618Srie #define	conv_sec_type		conv32_sec_type
187*1618Srie #define	conv_sym_info_bind	conv32_sym_info_bind
188*1618Srie #define	conv_sym_info_type	conv32_sym_info_type
189*1618Srie #define	conv_sym_shndx		conv32_sym_shndx
190*1618Srie #define	conv_sym_other		conv32_sym_other
191*1618Srie #define	conv_sym_value		conv32_sym_value
192*1618Srie #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
193*1618Srie #endif
194*1618Srie 
195*1618Srie extern	const char	*conv_bnd_obj(uint_t);
196*1618Srie extern	const char	*conv_bnd_type(uint_t);
197*1618Srie extern	const char	*conv_cap_tag(Xword);
198*1618Srie extern	const char	*conv_cap_val(Xword, Xword, Half);
199*1618Srie extern	const char	*conv_cap_val_hw1(Xword, Half);
200*1618Srie extern	const char	*conv_cap_val_sf1(Xword, Half);
201*1618Srie extern	const char	*conv_dyn_flag1(Xword);
202*1618Srie extern	const char	*conv_dyn_flag(Xword);
203*1618Srie extern	const char	*conv_dyn_posflag1(Xword);
204*1618Srie extern	const char	*conv_dyn_tag(Xword, Half);
205*1618Srie extern	const char	*conv_dyn_feature1(Xword);
206*1618Srie extern	const char	*conv_ehdr_class(uchar_t);
207*1618Srie extern	const char	*conv_ehdr_data(uchar_t);
208*1618Srie extern	const char	*conv_ehdr_flags(Half, Word);
209*1618Srie extern	const char	*conv_ehdr_mach(Half);
210*1618Srie extern	const char	*conv_ehdr_type(Half);
211*1618Srie extern	const char	*conv_ehdr_vers(Word);
212*1618Srie extern	int		conv_expn_field(char *, size_t, const Val_desc *,
213*1618Srie 			    Xword, Xword, const char *, int);
214*1618Srie extern	const char	*conv_invalid_val(char *, size_t, Xword, int);
215*1618Srie extern	const char	*conv_phdr_flags(Word);
216*1618Srie extern	const char	*conv_phdr_type(Half, Word);
217*1618Srie extern	const char	*conv_reject_desc(Rej_desc *);
218*1618Srie extern	const char	*conv_reloc_type(Half, Word);
219*1618Srie extern	const char	*conv_reloc_386_type(Word);
220*1618Srie extern	const char	*conv_reloc_amd64_type(Word);
221*1618Srie extern	const char	*conv_reloc_SPARC_type(Word);
222*1618Srie extern	const char	*conv_sec_flags(Xword);
223*1618Srie extern	const char	*conv_sec_info(Word, Xword);
224*1618Srie extern	const char	*conv_sec_type(Half, Word);
225*1618Srie extern	const char	*conv_sym_info_bind(uchar_t);
226*1618Srie extern	const char	*conv_sym_info_type(Half, uchar_t);
227*1618Srie extern	const char	*conv_sym_shndx(Half);
228*1618Srie extern	const char	*conv_sym_other(uchar_t);
229*1618Srie extern	const char	*conv_sym_value(Half, uchar_t, Addr);
230*1618Srie extern	const char	*conv_sym_SPARC_value(Addr);
2310Sstevel@tonic-gate 
2320Sstevel@tonic-gate #ifdef	__cplusplus
2330Sstevel@tonic-gate }
2340Sstevel@tonic-gate #endif
2350Sstevel@tonic-gate 
2360Sstevel@tonic-gate #endif /* _CONV_H */
237