/[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.169 Revision 1.170
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.169 2007/01/09 00:23:13 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.170 2007/01/09 18:46:22 solar 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.169 2007/01/09 00:23:13 vapier Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.170 2007/01/09 18:46:22 solar 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 */
73int match_bits = 0; 73int match_bits = 0;
74caddr_t ldcache = 0; 74caddr_t ldcache = 0;
75size_t ldcache_size = 0; 75size_t ldcache_size = 0;
76unsigned long setpax = 0UL; 76unsigned long setpax = 0UL;
77 77
78int has_objdump = 0;
78 79
80static char *which(const char *fname)
81{
82 static char fullpath[BUFSIZ];
83 char *path, *p;
84
85 memset(fullpath, 0x0, sizeof(fullpath));
86
87 path = getenv("PATH");
88
89 if (!path)
90 return NULL;
91
92 path = xstrdup(path);
93 while ((p = strrchr(path, ':')) != NULL) {
94 snprintf(fullpath, sizeof(fullpath), "%s/%s", p + 1, fname);
95 *p = 0;
96 if (access(fullpath, R_OK) != (-1)) {
97 free(path);
98 return (char *) fullpath;
99 }
100 }
101 free(path);
102 return NULL;
103}
79 104
80/* sub-funcs for scanelf_file() */ 105/* sub-funcs for scanelf_file() */
81static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab) 106static void scanelf_file_get_symtabs(elfobj *elf, void **sym, void **tab)
82{ 107{
83 /* find the best SHT_DYNSYM and SHT_STRTAB sections */ 108 /* find the best SHT_DYNSYM and SHT_STRTAB sections */
411 else \ 436 else \
412 printf("%s", func_name); \ 437 printf("%s", func_name); \
413 } else \ 438 } else \
414 printf("(optimized out)"); \ 439 printf("(optimized out)"); \
415 printf(" [0x%lX]\n", (unsigned long)offset_tmp); \ 440 printf(" [0x%lX]\n", (unsigned long)offset_tmp); \
416 if (be_verbose) { \ 441 if (be_verbose && has_objdump) { \
417 char *sysbuf; \ 442 char *sysbuf; \
418 size_t syslen; \ 443 size_t syslen; \
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"; \ 444 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"; \
420 syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \ 445 syslen = sizeof(sysfmt) + strlen(elf->filename) + 3 * sizeof(unsigned long) + 1; \
421 sysbuf = xmalloc(syslen); \ 446 sysbuf = xmalloc(syslen); \
1757 err("Unknown option '%c' or argument missing", optopt); 1782 err("Unknown option '%c' or argument missing", optopt);
1758 default: 1783 default:
1759 err("Unhandled option '%c'; please report this", i); 1784 err("Unhandled option '%c'; please report this", i);
1760 } 1785 }
1761 } 1786 }
1762 1787 if (show_textrels && be_verbose) {
1788 if (which("objdump") != NULL)
1789 has_objdump = 1;
1790 }
1763 /* let the format option override all other options */ 1791 /* let the format option override all other options */
1764 if (out_format) { 1792 if (out_format) {
1765 show_pax = show_phdr = show_textrel = show_rpath = \ 1793 show_pax = show_phdr = show_textrel = show_rpath = \
1766 show_needed = show_interp = show_bind = show_soname = \ 1794 show_needed = show_interp = show_bind = show_soname = \
1767 show_textrels = 0; 1795 show_textrels = 0;

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

  ViewVC Help
Powered by ViewVC 1.1.20