xref: /titanic_44/usr/src/cmd/sgs/include/conv.h (revision 3db86aab554edbb4244c8d1a1c90f152eee768af)
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 2006 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  * Various values that can't be matched to a symbolic definition are converted
68  * to a numeric string.  Each function that may require this fallback maintains
69  * its own static string buffer, as many conversion routines may be called for
70  * one final diagnostic.  See conv_invalid_val().
71  *
72  * The string size reflects the largest possible decimal number plus a trailing
73  * null.  Typically however, values are hex with a leading "0x".
74  */
75 #if	defined(_ELF64)
76 #define	CONV_INV_STRSIZE	22
77 #else
78 #define	CONV_INV_STRSIZE	12
79 #endif
80 
81 /*
82  * Flags that alter standard formatting for conversion routines.
83  */
84 #define	CONV_FMT_DECIMAL	0x1	/* conv_invalid_val() should print */
85 					/*    integer print as decimal */
86 					/*    (default is hex) */
87 #define	CONV_FMT_SPACE		0x2	/* conv_invalid_val() should append */
88 					/*    a space after the number.  */
89 #define	CONV_FMT_ALTDUMP	0x4	/* Output strings using the versions */
90 					/*    used by the dump program. */
91 #define	CONV_FMT_ALTFILE	0x8	/* Output strings in the form used */
92 					/*    by the file(1) command */
93 
94 /*
95  * Mask of CONV_FMT bits that reflect a desire to use alternate strings.
96  */
97 #define	CONV_FMTALTMASK (CONV_FMT_ALTDUMP|CONV_FMT_ALTFILE)
98 
99 /*
100  * The expansion of bit-field data items is driven from a value descriptor and
101  * the conv_expn_field() routine.
102  */
103 typedef struct {
104 	Xword		v_val;		/* expansion value */
105 	const char	*v_msg;		/* associated message string */
106 } Val_desc;
107 
108 /*
109  * Define all generic interfaces.
110  */
111 extern	void		conv_check_native(char **, char **);
112 extern	const char	*conv_config_feat(int);
113 extern	const char	*conv_config_obj(ushort_t);
114 extern	const char	*conv_config_upm(const char *, const char *,
115 			    const char *, size_t);
116 extern	const char	*conv_def_tag(Symref);
117 extern	const char	*conv_demangle_name(const char *);
118 extern	const char	*conv_dl_flag(int, int);
119 extern	const char	*conv_dl_mode(int, int);
120 extern	const char	*conv_dwarf_ehe(uint_t);
121 extern	const char	*conv_elfdata_type(Elf_Type);
122 extern	const char	*conv_grphdl_flags(uint_t);
123 extern	Isa_desc	*conv_isalist(void);
124 extern	const char	*conv_lddstub(int);
125 extern	const char	*conv_seg_flags(Half);
126 extern	int		conv_sys_eclass();
127 extern	Uts_desc	*conv_uts(void);
128 extern	const char	*conv_ver_flags(Half);
129 
130 /*
131  * Define all class specific routines.
132  */
133 #if	defined(_ELF64)
134 #define	conv_bnd_obj		conv64_bnd_obj
135 #define	conv_bnd_type		conv64_bnd_type
136 #define	conv_cap_tag		conv64_cap_tag
137 #define	conv_cap_val		conv64_cap_val
138 #define	conv_cap_val_hw1	conv64_cap_val_hw1
139 #define	conv_cap_val_sf1	conv64_cap_val_sf1
140 #define	conv_dyn_feature1	conv64_dyn_feature1
141 #define	conv_dyn_flag1		conv64_dyn_flag1
142 #define	conv_dyn_flag		conv64_dyn_flag
143 #define	conv_dyn_posflag1	conv64_dyn_posflag1
144 #define	conv_dyn_tag		conv64_dyn_tag
145 #define	conv_ehdr_class		conv64_ehdr_class
146 #define	conv_ehdr_data		conv64_ehdr_data
147 #define	conv_ehdr_flags		conv64_ehdr_flags
148 #define	conv_ehdr_mach		conv64_ehdr_mach
149 #define	conv_ehdr_type		conv64_ehdr_type
150 #define	conv_ehdr_vers		conv64_ehdr_vers
151 #define	conv_expn_field		conv64_expn_field
152 #define	conv_invalid_val	conv64_invalid_val
153 #define	conv_phdr_flags		conv64_phdr_flags
154 #define	conv_phdr_type		conv64_phdr_type
155 #define	conv_reject_desc	conv64_reject_desc
156 #define	conv_reloc_type		conv64_reloc_type
157 #define	conv_reloc_386_type	conv64_reloc_386_type
158 #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
159 #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
160 #define	conv_sec_flags		conv64_sec_flags
161 #define	conv_sec_info		conv64_sec_info
162 #define	conv_sec_type		conv64_sec_type
163 #define	conv_sym_info_bind	conv64_sym_info_bind
164 #define	conv_sym_info_type	conv64_sym_info_type
165 #define	conv_sym_shndx		conv64_sym_shndx
166 #define	conv_sym_other		conv64_sym_other
167 #define	conv_sym_value		conv64_sym_value
168 #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
169 #else
170 #define	conv_bnd_obj		conv32_bnd_obj
171 #define	conv_bnd_type		conv32_bnd_type
172 #define	conv_cap_tag		conv32_cap_tag
173 #define	conv_cap_val		conv32_cap_val
174 #define	conv_cap_val_hw1	conv32_cap_val_hw1
175 #define	conv_cap_val_sf1	conv32_cap_val_sf1
176 #define	conv_dyn_feature1	conv32_dyn_feature1
177 #define	conv_dyn_flag1		conv32_dyn_flag1
178 #define	conv_dyn_flag		conv32_dyn_flag
179 #define	conv_dyn_posflag1	conv32_dyn_posflag1
180 #define	conv_dyn_tag		conv32_dyn_tag
181 #define	conv_ehdr_class		conv32_ehdr_class
182 #define	conv_ehdr_data		conv32_ehdr_data
183 #define	conv_ehdr_flags		conv32_ehdr_flags
184 #define	conv_ehdr_mach		conv32_ehdr_mach
185 #define	conv_ehdr_type		conv32_ehdr_type
186 #define	conv_ehdr_vers		conv32_ehdr_vers
187 #define	conv_expn_field		conv32_expn_field
188 #define	conv_invalid_val	conv32_invalid_val
189 #define	conv_phdr_flags		conv32_phdr_flags
190 #define	conv_phdr_type		conv32_phdr_type
191 #define	conv_reject_desc	conv32_reject_desc
192 #define	conv_reloc_type		conv32_reloc_type
193 #define	conv_reloc_386_type	conv32_reloc_386_type
194 #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
195 #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
196 #define	conv_sec_flags		conv32_sec_flags
197 #define	conv_sec_info		conv32_sec_info
198 #define	conv_sec_type		conv32_sec_type
199 #define	conv_sym_info_bind	conv32_sym_info_bind
200 #define	conv_sym_info_type	conv32_sym_info_type
201 #define	conv_sym_shndx		conv32_sym_shndx
202 #define	conv_sym_other		conv32_sym_other
203 #define	conv_sym_value		conv32_sym_value
204 #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
205 #endif
206 
207 extern	const char	*conv_bnd_obj(uint_t);
208 extern	const char	*conv_bnd_type(uint_t);
209 extern	const char	*conv_cap_tag(Xword);
210 extern	const char	*conv_cap_val(Xword, Xword, Half);
211 extern	const char	*conv_cap_val_hw1(Xword, Half);
212 extern	const char	*conv_cap_val_sf1(Xword, Half);
213 extern	const char	*conv_dyn_flag1(Xword);
214 extern	const char	*conv_dyn_flag(Xword);
215 extern	const char	*conv_dyn_posflag1(Xword);
216 extern	const char	*conv_dyn_tag(Xword, Half, int);
217 extern	const char	*conv_dyn_feature1(Xword);
218 extern	const char	*conv_ehdr_class(uchar_t, int);
219 extern	const char	*conv_ehdr_data(uchar_t, int);
220 extern	const char	*conv_ehdr_flags(Half, Word);
221 extern	const char	*conv_ehdr_mach(Half, int);
222 extern	const char	*conv_ehdr_type(Half, int);
223 extern	const char	*conv_ehdr_vers(Word, int);
224 extern	int		conv_expn_field(char *, size_t, const Val_desc *,
225 			    Xword, Xword, const char *, int);
226 extern	const char	*conv_invalid_val(char *, size_t, Xword, int);
227 extern	const char	*conv_phdr_flags(Word);
228 extern	const char	*conv_phdr_type(Half, Word);
229 extern	const char	*conv_reject_desc(Rej_desc *);
230 extern	const char	*conv_reloc_type(Half, Word, int);
231 extern	const char	*conv_reloc_386_type(Word, int);
232 extern	const char	*conv_reloc_amd64_type(Word, int);
233 extern	const char	*conv_reloc_SPARC_type(Word, int);
234 extern	const char	*conv_sec_flags(Xword);
235 extern	const char	*conv_sec_info(Word, Xword);
236 extern	const char	*conv_sec_type(Half, Word, int);
237 extern	const char	*conv_sym_info_bind(uchar_t, int);
238 extern	const char	*conv_sym_info_type(Half, uchar_t, int);
239 extern	const char	*conv_sym_shndx(Half);
240 extern	const char	*conv_sym_other(uchar_t);
241 extern	const char	*conv_sym_value(Half, uchar_t, Addr);
242 extern	const char	*conv_sym_SPARC_value(Addr, int);
243 
244 #ifdef	__cplusplus
245 }
246 #endif
247 
248 #endif /* _CONV_H */
249