xref: /titanic_52/usr/src/cmd/file/elf_read.h (revision 97cca09008b0f5f24287c17660e644b0294c9ba2)
1c2c65e21Sny155746 /*
2c2c65e21Sny155746  * CDDL HEADER START
3c2c65e21Sny155746  *
4c2c65e21Sny155746  * The contents of this file are subject to the terms of the
5c2c65e21Sny155746  * Common Development and Distribution License (the "License").
6c2c65e21Sny155746  * You may not use this file except in compliance with the License.
7c2c65e21Sny155746  *
8c2c65e21Sny155746  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9c2c65e21Sny155746  * or http://www.opensolaris.org/os/licensing.
10c2c65e21Sny155746  * See the License for the specific language governing permissions
11c2c65e21Sny155746  * and limitations under the License.
12c2c65e21Sny155746  *
13c2c65e21Sny155746  * When distributing Covered Code, include this CDDL HEADER in each
14c2c65e21Sny155746  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15c2c65e21Sny155746  * If applicable, add the following below this CDDL HEADER, with the
16c2c65e21Sny155746  * fields enclosed by brackets "[]" replaced with your own identifying
17c2c65e21Sny155746  * information: Portions Copyright [yyyy] [name of copyright owner]
18c2c65e21Sny155746  *
19c2c65e21Sny155746  * CDDL HEADER END
20c2c65e21Sny155746  */
21c2c65e21Sny155746 /*
22c2c65e21Sny155746  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23c2c65e21Sny155746  * Use is subject to license terms.
24c2c65e21Sny155746  */
25c2c65e21Sny155746 
26c2c65e21Sny155746 #ifndef _ELF_READ_H
27c2c65e21Sny155746 #define	_ELF_READ_H
28c2c65e21Sny155746 
29c2c65e21Sny155746 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30c2c65e21Sny155746 
31c2c65e21Sny155746 #define	BUFSZ 128
32c2c65e21Sny155746 typedef struct Elf_Info {
33c2c65e21Sny155746 	boolean_t	dynamic;	/* dymanically linked? */
34c2c65e21Sny155746 	unsigned	core_type;	/* core? what type of core? */
35c2c65e21Sny155746 	unsigned	stripped;	/* symtab, debug info */
36c2c65e21Sny155746 	unsigned	flags;		/* e_flags */
37c2c65e21Sny155746 	unsigned	machine;	/* e_machine */
38c2c65e21Sny155746 	unsigned	type;		/* e_type */
39c2c65e21Sny155746 	int		elffd;		/* fd of file being processed */
40c2c65e21Sny155746 	char		fname[PRFNSZ];	/* name of process that dumped core */
41c2c65e21Sny155746 	char		cap_str[BUFSZ];	/* hw/sw capabilities */
42c2c65e21Sny155746 	char		*file;		/* file being processed */
43c2c65e21Sny155746 } Elf_Info;
44c2c65e21Sny155746 
45c2c65e21Sny155746 /* values for Elf_Info.stripped */
46c2c65e21Sny155746 #define	E_DBGINF	0x01
47c2c65e21Sny155746 #define	E_SYMTAB	0x02
48c2c65e21Sny155746 #define	E_NOSTRIP	0x03
49c2c65e21Sny155746 
50c2c65e21Sny155746 /* values for Elf_Info.core_type; */
51c2c65e21Sny155746 #define	EC_NOTCORE	0x0
52c2c65e21Sny155746 #define	EC_OLDCORE	0x1
53c2c65e21Sny155746 #define	EC_NEWCORE	0x2
54c2c65e21Sny155746 
55c2c65e21Sny155746 /* elf file processing errors */
56c2c65e21Sny155746 #define	ELF_ERR_ELFCAP1	gettext("%s: %s zero size or zero entry ELF " \
57c2c65e21Sny155746 			    "section - ELF capabilities ignored\n")
58c2c65e21Sny155746 #define	ELF_ERR_ELFCAP2	gettext("%s: %s: can't read ELF capabilities " \
59c2c65e21Sny155746 			    "data - ELF capabilities ignored\n")
60c2c65e21Sny155746 
61c2c65e21Sny155746 extern int is_in_list(char *str);
62c2c65e21Sny155746 
63c2c65e21Sny155746 /* return status for elf_read and its helper functions */
64c2c65e21Sny155746 #define	ELF_READ_OKAY 1
65c2c65e21Sny155746 #define	ELF_READ_FAIL 0
66c2c65e21Sny155746 
67c2c65e21Sny155746 #if defined(_ELF64)
68c2c65e21Sny155746 
69c2c65e21Sny155746 #define	Elf_Ehdr	Elf64_Ehdr
70c2c65e21Sny155746 #define	Elf_Shdr	Elf64_Shdr
71c2c65e21Sny155746 #define	Elf_Phdr	Elf64_Phdr
72c2c65e21Sny155746 #define	Elf_Cap		Elf64_Cap
73c2c65e21Sny155746 #define	Elf_Nhdr	Elf64_Nhdr
74*97cca090Sab196087 #define	Elf_Word	Elf64_Word
75c2c65e21Sny155746 
76c2c65e21Sny155746 #define	elf_read	elf_read64
77c2c65e21Sny155746 #define	elf_xlatetom	elf64_xlatetom
78c2c65e21Sny155746 #define	elf_fsize	elf64_fsize
79c2c65e21Sny155746 #define	get_class	get_class64
80c2c65e21Sny155746 #define	get_version	get_version64
81c2c65e21Sny155746 #define	get_format	get_format64
82c2c65e21Sny155746 
83c2c65e21Sny155746 #else
84c2c65e21Sny155746 
85c2c65e21Sny155746 #define	Elf_Ehdr	Elf32_Ehdr
86c2c65e21Sny155746 #define	Elf_Shdr	Elf32_Shdr
87c2c65e21Sny155746 #define	Elf_Phdr	Elf32_Phdr
88c2c65e21Sny155746 #define	Elf_Cap		Elf32_Cap
89c2c65e21Sny155746 #define	Elf_Nhdr	Elf32_Nhdr
90*97cca090Sab196087 #define	Elf_Word	Elf32_Word
91c2c65e21Sny155746 
92c2c65e21Sny155746 #define	elf_read	elf_read32
93c2c65e21Sny155746 #define	elf_xlatetom	elf32_xlatetom
94c2c65e21Sny155746 #define	elf_fsize	elf32_fsize
95c2c65e21Sny155746 #define	get_class	get_class32
96c2c65e21Sny155746 #define	get_version	get_version32
97c2c65e21Sny155746 #define	get_format	get_format32
98c2c65e21Sny155746 
99c2c65e21Sny155746 #endif
100c2c65e21Sny155746 
101c2c65e21Sny155746 /* so lint can understand elf_read64 is defined */
102c2c65e21Sny155746 #ifdef lint
103c2c65e21Sny155746 #define	elf_read64	elf_read
104c2c65e21Sny155746 #endif /* lint */
105c2c65e21Sny155746 
106c2c65e21Sny155746 #endif /* _ELF_READ_H */
107