/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.168 Revision 1.169
1/* 1/*
2 * Copyright 2003-2006 Gentoo Foundation 2 * Copyright 2003-2006 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2 3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.168 2007/01/08 22:57:01 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.169 2007/01/09 00:23:13 vapier Exp $
5 * 5 *
6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org> 6 * Copyright 2003-2006 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org> 7 * Copyright 2004-2006 Mike Frysinger - <vapier@gentoo.org>
8 */ 8 */
9 9
10#include "paxinc.h" 10#include "paxinc.h"
11 11
12static const char *rcsid = "$Id: scanelf.c,v 1.168 2007/01/08 22:57:01 vapier Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.169 2007/01/09 00:23:13 vapier Exp $";
13#define argv0 "scanelf" 13#define argv0 "scanelf"
14 14
15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') 15#define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+')
16 16
17/* prototypes */ 17/* prototypes */
388 /* show the raw details about this reloc */ \ 388 /* show the raw details about this reloc */ \
389 printf(" %s: ", elf->base_filename); \ 389 printf(" %s: ", elf->base_filename); \
390 if (sym && sym->st_name) \ 390 if (sym && sym->st_name) \
391 printf("%s", (char*)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name))); \ 391 printf("%s", (char*)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name))); \
392 else \ 392 else \
393 printf("(memory/fake?)"); \ 393 printf("(memory/data?)"); \
394 printf(" [0x%lX]", (unsigned long)r_offset); \ 394 printf(" [0x%lX]", (unsigned long)r_offset); \
395 /* now try to find the closest symbol that this rel is probably in */ \ 395 /* now try to find the closest symbol that this rel is probably in */ \
396 sym = SYM ## B (elf->data + EGET(symtab->sh_offset)); \ 396 sym = SYM ## B (elf->data + EGET(symtab->sh_offset)); \
397 func = NULL; \ 397 func = NULL; \
398 offset_tmp = 0; \ 398 offset_tmp = 0; \
402 offset_tmp = EGET(sym->st_value); \ 402 offset_tmp = EGET(sym->st_value); \
403 } \ 403 } \
404 ++sym; \ 404 ++sym; \
405 } \ 405 } \
406 printf(" in "); \ 406 printf(" in "); \
407 if (func && func->st_name) \ 407 if (func && func->st_name) { \
408 printf("%s", (char*)(elf->data + EGET(strtab->sh_offset) + EGET(func->st_name))); \ 408 const char *func_name = elf->data + EGET(strtab->sh_offset) + EGET(func->st_name); \
409 if (r_offset > EGET(func->st_size)) \
410 printf("(optimized out: previous %s)", func_name); \
409 else \ 411 else \
410 printf("(NULL: fake?)"); \ 412 printf("%s", func_name); \
413 } else \
414 printf("(optimized out)"); \
411 printf(" [0x%lX]\n", (unsigned long)offset_tmp); \ 415 printf(" [0x%lX]\n", (unsigned long)offset_tmp); \
412 if (be_verbose) { \ 416 if (be_verbose) { \
413 char *sysbuf; \ 417 char *sysbuf; \
414 size_t syslen; \ 418 size_t syslen; \
415 const char sysfmt[] = "objdump -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \ 419 const char sysfmt[] = "objdump -r -R -d -w -l --start-address=0x%lX --stop-address=0x%lX %s | grep --color -i -C 3 '.*[[:space:]]%lX:[[:space:]]*R_.*'\n"; \
416 syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \ 420 syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
417 sysbuf = xmalloc(syslen); \ 421 sysbuf = xmalloc(syslen); \
418 if (sysbuf) { \ 422 if (sysbuf) { \
423 Elf ## B ## _Addr end_addr = offset_tmp + EGET(func->st_size); \
424 if (end_addr < r_offset) \
425 /* not uncommon when things are optimized out */ \
426 end_addr = r_offset + 0x100; \
419 snprintf(sysbuf, syslen, sysfmt, \ 427 snprintf(sysbuf, syslen, sysfmt, \
420 (unsigned long)offset_tmp, \ 428 (unsigned long)offset_tmp, \
421 (unsigned long)(offset_tmp + EGET(func->st_size)), \ 429 (unsigned long)end_addr, \
422 elf->filename, \ 430 elf->filename, \
423 (unsigned long)r_offset); \ 431 (unsigned long)r_offset); \
424 fflush(stdout); \ 432 fflush(stdout); \
425 system(sysbuf); \ 433 system(sysbuf); \
426 fflush(stdout); \ 434 fflush(stdout); \

Legend:
Removed from v.1.168  
changed lines
  Added in v.1.169

  ViewVC Help
Powered by ViewVC 1.1.20