xref: /onnv-gate/usr/src/cmd/sgs/elfdump/common/_elfdump.h (revision 4665:7559cdd1a09e)
11618Srie /*
21618Srie  * CDDL HEADER START
31618Srie  *
41618Srie  * The contents of this file are subject to the terms of the
51618Srie  * Common Development and Distribution License (the "License").
61618Srie  * You may not use this file except in compliance with the License.
71618Srie  *
81618Srie  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
91618Srie  * or http://www.opensolaris.org/os/licensing.
101618Srie  * See the License for the specific language governing permissions
111618Srie  * and limitations under the License.
121618Srie  *
131618Srie  * When distributing Covered Code, include this CDDL HEADER in each
141618Srie  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
151618Srie  * If applicable, add the following below this CDDL HEADER, with the
161618Srie  * fields enclosed by brackets "[]" replaced with your own identifying
171618Srie  * information: Portions Copyright [yyyy] [name of copyright owner]
181618Srie  *
191618Srie  * CDDL HEADER END
201618Srie  */
211618Srie 
221618Srie /*
233492Sab196087  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
241618Srie  * Use is subject to license terms.
251618Srie  */
261618Srie 
271618Srie #ifndef	__ELFDUMP_H
281618Srie #define	__ELFDUMP_H
291618Srie 
301618Srie #pragma ident	"%Z%%M%	%I%	%E% SMI"
311618Srie 
321618Srie #include	<machelf.h>
331618Srie #include	<debug.h>
341618Srie 
351618Srie /*
361618Srie  * Local include file for elfdump.
371618Srie  */
381618Srie #ifdef	__cplusplus
391618Srie extern "C" {
401618Srie #endif
411618Srie 
421618Srie #define	FLG_DYNAMIC	0x00000001
431618Srie #define	FLG_EHDR	0x00000002
441618Srie #define	FLG_INTERP	0x00000004
451618Srie #define	FLG_SHDR	0x00000008
461618Srie #define	FLG_NOTE	0x00000010
471618Srie #define	FLG_PHDR	0x00000020
481618Srie #define	FLG_RELOC	0x00000040
491618Srie #define	FLG_SYMBOLS	0x00000080
501618Srie #define	FLG_VERSIONS	0x00000100
511618Srie #define	FLG_HASH	0x00000200
521618Srie #define	FLG_GOT		0x00000400
531618Srie #define	FLG_SYMINFO	0x00000800
541618Srie #define	FLG_MOVE	0x00001000
551618Srie #define	FLG_GROUP	0x00002000
561618Srie #define	FLG_CAP		0x00004000
571618Srie #define	FLG_UNWIND	0x00008000
583492Sab196087 #define	FLG_SORT	0x00010000
591618Srie #define	FLG_LONGNAME	0x00100000	/* not done by default */
601618Srie #define	FLG_CHECKSUM	0x00200000	/* not done by default */
611618Srie #define	FLG_DEMANGLE	0x00400000	/* not done by default */
62*4665Sab196087 #define	FLG_FAKESHDR	0x00800000	/* not done by default */
631618Srie #define	FLG_EVERYTHING	0x000fffff
641618Srie 
651618Srie #define	MAXNDXSIZE	10
661618Srie 
671618Srie typedef struct cache {
683862Srie 	Elf_Scn		*c_scn;
691618Srie 	Shdr		*c_shdr;
701618Srie 	Elf_Data	*c_data;
711618Srie 	char		*c_name;
724063Sab196087 	int		c_ndx;		/* Section index */
731618Srie } Cache;
741618Srie 
751618Srie typedef struct got_info {
761618Srie 	Word		g_reltype;	/* it will never happen, but */
771618Srie 					/* support mixed relocations */
781618Srie 	void		*g_rel;
791618Srie 	const char	*g_symname;
801618Srie } Got_info;
811618Srie 
821618Srie extern	const Cache	 cache_init;
831618Srie 
841618Srie extern	void		failure(const char *, const char *);
851618Srie extern	const char	*demangle(const char *, uint_t);
864168Sab196087 extern int		match(int, const char *, int);
871618Srie 
881618Srie /*
891618Srie  * Define various elfdump() functions into their 32-bit and 64-bit variants.
901618Srie  */
911618Srie #if	defined(_ELF64)
921618Srie #define	cap			cap64
931618Srie #define	checksum		checksum64
941618Srie #define	dynamic			dynamic64
95*4665Sab196087 #define	fake_shdr_cache		fake_shdr_cache64
96*4665Sab196087 #define	fake_shdr_cache_free	fake_shdr_cache_free64
971618Srie #define	got			got64
981618Srie #define	group			group64
991618Srie #define	hash			hash64
1001618Srie #define	interp			interp64
1011618Srie #define	move			move64
1021618Srie #define	note			note64
1031618Srie #define	note_entry		note_entry64
1041618Srie #define	regular			regular64
1051618Srie #define	reloc			reloc64
1061618Srie #define	sections		sections64
1071618Srie #define	string			string64
1081618Srie #define	symbols			symbols64
1091618Srie #define	syminfo			syminfo64
1101618Srie #define	symlookup		symlookup64
1111618Srie #define	unwind			unwind64
1121618Srie #define	versions		versions64
1131618Srie #define	version_def		version_def64
1141618Srie #define	version_need		version_need64
1151618Srie #else
1161618Srie #define	cap			cap32
1171618Srie #define	checksum		checksum32
1181618Srie #define	dynamic			dynamic32
119*4665Sab196087 #define	fake_shdr_cache		fake_shdr_cache32
120*4665Sab196087 #define	fake_shdr_cache_free	fake_shdr_cache_free32
1211618Srie #define	got			got32
1221618Srie #define	group			group32
1231618Srie #define	hash			hash32
1241618Srie #define	interp			interp32
1251618Srie #define	move			move32
1261618Srie #define	note			note32
1271618Srie #define	note_entry		note_entry32
1281618Srie #define	regular			regular32
1291618Srie #define	reloc			reloc32
1301618Srie #define	sections		sections32
1311618Srie #define	string			string32
1321618Srie #define	symbols			symbols32
1331618Srie #define	syminfo			syminfo32
1341618Srie #define	symlookup		symlookup32
1351618Srie #define	unwind			unwind32
1361618Srie #define	versions		versions32
1371618Srie #define	version_def		version_def32
1381618Srie #define	version_need		version_need32
1391618Srie #endif
1401618Srie 
141*4665Sab196087 extern	int	fake_shdr_cache32(const char *, int, Elf *, Elf32_Ehdr *,
142*4665Sab196087     Cache **, size_t *);
143*4665Sab196087 extern	int	fake_shdr_cache64(const char *, int, Elf *, Elf64_Ehdr *,
144*4665Sab196087     Cache **, size_t *);
145*4665Sab196087 
146*4665Sab196087 extern	void	fake_shdr_cache_free32(Cache *, size_t);
147*4665Sab196087 extern	void	fake_shdr_cache_free64(Cache *, size_t);
148*4665Sab196087 
149*4665Sab196087 extern	void	regular32(const char *, int, Elf *, uint_t, int);
150*4665Sab196087 extern	void	regular64(const char *, int, Elf *, uint_t, int);
1511618Srie 
1521618Srie #ifdef	__cplusplus
1531618Srie }
1541618Srie #endif
1551618Srie 
1561618Srie #endif	/* __ELFDUMP_H */
157