xref: /titanic_52/usr/src/cmd/file/elf_read.h (revision a49a392f179e40c74ea8903bf2793b2aa49efdf1)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _ELF_READ_H
27 #define	_ELF_READ_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #define	BUFSZ 128
32 typedef struct Elf_Info {
33 	boolean_t	dynamic;	/* dymanically linked? */
34 	unsigned	core_type;	/* core? what type of core? */
35 	unsigned	stripped;	/* symtab, debug info */
36 	unsigned	flags;		/* e_flags */
37 	unsigned	machine;	/* e_machine */
38 	unsigned	type;		/* e_type */
39 	int		elffd;		/* fd of file being processed */
40 	char		fname[PRFNSZ];	/* name of process that dumped core */
41 	char		cap_str[BUFSZ];	/* hw/sw capabilities */
42 	char		*file;		/* file being processed */
43 } Elf_Info;
44 
45 /* values for Elf_Info.stripped */
46 #define	E_DBGINF	0x01
47 #define	E_SYMTAB	0x02
48 #define	E_NOSTRIP	0x03
49 
50 /* values for Elf_Info.core_type; */
51 #define	EC_NOTCORE	0x0
52 #define	EC_OLDCORE	0x1
53 #define	EC_NEWCORE	0x2
54 
55 /* elf file processing errors */
56 #define	ELF_ERR_ELFCAP1	gettext("%s: %s zero size or zero entry ELF " \
57 			    "section - ELF capabilities ignored\n")
58 #define	ELF_ERR_ELFCAP2	gettext("%s: %s: can't read ELF capabilities " \
59 			    "data - ELF capabilities ignored\n")
60 
61 extern int is_in_list(char *str);
62 
63 /* return status for elf_read and its helper functions */
64 #define	ELF_READ_OKAY 1
65 #define	ELF_READ_FAIL 0
66 
67 #if defined(_ELF64)
68 
69 #define	Elf_Ehdr	Elf64_Ehdr
70 #define	Elf_Shdr	Elf64_Shdr
71 #define	Elf_Phdr	Elf64_Phdr
72 #define	Elf_Cap		Elf64_Cap
73 #define	Elf_Nhdr	Elf64_Nhdr
74 
75 #define	elf_read	elf_read64
76 #define	elf_xlatetom	elf64_xlatetom
77 #define	elf_fsize	elf64_fsize
78 #define	get_class	get_class64
79 #define	get_version	get_version64
80 #define	get_format	get_format64
81 
82 #else
83 
84 #define	Elf_Ehdr	Elf32_Ehdr
85 #define	Elf_Shdr	Elf32_Shdr
86 #define	Elf_Phdr	Elf32_Phdr
87 #define	Elf_Cap		Elf32_Cap
88 #define	Elf_Nhdr	Elf32_Nhdr
89 
90 #define	elf_read	elf_read32
91 #define	elf_xlatetom	elf32_xlatetom
92 #define	elf_fsize	elf32_fsize
93 #define	get_class	get_class32
94 #define	get_version	get_version32
95 #define	get_format	get_format32
96 
97 #endif
98 
99 /* so lint can understand elf_read64 is defined */
100 #ifdef lint
101 #define	elf_read64	elf_read
102 #endif /* lint */
103 
104 #endif /* _ELF_READ_H */
105