Print this page
5688 ELF tools need to be more careful with dwarf data
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/elfdump/common/_elfdump.h
+++ new/usr/src/cmd/sgs/elfdump/common/_elfdump.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #ifndef __ELFDUMP_H
28 28 #define __ELFDUMP_H
29 29
30 30 #include <_machelf.h>
31 31 #include <debug.h>
32 32
33 33 /*
34 34 * Local include file for elfdump.
35 35 */
36 36 #ifdef __cplusplus
37 37 extern "C" {
38 38 #endif
39 39
40 40 /*
41 41 * flags: This is a bitmask that controls elfdump's operations. There
42 42 * are three categories of flag:
43 43 *
44 44 * SHOW - Specify categories of things in the ELF object to display.
45 45 * CALC - Compute something based on the contents of the ELF object.
46 46 * CTL - Control options specify general options that are not
47 47 * specific to any specific part of the ELF object, but
48 48 * which apply at a higher level.
49 49 *
50 50 * To simplify masking these categories, they are assigned bit ranges
51 51 * as follows:
52 52 * SHOW: Bottom 24-bits
53 53 * CALC: Upper 2 bits of most significant byte
54 54 * CTL: Lower 6 bits of most significant byte
55 55 */
56 56 #define FLG_SHOW_DYNAMIC 0x00000001
57 57 #define FLG_SHOW_EHDR 0x00000002
58 58 #define FLG_SHOW_INTERP 0x00000004
59 59 #define FLG_SHOW_SHDR 0x00000008
60 60 #define FLG_SHOW_NOTE 0x00000010
61 61 #define FLG_SHOW_PHDR 0x00000020
62 62 #define FLG_SHOW_RELOC 0x00000040
63 63 #define FLG_SHOW_SYMBOLS 0x00000080
64 64 #define FLG_SHOW_VERSIONS 0x00000100
65 65 #define FLG_SHOW_HASH 0x00000200
66 66 #define FLG_SHOW_GOT 0x00000400
67 67 #define FLG_SHOW_SYMINFO 0x00000800
68 68 #define FLG_SHOW_MOVE 0x00001000
69 69 #define FLG_SHOW_GROUP 0x00002000
70 70 #define FLG_SHOW_CAP 0x00004000
71 71 #define FLG_SHOW_UNWIND 0x00008000
72 72 #define FLG_SHOW_SORT 0x00010000
73 73
74 74 #define FLG_CTL_LONGNAME 0x01000000
75 75 #define FLG_CTL_DEMANGLE 0x02000000
76 76 #define FLG_CTL_FAKESHDR 0x04000000
77 77 #define FLG_CTL_MATCH 0x08000000
78 78 #define FLG_CTL_OSABI 0x10000000
79 79
80 80 #define FLG_CALC_CHECKSUM 0x40000000
81 81
82 82 /* Bitmasks that isolate the parts of a flag value */
83 83 #define FLG_MASK_SHOW 0x00ffffff
84 84 #define FLG_MASK_CTL 0x3f000000
85 85 #define FLG_MASK_CALC 0xc0000000
86 86
87 87 /*
88 88 * Mask that selects the show flags that do not require the ELF
89 89 * object to have a section header array.
90 90 */
91 91 #define FLG_MASK_SHOW_NOSHDR (FLG_SHOW_EHDR | FLG_SHOW_PHDR)
92 92
93 93 /*
94 94 * Masks to select the flags that require the ELF object to
95 95 * have a section header array, within each flag type.
96 96 */
97 97 #define FLG_MASK_SHOW_SHDR (FLG_MASK_SHOW & ~FLG_MASK_SHOW_NOSHDR)
98 98 #define FLG_MASK_CALC_SHDR FLG_CALC_CHECKSUM
99 99
100 100
101 101 /* Size of buffer used for formatting an index into textual representation */
102 102 #define MAXNDXSIZE 10
103 103
104 104 typedef struct cache {
105 105 Elf_Scn *c_scn;
106 106 Shdr *c_shdr;
107 107 Elf_Data *c_data;
108 108 char *c_name;
109 109 int c_ndx; /* Section index */
110 110 } Cache;
111 111
112 112 typedef struct got_info {
113 113 Word g_reltype; /* it will never happen, but */
114 114 /* support mixed relocations */
115 115 void *g_rel;
116 116 const char *g_symname;
117 117 } Got_info;
118 118
119 119 extern const Cache cache_init;
120 120
121 121 extern void failure(const char *, const char *);
122 122 extern const char *demangle(const char *, uint_t);
123 123
124 124
125 125 /*
126 126 * Flags for the match() function:
127 127 * MATCH_F_STRICT
128 128 * A strict match requires an explicit match to
129 129 * a user specified match (-I, -N, -T) option. A
130 130 * non-strict match also succeeds if the match
131 131 * list is empty.
132 132 *
133 133 * MATCH_F_PHDR
134 134 * The match item is a program header. If this
135 135 * flag is not set, the match item is a section
136 136 * header.
137 137 *
138 138 * MATCH_F_NAME
139 139 * The name parameter contains valid information.
140 140 *
141 141 * MATCH_F_NDX
142 142 * The ndx argument contains valid information
143 143 *
144 144 * MATCH_F_TYPE
145 145 * The type argument contains valid information
146 146 */
147 147 typedef enum {
148 148 MATCH_F_STRICT = 1,
149 149 MATCH_F_PHDR = 2,
150 150 MATCH_F_NAME = 4,
151 151 MATCH_F_NDX = 8,
152 152 MATCH_F_TYPE = 16
153 153 } match_flags_t;
154 154
155 155 /* It is common for calls to match() to specify all three arguments */
156 156 #define MATCH_F_ALL (MATCH_F_NAME | MATCH_F_NDX | MATCH_F_TYPE)
157 157
158 158 extern int match(match_flags_t, const char *, uint_t, uint_t);
159 159
160 160 /*
161 161 * Possible return values from corenote()
162 162 */
163 163 typedef enum {
164 164 CORENOTE_R_OK = 0, /* Note data successfully displayed */
165 165 CORENOTE_R_OK_DUMP = 1, /* Note OK, but not handled. Display Hex dump */
166 166 CORENOTE_R_BADDATA = 2, /* Note data truncated or otherwise malformed */
167 167 CORENOTE_R_BADARCH = 3, /* core file note code does not contain */
168 168 /* support for given architecture */
169 169 CORENOTE_R_BADTYPE = 4 /* Unknown note type */
170 170 } corenote_ret_t;
171 171
172 172 /*
173 173 * Define various elfdump() functions into their 32-bit and 64-bit variants.
174 174 */
175 175 #if defined(_ELF64)
176 176 #define cap cap64
177 177 #define checksum checksum64
178 178 #define dynamic dynamic64
179 179 #define fake_shdr_cache fake_shdr_cache64
180 180 #define fake_shdr_cache_free fake_shdr_cache_free64
181 181 #define got got64
182 182 #define group group64
183 183 #define hash hash64
184 184 #define interp interp64
185 185 #define move move64
186 186 #define note note64
187 187 #define note_entry note_entry64
188 188 #define regular regular64
189 189 #define reloc reloc64
190 190 #define sections sections64
191 191 #define string string64
192 192 #define symbols symbols64
193 193 #define syminfo syminfo64
194 194 #define symlookup symlookup64
195 195 #define unwind unwind64
196 196 #define versions versions64
197 197 #define version_def version_def64
198 198 #define version_need version_need64
199 199 #else
200 200 #define cap cap32
201 201 #define checksum checksum32
202 202 #define dynamic dynamic32
203 203 #define fake_shdr_cache fake_shdr_cache32
204 204 #define fake_shdr_cache_free fake_shdr_cache_free32
205 205 #define got got32
206 206 #define group group32
207 207 #define hash hash32
208 208 #define interp interp32
209 209 #define move move32
210 210 #define note note32
211 211 #define note_entry note_entry32
212 212 #define regular regular32
213 213 #define reloc reloc32
214 214 #define sections sections32
215 215 #define string string32
↓ open down ↓ |
215 lines elided |
↑ open up ↑ |
216 216 #define symbols symbols32
217 217 #define syminfo syminfo32
218 218 #define symlookup symlookup32
219 219 #define unwind unwind32
220 220 #define versions versions32
221 221 #define version_def version_def32
222 222 #define version_need version_need32
223 223 #endif
224 224
225 225 extern corenote_ret_t corenote(Half, int, Word, const char *, Word);
226 -extern void dump_eh_frame(uchar_t *, size_t, uint64_t, Half e_machine,
227 - uchar_t *e_ident, uint64_t gotaddr);
226 +extern void dump_eh_frame(const char *, char *, uchar_t *, size_t, uint64_t,
227 + Half e_machine, uchar_t *e_ident, uint64_t gotaddr);
228 228 extern void dump_hex_bytes(const void *, size_t, int, int, int);
229 229
230 230 extern int fake_shdr_cache32(const char *, int, Elf *, Elf32_Ehdr *,
231 231 Cache **, size_t *);
232 232 extern int fake_shdr_cache64(const char *, int, Elf *, Elf64_Ehdr *,
233 233 Cache **, size_t *);
234 234
235 235 extern void fake_shdr_cache_free32(Cache *, size_t);
236 236 extern void fake_shdr_cache_free64(Cache *, size_t);
237 237
238 238 extern int regular32(const char *, int, Elf *, uint_t, const char *, int,
239 239 uchar_t);
240 240 extern int regular64(const char *, int, Elf *, uint_t, const char *, int,
241 241 uchar_t);
242 242
243 243 #ifdef __cplusplus
244 244 }
245 245 #endif
246 246
247 247 #endif /* __ELFDUMP_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX