| 1 | /* |
1 | /* |
| 2 | * Copyright 2003-2007 Gentoo Foundation |
2 | * Copyright 2003-2007 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.199 2008/12/10 20:05:20 grobian Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.200 2008/12/10 20:06:20 grobian Exp $ |
| 5 | * |
5 | * |
| 6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
6 | * Copyright 2003-2007 Ned Ludd - <solar@gentoo.org> |
| 7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
7 | * Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org> |
| 8 | */ |
8 | */ |
| 9 | |
9 | |
| 10 | static const char *rcsid = "$Id: scanelf.c,v 1.199 2008/12/10 20:05:20 grobian Exp $"; |
10 | static const char *rcsid = "$Id: scanelf.c,v 1.200 2008/12/10 20:06:20 grobian Exp $"; |
| 11 | const char * const argv0 = "scanelf"; |
11 | const char * const argv0 = "scanelf"; |
| 12 | |
12 | |
| 13 | #include "paxinc.h" |
13 | #include "paxinc.h" |
| 14 | |
14 | |
| 15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
15 | #define IS_MODIFIER(c) (c == '%' || c == '#' || c == '+') |
| … | |
… | |
| 1037 | char *this_sym, *next_sym; \ |
1037 | char *this_sym, *next_sym; \ |
| 1038 | next_sym = ret; \ |
1038 | next_sym = ret; \ |
| 1039 | while (next_sym) { \ |
1039 | while (next_sym) { \ |
| 1040 | this_sym = next_sym; \ |
1040 | this_sym = next_sym; \ |
| 1041 | if ((next_sym = strchr(this_sym, ','))) \ |
1041 | if ((next_sym = strchr(this_sym, ','))) \ |
| 1042 | *next_sym++ = '\0'; /* Skip the comma */ \ |
1042 | next_sym += 1; /* Skip the comma */ \ |
| 1043 | /* do we want a defined symbol ? */ \ |
1043 | /* do we want a defined symbol ? */ \ |
| 1044 | if (*this_sym == '+') { \ |
1044 | if (*this_sym == '+') { \ |
| 1045 | if (sym->st_shndx == SHN_UNDEF) \ |
1045 | if (sym->st_shndx == SHN_UNDEF) \ |
| 1046 | continue; \ |
1046 | continue; \ |
| 1047 | ++this_sym; \ |
1047 | ++this_sym; \ |
| … | |
… | |
| 1049 | } else if (*this_sym == '-') { \ |
1049 | } else if (*this_sym == '-') { \ |
| 1050 | if (sym->st_shndx != SHN_UNDEF) \ |
1050 | if (sym->st_shndx != SHN_UNDEF) \ |
| 1051 | continue; \ |
1051 | continue; \ |
| 1052 | ++this_sym; \ |
1052 | ++this_sym; \ |
| 1053 | } \ |
1053 | } \ |
|
|
1054 | if (next_sym) /* Copy it so that we don't have to worry about the final , */ \ |
|
|
1055 | this_sym = strndup(this_sym, next_sym-this_sym); \ |
| 1054 | /* ok, lets compare the name now */ \ |
1056 | /* ok, lets compare the name now */ \ |
| 1055 | if (scanelf_match_symname(this_sym, symname)) { \ |
1057 | if (scanelf_match_symname(this_sym, symname)) { \ |
| 1056 | if (be_semi_verbose) { \ |
1058 | if (be_semi_verbose) { \ |
| 1057 | char buf[126]; \ |
1059 | char buf[126]; \ |
| 1058 | snprintf(buf, sizeof(buf), "%lX %s %s", \ |
1060 | snprintf(buf, sizeof(buf), "%lX %s %s", \ |
| … | |
… | |
| 1061 | } else \ |
1063 | } else \ |
| 1062 | ret = symname; \ |
1064 | ret = symname; \ |
| 1063 | (*found_sym)++; \ |
1065 | (*found_sym)++; \ |
| 1064 | goto break_out; \ |
1066 | goto break_out; \ |
| 1065 | } \ |
1067 | } \ |
|
|
1068 | if (next_sym) free(this_sym); \ |
| 1066 | } \ |
1069 | } \ |
| 1067 | } \ |
1070 | } \ |
| 1068 | } \ |
1071 | } \ |
| 1069 | ++sym; \ |
1072 | ++sym; \ |
| 1070 | } } |
1073 | } } |