xref: /titanic_44/usr/src/cmd/sgs/include/conv.h (revision 9df12a23948bd40cbe37ce88d84e272c3894e675)
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 for conv_invalid_val().
83  */
84 #define	CONV_INV_DECIMAL	0x1	/* print as decimal (default is hex) */
85 #define	CONV_INV_SPACE		0x2	/* append a space */
86 
87 /*
88  * The expansion of bit-field data items is driven from a value descriptor and
89  * the conv_expn_field() routine.
90  */
91 typedef struct {
92 	Xword		v_val;		/* expansion value */
93 	const char	*v_msg;		/* associated message string */
94 } Val_desc;
95 
96 /*
97  * Define all generic interfaces.
98  */
99 extern	void		conv_check_native(char **, char **);
100 extern	const char	*conv_config_feat(int);
101 extern	const char	*conv_config_obj(ushort_t);
102 extern	const char	*conv_config_upm(const char *, const char *,
103 			    const char *, size_t);
104 extern	const char	*conv_def_tag(Symref);
105 extern	const char	*conv_demangle_name(const char *);
106 extern	const char	*conv_dl_flag(int, int);
107 extern	const char	*conv_dl_mode(int, int);
108 extern	const char	*conv_dwarf_ehe(uint_t);
109 extern	const char	*conv_elfdata_type(Elf_Type);
110 extern	const char	*conv_grphdl_flags(uint_t);
111 extern	Isa_desc	*conv_isalist(void);
112 extern	const char	*conv_lddstub(int);
113 extern	const char	*conv_seg_flags(Half);
114 extern	int		conv_sys_eclass();
115 extern	Uts_desc	*conv_uts(void);
116 extern	const char	*conv_ver_flags(Half);
117 
118 /*
119  * Define all class specific routines.
120  */
121 #if	defined(_ELF64)
122 #define	conv_bnd_obj		conv64_bnd_obj
123 #define	conv_bnd_type		conv64_bnd_type
124 #define	conv_cap_tag		conv64_cap_tag
125 #define	conv_cap_val		conv64_cap_val
126 #define	conv_cap_val_hw1	conv64_cap_val_hw1
127 #define	conv_cap_val_sf1	conv64_cap_val_sf1
128 #define	conv_dyn_feature1	conv64_dyn_feature1
129 #define	conv_dyn_flag1		conv64_dyn_flag1
130 #define	conv_dyn_flag		conv64_dyn_flag
131 #define	conv_dyn_posflag1	conv64_dyn_posflag1
132 #define	conv_dyn_tag		conv64_dyn_tag
133 #define	conv_ehdr_class		conv64_ehdr_class
134 #define	conv_ehdr_data		conv64_ehdr_data
135 #define	conv_ehdr_flags		conv64_ehdr_flags
136 #define	conv_ehdr_mach		conv64_ehdr_mach
137 #define	conv_ehdr_type		conv64_ehdr_type
138 #define	conv_ehdr_vers		conv64_ehdr_vers
139 #define	conv_expn_field		conv64_expn_field
140 #define	conv_invalid_val	conv64_invalid_val
141 #define	conv_phdr_flags		conv64_phdr_flags
142 #define	conv_phdr_type		conv64_phdr_type
143 #define	conv_reject_desc	conv64_reject_desc
144 #define	conv_reloc_type		conv64_reloc_type
145 #define	conv_reloc_386_type	conv64_reloc_386_type
146 #define	conv_reloc_amd64_type	conv64_reloc_amd64_type
147 #define	conv_reloc_SPARC_type	conv64_reloc_SPARC_type
148 #define	conv_sec_flags		conv64_sec_flags
149 #define	conv_sec_info		conv64_sec_info
150 #define	conv_sec_type		conv64_sec_type
151 #define	conv_sym_info_bind	conv64_sym_info_bind
152 #define	conv_sym_info_type	conv64_sym_info_type
153 #define	conv_sym_shndx		conv64_sym_shndx
154 #define	conv_sym_other		conv64_sym_other
155 #define	conv_sym_value		conv64_sym_value
156 #define	conv_sym_SPARC_value	conv64_sym_SPARC_value
157 #else
158 #define	conv_bnd_obj		conv32_bnd_obj
159 #define	conv_bnd_type		conv32_bnd_type
160 #define	conv_cap_tag		conv32_cap_tag
161 #define	conv_cap_val		conv32_cap_val
162 #define	conv_cap_val_hw1	conv32_cap_val_hw1
163 #define	conv_cap_val_sf1	conv32_cap_val_sf1
164 #define	conv_dyn_feature1	conv32_dyn_feature1
165 #define	conv_dyn_flag1		conv32_dyn_flag1
166 #define	conv_dyn_flag		conv32_dyn_flag
167 #define	conv_dyn_posflag1	conv32_dyn_posflag1
168 #define	conv_dyn_tag		conv32_dyn_tag
169 #define	conv_ehdr_class		conv32_ehdr_class
170 #define	conv_ehdr_data		conv32_ehdr_data
171 #define	conv_ehdr_flags		conv32_ehdr_flags
172 #define	conv_ehdr_mach		conv32_ehdr_mach
173 #define	conv_ehdr_type		conv32_ehdr_type
174 #define	conv_ehdr_vers		conv32_ehdr_vers
175 #define	conv_expn_field		conv32_expn_field
176 #define	conv_invalid_val	conv32_invalid_val
177 #define	conv_phdr_flags		conv32_phdr_flags
178 #define	conv_phdr_type		conv32_phdr_type
179 #define	conv_reject_desc	conv32_reject_desc
180 #define	conv_reloc_type		conv32_reloc_type
181 #define	conv_reloc_386_type	conv32_reloc_386_type
182 #define	conv_reloc_amd64_type	conv32_reloc_amd64_type
183 #define	conv_reloc_SPARC_type	conv32_reloc_SPARC_type
184 #define	conv_sec_flags		conv32_sec_flags
185 #define	conv_sec_info		conv32_sec_info
186 #define	conv_sec_type		conv32_sec_type
187 #define	conv_sym_info_bind	conv32_sym_info_bind
188 #define	conv_sym_info_type	conv32_sym_info_type
189 #define	conv_sym_shndx		conv32_sym_shndx
190 #define	conv_sym_other		conv32_sym_other
191 #define	conv_sym_value		conv32_sym_value
192 #define	conv_sym_SPARC_value	conv32_sym_SPARC_value
193 #endif
194 
195 extern	const char	*conv_bnd_obj(uint_t);
196 extern	const char	*conv_bnd_type(uint_t);
197 extern	const char	*conv_cap_tag(Xword);
198 extern	const char	*conv_cap_val(Xword, Xword, Half);
199 extern	const char	*conv_cap_val_hw1(Xword, Half);
200 extern	const char	*conv_cap_val_sf1(Xword, Half);
201 extern	const char	*conv_dyn_flag1(Xword);
202 extern	const char	*conv_dyn_flag(Xword);
203 extern	const char	*conv_dyn_posflag1(Xword);
204 extern	const char	*conv_dyn_tag(Xword, Half);
205 extern	const char	*conv_dyn_feature1(Xword);
206 extern	const char	*conv_ehdr_class(uchar_t);
207 extern	const char	*conv_ehdr_data(uchar_t);
208 extern	const char	*conv_ehdr_flags(Half, Word);
209 extern	const char	*conv_ehdr_mach(Half);
210 extern	const char	*conv_ehdr_type(Half);
211 extern	const char	*conv_ehdr_vers(Word);
212 extern	int		conv_expn_field(char *, size_t, const Val_desc *,
213 			    Xword, Xword, const char *, int);
214 extern	const char	*conv_invalid_val(char *, size_t, Xword, int);
215 extern	const char	*conv_phdr_flags(Word);
216 extern	const char	*conv_phdr_type(Half, Word);
217 extern	const char	*conv_reject_desc(Rej_desc *);
218 extern	const char	*conv_reloc_type(Half, Word);
219 extern	const char	*conv_reloc_386_type(Word);
220 extern	const char	*conv_reloc_amd64_type(Word);
221 extern	const char	*conv_reloc_SPARC_type(Word);
222 extern	const char	*conv_sec_flags(Xword);
223 extern	const char	*conv_sec_info(Word, Xword);
224 extern	const char	*conv_sec_type(Half, Word);
225 extern	const char	*conv_sym_info_bind(uchar_t);
226 extern	const char	*conv_sym_info_type(Half, uchar_t);
227 extern	const char	*conv_sym_shndx(Half);
228 extern	const char	*conv_sym_other(uchar_t);
229 extern	const char	*conv_sym_value(Half, uchar_t, Addr);
230 extern	const char	*conv_sym_SPARC_value(Addr);
231 
232 #ifdef	__cplusplus
233 }
234 #endif
235 
236 #endif /* _CONV_H */
237