| 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.224 2011/08/08 01:56:16 vapier Exp $ |
4 | * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.225 2011/09/27 17:28:19 vapier 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.224 2011/08/08 01:56:16 vapier Exp $"; |
10 | static const char *rcsid = "$Id: scanelf.c,v 1.225 2011/09/27 17:28:19 vapier Exp $"; |
| 11 | const char argv0[] = "scanelf"; |
11 | const char 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 == '+') |
| … | |
… | |
| 1144 | *found_sym = 1; |
1144 | *found_sym = 1; |
| 1145 | if (next_sym) |
1145 | if (next_sym) |
| 1146 | next_sym[-1] = saved; |
1146 | next_sym[-1] = saved; |
| 1147 | } |
1147 | } |
| 1148 | |
1148 | |
| 1149 | static char *scanelf_file_sym(elfobj *elf, char *found_sym) |
1149 | static const char *scanelf_file_sym(elfobj *elf, char *found_sym) |
| 1150 | { |
1150 | { |
| 1151 | unsigned long i; |
1151 | unsigned long i; |
| 1152 | char *ret; |
1152 | char *ret; |
| 1153 | void *symtab_void, *strtab_void; |
1153 | void *symtab_void, *strtab_void; |
| 1154 | |
1154 | |
| … | |
… | |
| 1201 | if (*find_sym != '*' && *found_sym) |
1201 | if (*find_sym != '*' && *found_sym) |
| 1202 | return ret; |
1202 | return ret; |
| 1203 | if (be_quiet) |
1203 | if (be_quiet) |
| 1204 | return NULL; |
1204 | return NULL; |
| 1205 | else |
1205 | else |
| 1206 | return (char *)" - "; |
1206 | return " - "; |
| 1207 | } |
1207 | } |
| 1208 | |
1208 | |
| 1209 | static char *scanelf_file_sections(elfobj *elf, char *found_section) |
1209 | static const char *scanelf_file_sections(elfobj *elf, char *found_section) |
| 1210 | { |
1210 | { |
| 1211 | if (!find_section) |
1211 | if (!find_section) |
| 1212 | return NULL; |
1212 | return NULL; |
| 1213 | |
1213 | |
| 1214 | #define FIND_SECTION(B) \ |
1214 | #define FIND_SECTION(B) \ |
| … | |
… | |
| 1230 | return find_section; |
1230 | return find_section; |
| 1231 | |
1231 | |
| 1232 | if (be_quiet) |
1232 | if (be_quiet) |
| 1233 | return NULL; |
1233 | return NULL; |
| 1234 | else |
1234 | else |
| 1235 | return (char *)" - "; |
1235 | return " - "; |
| 1236 | } |
1236 | } |
| 1237 | |
1237 | |
| 1238 | /* scan an elf file and show all the fun stuff */ |
1238 | /* scan an elf file and show all the fun stuff */ |
| 1239 | #define prints(str) ({ ssize_t ret = write(fileno(stdout), str, strlen(str)); ret; }) |
1239 | #define prints(str) ({ ssize_t ret = write(fileno(stdout), str, strlen(str)); ret; }) |
| 1240 | static int scanelf_elfobj(elfobj *elf) |
1240 | static int scanelf_elfobj(elfobj *elf) |