| 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.176 2007/04/08 19:14:31 solar Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.177 2007/05/20 23:20:46 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 | |
| 12 | static const char *rcsid = "$Id: scanelf.c,v 1.176 2007/04/08 19:14:31 solar Exp $"; |
12 | static const char *rcsid = "$Id: scanelf.c,v 1.177 2007/05/20 23:20:46 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 */ |
| … | |
… | |
| 952 | SHOW_SONAME(64) |
952 | SHOW_SONAME(64) |
| 953 | } |
953 | } |
| 954 | |
954 | |
| 955 | return NULL; |
955 | return NULL; |
| 956 | } |
956 | } |
|
|
957 | |
| 957 | static char *scanelf_file_sym(elfobj *elf, char *found_sym) |
958 | static char *scanelf_file_sym(elfobj *elf, char *found_sym) |
| 958 | { |
959 | { |
| 959 | unsigned long i; |
960 | unsigned long i; |
| 960 | char *ret; |
961 | char *ret; |
| 961 | void *symtab_void, *strtab_void; |
962 | void *symtab_void, *strtab_void; |
| … | |
… | |
| 984 | ++sym; \ |
985 | ++sym; \ |
| 985 | continue; \ |
986 | continue; \ |
| 986 | } \ |
987 | } \ |
| 987 | /* debug display ... show all symbols and some extra info */ \ |
988 | /* debug display ... show all symbols and some extra info */ \ |
| 988 | if (g_match ? rematch(ret, symname, REG_EXTENDED) == 0 : *ret == '*') { \ |
989 | if (g_match ? rematch(ret, symname, REG_EXTENDED) == 0 : *ret == '*') { \ |
| 989 | printf("%s(%s) %5lX %15s %s\n", \ |
990 | printf("%s(%s) %5lX %15s %s %s\n", \ |
| 990 | ((*found_sym == 0) ? "\n\t" : "\t"), \ |
991 | ((*found_sym == 0) ? "\n\t" : "\t"), \ |
| 991 | elf->base_filename, \ |
992 | elf->base_filename, \ |
| 992 | (unsigned long)sym->st_size, \ |
993 | (unsigned long)sym->st_size, \ |
| 993 | get_elfstttype(sym->st_info), \ |
994 | get_elfstttype(sym->st_info), \ |
| 994 | symname); \ |
995 | sym->st_shndx == SHN_UNDEF ? "U" : "D", symname); \ |
| 995 | *found_sym = 1; \ |
996 | *found_sym = 1; \ |
| 996 | } else { \ |
997 | } else { \ |
| 997 | /* allow the user to specify a comma delimited list of symbols to search for */ \ |
998 | /* allow the user to specify a comma delimited list of symbols to search for */ \ |
| 998 | char *this_sym, *this_sym_ver, *next_sym; \ |
999 | char *this_sym, *this_sym_ver, *next_sym; \ |
| 999 | this_sym = ret; \ |
1000 | this_sym = ret; \ |