Print this page
10476 file(1) could be smatch clean
10366 ld(1) should support GNU-style linker sets
10581 ld(1) should know kernel modules are a thing
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/file/elf_read.c
+++ new/usr/src/cmd/file/elf_read.c
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.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
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 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 -/* All Rights Reserved */
22 +/* All Rights Reserved */
23 23
24 24
25 25 /* Copyright (c) 1987, 1988 Microsoft Corporation */
26 26 /* All Rights Reserved */
27 27
28 28 /*
29 29 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
30 30 * Use is subject to license terms.
31 31 */
32 32
33 33 /*
34 34 * ELF files can exceed 2GB in size. A standard 32-bit program
35 35 * like 'file' cannot read past 2GB, and will be unable to see
36 36 * the ELF section headers that typically are at the end of the
37 37 * object. The simplest solution to this problem would be to make
38 38 * the 'file' command a 64-bit application. However, as a matter of
39 39 * policy, we do not want to require this. A simple command like
40 40 * 'file' should not carry such a requirement, especially as we
41 41 * support 32-bit only hardware.
42 42 *
43 43 * An alternative solution is to build this code as 32-bit
44 44 * large file aware. The usual way to do this is to define a pair
45 45 * of preprocessor definitions:
46 46 *
47 47 * _LARGEFILE64_SOURCE
48 48 * Map standard I/O routines to their largefile aware versions.
49 49 *
50 50 * _FILE_OFFSET_BITS=64
51 51 * Map off_t to off64_t
52 52 *
53 53 * The problem with this solution is that libelf is not large file capable,
54 54 * and the libelf header file will prevent compilation if
55 55 * _FILE_OFFSET_BITS is set to 64.
56 56 *
57 57 * So, the solution used in this code is to define _LARGEFILE64_SOURCE
58 58 * to get access to the 64-bit APIs, not to define _FILE_OFFSET_BITS, and to
59 59 * use our own types in place of off_t, and size_t. We read all the file
60 60 * data directly using pread64(), and avoid the use of libelf for anything
61 61 * other than the xlate functionality.
62 62 */
63 63 #define _LARGEFILE64_SOURCE
64 64 #define FILE_ELF_OFF_T off64_t
65 65 #define FILE_ELF_SIZE_T uint64_t
66 66
67 67 #include <ctype.h>
68 68 #include <unistd.h>
69 69 #include <fcntl.h>
70 70 #include <stdio.h>
71 71 #include <libelf.h>
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
72 72 #include <stdlib.h>
73 73 #include <limits.h>
74 74 #include <locale.h>
75 75 #include <string.h>
76 76 #include <errno.h>
77 77 #include <procfs.h>
78 78 #include <sys/param.h>
79 79 #include <sys/types.h>
80 80 #include <sys/stat.h>
81 81 #include <sys/elf.h>
82 +#include <sys/link.h>
82 83 #include <elfcap.h>
83 84 #include "file.h"
84 85 #include "elf_read.h"
85 86
86 87 extern const char *File;
87 88
88 89 static int get_class(void);
89 90 static int get_version(void);
90 91 static int get_format(void);
91 92 static int process_shdr(Elf_Info *);
92 93 static int process_phdr(Elf_Info *);
93 94 static int file_xlatetom(Elf_Type, char *);
94 95 static int xlatetom_nhdr(Elf_Nhdr *);
95 96 static int get_phdr(Elf_Info *, int);
96 97 static int get_shdr(Elf_Info *, int);
97 98
98 99 static Elf_Ehdr EI_Ehdr; /* Elf_Ehdr to be stored */
99 100 static Elf_Word EI_Ehdr_shnum; /* # section headers */
100 101 static Elf_Word EI_Ehdr_phnum; /* # program headers */
101 102 static Elf_Word EI_Ehdr_shstrndx; /* Index of section hdr string table */
102 103 static Elf_Shdr EI_Shdr; /* recent Elf_Shdr to be stored */
103 104 static Elf_Phdr EI_Phdr; /* recent Elf_Phdr to be stored */
104 105
105 106
106 107 static int
107 108 get_class(void)
108 109 {
109 110 return (EI_Ehdr.e_ident[EI_CLASS]);
110 111 }
111 112
112 113 static int
113 114 get_version(void)
114 115 {
115 116 /* do as what libelf:_elf_config() does */
116 117 return (EI_Ehdr.e_ident[EI_VERSION] ?
117 118 EI_Ehdr.e_ident[EI_VERSION] : 1);
↓ open down ↓ |
26 lines elided |
↑ open up ↑ |
118 119 }
119 120
120 121 static int
121 122 get_format(void)
122 123 {
123 124 return (EI_Ehdr.e_ident[EI_DATA]);
124 125 }
125 126
126 127 /*
127 128 * file_xlatetom: translate different headers from file
128 - * representation to memory representaion.
129 + * representation to memory representaion.
129 130 */
130 131 #define HDRSZ 512
131 132 static int
132 133 file_xlatetom(Elf_Type type, char *hdr)
133 134 {
134 135 Elf_Data src, dst;
135 136 char *hbuf[HDRSZ];
136 137 int version, format;
137 138
138 139 version = get_version();
139 140 format = get_format();
140 141
141 142 /* will convert only these types */
142 143 if (type != ELF_T_EHDR && type != ELF_T_PHDR &&
143 144 type != ELF_T_SHDR && type != ELF_T_WORD &&
144 - type != ELF_T_CAP)
145 + type != ELF_T_CAP && type != ELF_T_DYN)
145 146 return (ELF_READ_FAIL);
146 147
147 148 src.d_buf = (Elf_Void *)hdr;
148 149 src.d_type = type;
149 150 src.d_version = version;
150 151
151 152 dst.d_buf = (Elf_Void *)&hbuf;
152 153 dst.d_version = EV_CURRENT;
153 154
154 155 src.d_size = elf_fsize(type, 1, version);
155 156 dst.d_size = elf_fsize(type, 1, EV_CURRENT);
156 157 if (elf_xlatetom(&dst, &src, format) == NULL)
157 158 return (ELF_READ_FAIL);
158 159
159 160 (void) memcpy(hdr, &hbuf, dst.d_size);
160 161 return (ELF_READ_OKAY);
161 162 }
162 163
163 164 /*
164 165 * xlatetom_nhdr: There is no routine to convert Note header
165 - * so we convert each field of this header.
166 + * so we convert each field of this header.
166 167 */
167 168 static int
168 169 xlatetom_nhdr(Elf_Nhdr *nhdr)
169 170 {
170 171 int r = ELF_READ_FAIL;
171 172
172 173 r |= file_xlatetom(ELF_T_WORD, (char *)&nhdr->n_namesz);
173 174 r |= file_xlatetom(ELF_T_WORD, (char *)&nhdr->n_descsz);
174 175 r |= file_xlatetom(ELF_T_WORD, (char *)&nhdr->n_type);
175 176 return (r);
176 177 }
177 178
178 179 /*
179 180 * elf_read: reads elf header, program, section headers to
180 - * collect all information needed for file(1)
181 + * collect all information needed for file(1)
181 182 * output and stores them in Elf_Info.
182 183 */
183 184 int
184 185 elf_read(int fd, Elf_Info *EI)
185 186 {
186 187 FILE_ELF_SIZE_T size;
187 188 int ret = 1;
188 189
189 190 Elf_Ehdr *ehdr = &EI_Ehdr;
190 191
191 192 EI->elffd = fd;
192 193 size = sizeof (Elf_Ehdr);
193 194
194 195 if (pread64(EI->elffd, (void*)ehdr, size, 0) != size)
195 196 ret = 0;
196 197
197 198
198 199 if (file_xlatetom(ELF_T_EHDR, (char *)ehdr) == ELF_READ_FAIL)
199 200 ret = 0;
200 201
201 202 if (EI->file == NULL)
202 203 return (ELF_READ_FAIL);
203 204
204 205 /*
205 206 * Extended section or program indexes in use? If so, special
206 207 * values in the ELF header redirect us to get the real values
207 208 * from shdr[0].
208 209 */
209 210 EI_Ehdr_shnum = EI_Ehdr.e_shnum;
210 211 EI_Ehdr_phnum = EI_Ehdr.e_phnum;
211 212 EI_Ehdr_shstrndx = EI_Ehdr.e_shstrndx;
212 213 if (((EI_Ehdr_shnum == 0) || (EI_Ehdr_phnum == PN_XNUM)) &&
213 214 (EI_Ehdr.e_shoff != 0)) {
214 215 if (get_shdr(EI, 0) == ELF_READ_FAIL)
215 216 return (ELF_READ_FAIL);
216 217 if (EI_Ehdr_shnum == 0)
217 218 EI_Ehdr_shnum = EI_Shdr.sh_size;
218 219 if ((EI_Ehdr_phnum == PN_XNUM) && (EI_Shdr.sh_info != 0))
219 220 EI_Ehdr_phnum = EI_Shdr.sh_info;
220 221 if (EI_Ehdr_shstrndx == SHN_XINDEX)
221 222 EI_Ehdr_shstrndx = EI_Shdr.sh_link;
222 223 }
223 224
224 225 EI->type = ehdr->e_type;
225 226 EI->machine = ehdr->e_machine;
226 227 EI->flags = ehdr->e_flags;
227 228
228 229 if (ret == 0) {
229 230 (void) fprintf(stderr, gettext("%s: %s: can't "
230 231 "read ELF header\n"), File, EI->file);
231 232 return (ELF_READ_FAIL);
232 233 }
233 234 if (process_phdr(EI) == ELF_READ_FAIL)
234 235 return (ELF_READ_FAIL);
235 236
236 237 /* We don't need section info for core files */
237 238 if (ehdr->e_type != ET_CORE)
238 239 if (process_shdr(EI) == ELF_READ_FAIL)
239 240 return (ELF_READ_FAIL);
240 241
241 242 return (ELF_READ_OKAY);
242 243 }
243 244
244 245 /*
245 246 * get_phdr: reads program header of specified index.
246 247 */
247 248 static int
248 249 get_phdr(Elf_Info *EI, int inx)
249 250 {
250 251 FILE_ELF_OFF_T off = 0;
251 252 FILE_ELF_SIZE_T size;
252 253
253 254 if (inx >= EI_Ehdr_phnum)
254 255 return (ELF_READ_FAIL);
255 256
256 257 size = sizeof (Elf_Phdr);
257 258 off = (FILE_ELF_OFF_T)EI_Ehdr.e_phoff + (inx * size);
258 259 if (pread64(EI->elffd, (void *)&EI_Phdr, size, off) != size)
259 260 return (ELF_READ_FAIL);
260 261
261 262 if (file_xlatetom(ELF_T_PHDR, (char *)&EI_Phdr) == ELF_READ_FAIL)
262 263 return (ELF_READ_FAIL);
263 264
264 265 return (ELF_READ_OKAY);
265 266 }
266 267
267 268 /*
268 269 * get_shdr: reads section header of specified index.
269 270 */
270 271 static int
271 272 get_shdr(Elf_Info *EI, int inx)
272 273 {
273 274 FILE_ELF_OFF_T off = 0;
274 275 FILE_ELF_SIZE_T size;
275 276
276 277 /*
277 278 * Prevent access to non-existent section headers.
278 279 *
279 280 * A value of 0 for e_shoff means that there is no section header
280 281 * array in the file. A value of 0 for e_shndx does not necessarily
281 282 * mean this - there can still be a 1-element section header array
282 283 * to support extended section or program header indexes that
283 284 * exceed the 16-bit fields used in the ELF header to represent them.
284 285 */
285 286 if ((EI_Ehdr.e_shoff == 0) || ((inx > 0) && (inx >= EI_Ehdr_shnum)))
286 287 return (ELF_READ_FAIL);
287 288
288 289 size = sizeof (Elf_Shdr);
289 290 off = (FILE_ELF_OFF_T)EI_Ehdr.e_shoff + (inx * size);
290 291
291 292 if (pread64(EI->elffd, (void *)&EI_Shdr, size, off) != size)
292 293 return (ELF_READ_FAIL);
↓ open down ↓ |
102 lines elided |
↑ open up ↑ |
293 294
294 295 if (file_xlatetom(ELF_T_SHDR, (char *)&EI_Shdr) == ELF_READ_FAIL)
295 296 return (ELF_READ_FAIL);
296 297
297 298 return (ELF_READ_OKAY);
298 299 }
299 300
300 301 /*
301 302 * process_phdr: Read Program Headers and see if it is a core
302 303 * file of either new or (pre-restructured /proc)
303 - * type, read the name of the file that dumped this
304 + * type, read the name of the file that dumped this
304 305 * core, else see if this is a dynamically linked.
305 306 */
306 307 static int
307 308 process_phdr(Elf_Info *EI)
308 309 {
309 310 register int inx;
310 311
311 312 Elf_Nhdr Nhdr, *nhdr; /* note header just read */
312 313 Elf_Phdr *phdr = &EI_Phdr;
313 314
314 315 FILE_ELF_SIZE_T nsz, nmsz, dsz;
315 316 FILE_ELF_OFF_T offset;
316 317 int class;
317 318 int ntype;
318 319 char *psinfo, *fname;
319 320
320 321 nsz = sizeof (Elf_Nhdr);
321 322 nhdr = &Nhdr;
322 323 class = get_class();
323 324 for (inx = 0; inx < EI_Ehdr_phnum; inx++) {
324 325 if (get_phdr(EI, inx) == ELF_READ_FAIL)
325 326 return (ELF_READ_FAIL);
326 327
327 328 /* read the note if it is a core */
328 329 if (phdr->p_type == PT_NOTE &&
329 330 EI_Ehdr.e_type == ET_CORE) {
330 331 /*
331 332 * If the next segment is also a note, use it instead.
332 333 */
333 334 if (get_phdr(EI, inx+1) == ELF_READ_FAIL)
334 335 return (ELF_READ_FAIL);
335 336 if (phdr->p_type != PT_NOTE) {
336 337 /* read the first phdr back */
337 338 if (get_phdr(EI, inx) == ELF_READ_FAIL)
338 339 return (ELF_READ_FAIL);
339 340 }
340 341 offset = phdr->p_offset;
341 342 if (pread64(EI->elffd, (void *)nhdr, nsz, offset)
342 343 != nsz)
343 344 return (ELF_READ_FAIL);
344 345
345 346 /* Translate the ELF note header */
346 347 if (xlatetom_nhdr(nhdr) == ELF_READ_FAIL)
347 348 return (ELF_READ_FAIL);
348 349
349 350 ntype = nhdr->n_type;
350 351 nmsz = nhdr->n_namesz;
351 352 dsz = nhdr->n_descsz;
352 353
353 354 offset += nsz + ((nmsz + 0x03) & ~0x3);
354 355 if ((psinfo = malloc(dsz)) == NULL) {
355 356 int err = errno;
356 357 (void) fprintf(stderr, gettext("%s: malloc "
357 358 "failed: %s\n"), File, strerror(err));
358 359 exit(1);
359 360 }
360 361 if (pread64(EI->elffd, psinfo, dsz, offset) != dsz)
361 362 return (ELF_READ_FAIL);
362 363 /*
363 364 * We want to print the string contained
364 365 * in psinfo->pr_fname[], where 'psinfo'
365 366 * is either an old NT_PRPSINFO structure
366 367 * or a new NT_PSINFO structure.
367 368 *
368 369 * Old core files have only type NT_PRPSINFO.
369 370 * New core files have type NT_PSINFO.
370 371 *
371 372 * These structures are also different by
372 373 * virtue of being contained in a core file
373 374 * of either 32-bit or 64-bit type.
374 375 *
375 376 * To further complicate matters, we ourself
376 377 * might be compiled either 32-bit or 64-bit.
377 378 *
378 379 * For these reason, we just *know* the offsets of
379 380 * pr_fname[] into the four different structures
380 381 * here, regardless of how we are compiled.
381 382 */
382 383 if (class == ELFCLASS32) {
383 384 /* 32-bit core file, 32-bit structures */
384 385 if (ntype == NT_PSINFO)
385 386 fname = psinfo + 88;
386 387 else /* old: NT_PRPSINFO */
387 388 fname = psinfo + 84;
388 389 } else if (class == ELFCLASS64) {
389 390 /* 64-bit core file, 64-bit structures */
390 391 if (ntype == NT_PSINFO)
391 392 fname = psinfo + 136;
392 393 else /* old: NT_PRPSINFO */
393 394 fname = psinfo + 120;
394 395 }
395 396 EI->core_type = (ntype == NT_PRPSINFO)?
396 397 EC_OLDCORE : EC_NEWCORE;
397 398 (void) memcpy(EI->fname, fname, strlen(fname));
398 399 free(psinfo);
399 400 }
400 401 if (phdr->p_type == PT_DYNAMIC) {
401 402 EI->dynamic = B_TRUE;
402 403 }
403 404 }
404 405 return (ELF_READ_OKAY);
405 406 }
406 407
407 408 /*
↓ open down ↓ |
94 lines elided |
↑ open up ↑ |
408 409 * process_shdr: Read Section Headers to attempt to get HW/SW
409 410 * capabilities by looking at the SUNW_cap
410 411 * section and set string in Elf_Info.
411 412 * Also look for symbol tables and debug
412 413 * information sections. Set the "stripped" field
413 414 * in Elf_Info with corresponding flags.
414 415 */
415 416 static int
416 417 process_shdr(Elf_Info *EI)
417 418 {
418 - int capn, mac;
419 - int i, j, idx;
420 - FILE_ELF_OFF_T cap_off;
421 - FILE_ELF_SIZE_T csize;
419 + int mac;
420 + int i, idx;
422 421 char *strtab;
423 422 size_t strtab_sz;
424 - Elf_Cap Chdr;
423 + uint64_t j;
425 424 Elf_Shdr *shdr = &EI_Shdr;
426 425
427 -
428 - csize = sizeof (Elf_Cap);
429 426 mac = EI_Ehdr.e_machine;
430 427
431 428 /* if there are no sections, return success anyway */
432 429 if (EI_Ehdr.e_shoff == 0 && EI_Ehdr_shnum == 0)
433 430 return (ELF_READ_OKAY);
434 431
435 432 /* read section names from String Section */
436 433 if (get_shdr(EI, EI_Ehdr_shstrndx) == ELF_READ_FAIL)
437 434 return (ELF_READ_FAIL);
438 435
439 436 if ((strtab = malloc(shdr->sh_size)) == NULL)
440 437 return (ELF_READ_FAIL);
441 438
442 439 if (pread64(EI->elffd, strtab, shdr->sh_size, shdr->sh_offset)
443 440 != shdr->sh_size)
444 441 return (ELF_READ_FAIL);
445 442
446 443 strtab_sz = shdr->sh_size;
447 444
448 445 /* read all the sections and process them */
449 446 for (idx = 1, i = 0; i < EI_Ehdr_shnum; idx++, i++) {
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
450 447 char *shnam;
451 448
452 449 if (get_shdr(EI, i) == ELF_READ_FAIL)
453 450 return (ELF_READ_FAIL);
454 451
455 452 if (shdr->sh_type == SHT_NULL) {
456 453 idx--;
457 454 continue;
458 455 }
459 456
460 - cap_off = shdr->sh_offset;
461 457 if (shdr->sh_type == SHT_SUNW_cap) {
462 - char capstr[128];
458 + char capstr[128];
459 + Elf_Cap Chdr;
460 + FILE_ELF_OFF_T cap_off;
461 + FILE_ELF_SIZE_T csize;
462 + uint64_t capn;
463 +
464 + cap_off = shdr->sh_offset;
465 + csize = sizeof (Elf_Cap);
463 466
464 467 if (shdr->sh_size == 0 || shdr->sh_entsize == 0) {
465 468 (void) fprintf(stderr, ELF_ERR_ELFCAP1,
466 469 File, EI->file);
467 470 return (ELF_READ_FAIL);
468 471 }
469 472 capn = (shdr->sh_size / shdr->sh_entsize);
470 473 for (j = 0; j < capn; j++) {
471 474 /*
472 475 * read cap and xlate the values
473 476 */
474 - if (pread64(EI->elffd, &Chdr, csize, cap_off)
475 - != csize ||
477 + if ((pread64(EI->elffd, &Chdr, csize, cap_off)
478 + != csize) ||
476 479 file_xlatetom(ELF_T_CAP, (char *)&Chdr)
477 480 == 0) {
478 481 (void) fprintf(stderr, ELF_ERR_ELFCAP2,
479 482 File, EI->file);
480 483 return (ELF_READ_FAIL);
481 484 }
482 485
483 486 cap_off += csize;
484 487
485 488 /*
486 489 * Each capatibility group is terminated with
487 490 * CA_SUNW_NULL. Groups other than the first
488 491 * represent symbol capabilities, and aren't
489 492 * interesting here.
490 493 */
491 494 if (Chdr.c_tag == CA_SUNW_NULL)
492 495 break;
493 496
494 497 (void) elfcap_tag_to_str(ELFCAP_STYLE_UC,
↓ open down ↓ |
9 lines elided |
↑ open up ↑ |
495 498 Chdr.c_tag, Chdr.c_un.c_val, capstr,
496 499 sizeof (capstr), ELFCAP_FMT_SNGSPACE,
497 500 mac);
498 501
499 502 if ((*EI->cap_str != '\0') && (*capstr != '\0'))
500 503 (void) strlcat(EI->cap_str, " ",
501 504 sizeof (EI->cap_str));
502 505
503 506 (void) strlcat(EI->cap_str, capstr,
504 507 sizeof (EI->cap_str));
508 + }
509 + } else if (shdr->sh_type == SHT_DYNAMIC) {
510 + Elf_Dyn dyn;
511 + FILE_ELF_SIZE_T dsize;
512 + FILE_ELF_OFF_T doff;
513 + uint64_t dynn;
514 +
515 + doff = shdr->sh_offset;
516 + dsize = sizeof (Elf_Dyn);
517 +
518 + if (shdr->sh_size == 0 || shdr->sh_entsize == 0) {
519 + (void) fprintf(stderr, ELF_ERR_DYNAMIC1,
520 + File, EI->file);
521 + return (ELF_READ_FAIL);
522 + }
523 +
524 + dynn = (shdr->sh_size / shdr->sh_entsize);
525 + for (j = 0; j < dynn; j++) {
526 + if (pread64(EI->elffd, &dyn, dsize, doff)
527 + != dsize ||
528 + file_xlatetom(ELF_T_DYN, (char *)&dyn)
529 + == 0) {
530 + (void) fprintf(stderr, ELF_ERR_DYNAMIC2,
531 + File, EI->file);
532 + return (ELF_READ_FAIL);
533 + }
534 +
535 + doff += dsize;
536 +
537 + if ((dyn.d_tag == DT_SUNW_KMOD) &&
538 + (dyn.d_un.d_val == 1)) {
539 + EI->kmod = B_TRUE;
540 + }
505 541 }
506 542 }
507 543
508 544 /*
509 545 * Definition time:
510 546 * - "not stripped" means that an executable file
511 547 * contains a Symbol Table (.symtab)
512 548 * - "stripped" means that an executable file
513 549 * does not contain a Symbol Table.
514 550 * When strip -l or strip -x is run, it strips the
515 551 * debugging information (.line section name (strip -l),
516 552 * .line, .debug*, .stabs*, .dwarf* section names
517 553 * and SHT_SUNW_DEBUGSTR and SHT_SUNW_DEBUG
518 554 * section types (strip -x), however the Symbol
519 555 * Table will still be present.
520 556 * Therefore, if
521 557 * - No Symbol Table present, then report
522 558 * "stripped"
523 559 * - Symbol Table present with debugging
524 560 * information (line number or debug section names,
525 561 * or SHT_SUNW_DEBUGSTR or SHT_SUNW_DEBUG section
526 562 * types) then report:
527 563 * "not stripped"
528 564 * - Symbol Table present with no debugging
529 565 * information (line number or debug section names,
530 566 * or SHT_SUNW_DEBUGSTR or SHT_SUNW_DEBUG section
531 567 * types) then report:
532 568 * "not stripped, no debugging information
533 569 * available"
534 570 */
535 571 if ((EI->stripped & E_NOSTRIP) == E_NOSTRIP)
536 572 continue;
537 573
538 574 if (!(EI->stripped & E_SYMTAB) &&
539 575 (shdr->sh_type == SHT_SYMTAB)) {
540 576 EI->stripped |= E_SYMTAB;
541 577 continue;
542 578 }
543 579
544 580 if (shdr->sh_name >= strtab_sz)
545 581 shnam = NULL;
546 582 else
547 583 shnam = &strtab[shdr->sh_name];
548 584
549 585 if (!(EI->stripped & E_DBGINF) &&
550 586 ((shdr->sh_type == SHT_SUNW_DEBUG) ||
551 587 (shdr->sh_type == SHT_SUNW_DEBUGSTR) ||
552 588 (shnam != NULL && is_in_list(shnam)))) {
553 589 EI->stripped |= E_DBGINF;
554 590 }
555 591 }
556 592 free(strtab);
557 593
558 594 return (ELF_READ_OKAY);
559 595 }
↓ open down ↓ |
45 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX