/[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.133 Revision 1.134
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.133 2006/03/08 05:32:53 vapier Exp $ 4 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.134 2006/03/15 03:20:29 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.133 2006/03/08 05:32:53 vapier Exp $"; 12static const char *rcsid = "$Id: scanelf.c,v 1.134 2006/03/15 03:20:29 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 17
853 char *symname; \ 853 char *symname; \
854 if (cnt) \ 854 if (cnt) \
855 cnt = EGET(symtab->sh_size) / cnt; \ 855 cnt = EGET(symtab->sh_size) / cnt; \
856 for (i = 0; i < cnt; ++i) { \ 856 for (i = 0; i < cnt; ++i) { \
857 if (sym->st_name) { \ 857 if (sym->st_name) { \
858 /* make sure the symbol name is in acceptable memory range */ \
858 symname = (char *)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name)); \ 859 symname = (char *)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name)); \
859 if ((void*)symname > (void*)elf->data_end) { \ 860 if ((void*)symname > (void*)elf->data_end) { \
860 warnf("%s: corrupt ELF symbols", elf->filename); \ 861 warnf("%s: corrupt ELF symbols", elf->filename); \
862 ++sym; \
861 continue; \ 863 continue; \
862 } \ 864 } \
865 /* debug display ... show all symbols and some extra info */ \
863 if (*find_sym == '*') { \ 866 if (*ret == '*') { \
864 printf("%s(%s) %5lX %15s %s\n", \ 867 printf("%s(%s) %5lX %15s %s\n", \
865 ((*found_sym == 0) ? "\n\t" : "\t"), \ 868 ((*found_sym == 0) ? "\n\t" : "\t"), \
866 elf->base_filename, \ 869 elf->base_filename, \
867 (unsigned long)sym->st_size, \ 870 (unsigned long)sym->st_size, \
868 get_elfstttype(sym->st_info), \ 871 get_elfstttype(sym->st_info), \
869 symname); \ 872 symname); \
870 *found_sym = 1; \ 873 *found_sym = 1; \
871 } else { \ 874 } else { \
875 /* allow the user to specify a comma delimited list of symbols to search for */ \
872 char *this_sym, *next_sym; \ 876 char *this_sym, *next_sym; \
873 this_sym = find_sym; \ 877 this_sym = ret; \
874 do { \ 878 do { \
875 next_sym = strchr(this_sym, ','); \ 879 next_sym = strchr(this_sym, ','); \
876 if (next_sym == NULL) \ 880 if (next_sym == NULL) \
877 next_sym = this_sym + strlen(this_sym); \ 881 next_sym = this_sym + strlen(this_sym); \
882 /* do we want a defined symbol ? */ \
883 if (*this_sym == '+') { \
884 if (sym->st_value == 0) \
885 goto skip_this_sym##B; \
886 ++this_sym; \
887 /* do we want an undefined symbol ? */ \
888 } else if (*this_sym == '-') { \
889 if (sym->st_value != 0) \
890 goto skip_this_sym##B; \
891 ++this_sym; \
892 } \
893 /* ok, lets compare the name now */ \
878 if ((strncmp(this_sym, symname, (next_sym-this_sym)) == 0 && symname[next_sym-this_sym] == '\0') || \ 894 if ((strncmp(this_sym, symname, (next_sym-this_sym)) == 0 && symname[next_sym-this_sym] == '\0') || \
879 (strcmp(symname, versioned_symname) == 0)) { \ 895 (strcmp(symname, versioned_symname) == 0)) { \
880 if (be_semi_verbose) { \ 896 if (be_semi_verbose) { \
881 char buf[126]; \ 897 char buf[126]; \
882 snprintf(buf, sizeof(buf), "%lX %s %s", \ 898 snprintf(buf, sizeof(buf), "%lX %s %s", \
885 } else \ 901 } else \
886 ret = this_sym; \ 902 ret = this_sym; \
887 (*found_sym)++; \ 903 (*found_sym)++; \
888 goto break_out; \ 904 goto break_out; \
889 } \ 905 } \
890 this_sym = next_sym + 1; \ 906 skip_this_sym##B: this_sym = next_sym + 1; \
891 } while (*next_sym != '\0'); \ 907 } while (*next_sym != '\0'); \
892 } \ 908 } \
893 } \ 909 } \
894 ++sym; \ 910 ++sym; \
895 } } 911 } }

Legend:
Removed from v.1.133  
changed lines
  Added in v.1.134

  ViewVC Help
Powered by ViewVC 1.1.20