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