/[gentoo-projects]/pax-utils/scanelf.c
Gentoo

Contents of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (hide annotations) (download) (as text)
Sat Apr 16 06:34:39 2005 UTC (9 years, 5 months ago) by vapier
Branch: MAIN
Changes since 1.36: +13 -7 lines
File MIME type: text/x-csrc
add a -y option to handle whether we scan symlinked files

1 solar 1.1 /*
2     * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 vapier 1.8 * Copyright 1999-2005 Gentoo Foundation
4 solar 1.1 * Distributed under the terms of the GNU General Public License v2
5 vapier 1.37 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.36 2005/04/15 22:02:03 vapier Exp $
6 solar 1.1 *
7     ********************************************************************
8     * This program is free software; you can redistribute it and/or
9     * modify it under the terms of the GNU General Public License as
10     * published by the Free Software Foundation; either version 2 of the
11     * License, or (at your option) any later version.
12     *
13     * This program is distributed in the hope that it will be useful, but
14     * WITHOUT ANY WARRANTY; without even the implied warranty of
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16     * General Public License for more details.
17     *
18     * You should have received a copy of the GNU General Public License
19     * along with this program; if not, write to the Free Software
20     * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21     * MA 02111-1307, USA.
22     */
23    
24     #include <stdio.h>
25     #include <stdlib.h>
26     #include <sys/types.h>
27 solar 1.28 #define __USE_GNU
28 solar 1.1 #include <string.h>
29 vapier 1.10 #include <errno.h>
30 solar 1.1 #include <unistd.h>
31     #include <sys/stat.h>
32     #include <dirent.h>
33     #include <getopt.h>
34 solar 1.20 #include <assert.h>
35 solar 1.21
36 solar 1.1 #include "paxelf.h"
37    
38 vapier 1.37 static const char *rcsid = "$Id: scanelf.c,v 1.36 2005/04/15 22:02:03 vapier Exp $";
39 vapier 1.36 #define argv0 "scanelf"
40 vapier 1.10
41    
42    
43     /* prototypes */
44     static void scanelf_file(const char *filename);
45     static void scanelf_dir(const char *path);
46     static void scanelf_ldpath();
47     static void scanelf_envpath();
48     static void usage(int status);
49     static void parseargs(int argc, char *argv[]);
50    
51     /* variables to control behavior */
52     static char scan_ldpath = 0;
53     static char scan_envpath = 0;
54 vapier 1.37 static char scan_symlink = 1;
55 vapier 1.10 static char dir_recurse = 0;
56 vapier 1.14 static char dir_crossmount = 1;
57 vapier 1.10 static char show_pax = 0;
58     static char show_stack = 0;
59     static char show_textrel = 0;
60     static char show_rpath = 0;
61 vapier 1.32 static char show_needed = 0;
62 solar 1.16 static char show_banner = 1;
63 vapier 1.10 static char be_quiet = 0;
64 vapier 1.14 static char be_verbose = 0;
65 vapier 1.27 static char *find_sym = NULL;
66 vapier 1.10
67 solar 1.1
68    
69 vapier 1.10 /* scan an elf file and show all the fun stuff */
70     static void scanelf_file(const char *filename)
71 solar 1.6 {
72 vapier 1.10 int i;
73 vapier 1.32 char found_pax, found_stack, found_relro, found_textrel,
74     found_rpath, found_needed, found_sym;
75 vapier 1.26 elfobj *elf;
76 solar 1.33 struct stat st;
77 vapier 1.10
78 vapier 1.37 /* make sure 'filename' exists */
79 solar 1.33 if (lstat(filename, &st) == -1)
80     return;
81 vapier 1.37 /* always handle regular files and handle symlinked files if no -y */
82     if (!(S_ISREG(st.st_mode) || (S_ISLNK(st.st_mode) && scan_symlink)))
83 solar 1.33 return;
84 vapier 1.37
85 vapier 1.32 found_pax = found_stack = found_relro = found_textrel = \
86     found_rpath = found_needed = found_sym = 0;
87 solar 1.12
88 vapier 1.10 /* verify this is real ELF */
89 vapier 1.14 if ((elf = readelf(filename)) == NULL) {
90 vapier 1.26 if (be_verbose > 2) printf("%s: not an ELF\n", filename);
91 vapier 1.10 return;
92 vapier 1.14 }
93    
94 vapier 1.26 if (be_verbose > 1)
95     printf("%s: {%s,%s} scanning file\n", filename,
96     get_elfeitype(elf, EI_CLASS, elf->elf_class),
97     get_elfeitype(elf, EI_DATA, elf->data[EI_DATA]));
98     else if (be_verbose)
99     printf("%s: scanning file\n", filename);
100 vapier 1.10
101     /* show the header */
102 solar 1.16 if (!be_quiet && show_banner) {
103 vapier 1.32 printf(" TYPE ");
104     if (show_pax) printf(" PAX ");
105     if (show_stack) printf("STK/REL ");
106 vapier 1.23 if (show_textrel) printf("TEXTREL ");
107     if (show_rpath) printf("RPATH ");
108 vapier 1.32 if (show_needed) printf("NEEDED ");
109 vapier 1.23 printf(" FILE\n");
110 solar 1.16 show_banner = 0;
111 vapier 1.10 }
112    
113     /* dump all the good stuff */
114     if (!be_quiet)
115 vapier 1.26 printf("%-7s ", get_elfetype(elf));
116 vapier 1.10
117 vapier 1.14 if (show_pax) {
118     char *paxflags = pax_short_hf_flags(PAX_FLAGS(elf));
119     if (!be_quiet || (be_quiet && strncmp(paxflags, "PeMRxS", 6))) {
120     found_pax = 1;
121     printf("%s ", pax_short_hf_flags(PAX_FLAGS(elf)));
122     }
123     }
124 vapier 1.10
125     /* stack fun */
126     if (show_stack) {
127 vapier 1.26 #define SHOW_STACK(B) \
128     if (elf->elf_class == ELFCLASS ## B) { \
129     Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
130     Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
131     for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
132     if (EGET(phdr[i].p_type) != PT_GNU_STACK && \
133     EGET(phdr[i].p_type) != PT_GNU_RELRO) continue; \
134     if (be_quiet && !(EGET(phdr[i].p_flags) & PF_X)) \
135     continue; \
136     if (EGET(phdr[i].p_type) == PT_GNU_STACK) \
137     found_stack = 1; \
138     if (EGET(phdr[i].p_type) == PT_GNU_RELRO) \
139     found_relro = 1; \
140     printf("%s ", gnu_short_stack_flags(EGET(phdr[i].p_flags))); \
141     } \
142 vapier 1.10 }
143 vapier 1.26 SHOW_STACK(32)
144     SHOW_STACK(64)
145 vapier 1.23 if (!be_quiet && !found_stack) printf("--- ");
146     if (!be_quiet && !found_relro) printf("--- ");
147 vapier 1.10 }
148    
149     /* textrel fun */
150     if (show_textrel) {
151 vapier 1.26 #define SHOW_TEXTREL(B) \
152     if (elf->elf_class == ELFCLASS ## B) { \
153     Elf ## B ## _Dyn *dyn; \
154     Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
155     Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
156     for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
157     if (phdr[i].p_type != PT_DYNAMIC) continue; \
158     dyn = DYN ## B (elf->data + EGET(phdr[i].p_offset)); \
159     while (EGET(dyn->d_tag) != DT_NULL) { \
160     if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \
161     found_textrel = 1; \
162     /*if (dyn->d_un.d_val & DF_TEXTREL)*/ \
163 solar 1.33 fputs("TEXTREL ", stdout); \
164 vapier 1.26 } \
165     ++dyn; \
166     } \
167     } }
168     SHOW_TEXTREL(32)
169     SHOW_TEXTREL(64)
170 solar 1.33 if (!be_quiet && !found_textrel) fputs("------- ", stdout);
171 vapier 1.10 }
172    
173     /* rpath fun */
174     /* TODO: if be_quiet, only output RPATH's which aren't in /etc/ld.so.conf */
175     if (show_rpath) {
176 vapier 1.23 char *rpath, *runpath;
177 vapier 1.26 void *strtbl_void = elf_findsecbyname(elf, ".dynstr");
178 vapier 1.23 rpath = runpath = NULL;
179 vapier 1.10
180 vapier 1.26 if (strtbl_void) {
181     #define SHOW_RPATH(B) \
182     if (elf->elf_class == ELFCLASS ## B) { \
183     Elf ## B ## _Dyn *dyn; \
184     Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
185     Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
186     Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
187     for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
188     if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \
189     dyn = DYN ## B (elf->data + EGET(phdr[i].p_offset)); \
190     while (EGET(dyn->d_tag) != DT_NULL) { \
191     if (EGET(dyn->d_tag) == DT_RPATH) { \
192     rpath = elf->data + EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \
193     found_rpath = 1; \
194     } else if (EGET(dyn->d_tag) == DT_RUNPATH) { \
195     runpath = elf->data + EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \
196     found_rpath = 1; \
197     } \
198     ++dyn; \
199     } \
200     } }
201     SHOW_RPATH(32)
202     SHOW_RPATH(64)
203 vapier 1.10 }
204 vapier 1.23 if (rpath && runpath) {
205     if (!strcmp(rpath, runpath))
206     printf("%-5s ", runpath);
207     else {
208     fprintf(stderr, "%s's RPATH [%s] != RUNPATH [%s]\n", filename, rpath, runpath);
209     printf("{%s,%s} ", rpath, runpath);
210     }
211     } else if (rpath || runpath)
212     printf("%-5s ", (runpath ? runpath : rpath));
213     else if (!be_quiet && !found_rpath)
214     printf(" - ");
215 vapier 1.10 }
216    
217 vapier 1.32 /* print out all the NEEDED entries */
218     if (show_needed) {
219     char *needed;
220     void *strtbl_void = elf_findsecbyname(elf, ".dynstr");
221    
222     if (strtbl_void) {
223     #define SHOW_NEEDED(B) \
224     if (elf->elf_class == ELFCLASS ## B) { \
225     Elf ## B ## _Dyn *dyn; \
226     Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \
227     Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \
228     Elf ## B ## _Shdr *strtbl = SHDR ## B (strtbl_void); \
229     for (i = 0; i < EGET(ehdr->e_phnum); i++) { \
230     if (be_verbose && EGET(phdr[i].p_type) == PT_INTERP) { \
231     dyn = DYN ## B (elf->data + EGET(phdr[i].p_offset)); \
232     printf("%s\n", elf->data + EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr)); \
233     exit(0); \
234     } \
235     if (EGET(phdr[i].p_type) != PT_DYNAMIC) continue; \
236     dyn = DYN ## B (elf->data + EGET(phdr[i].p_offset)); \
237     while (EGET(dyn->d_tag) != DT_NULL) { \
238     if (EGET(dyn->d_tag) == DT_NEEDED) { \
239     needed = elf->data + EGET(strtbl->sh_offset) + EGET(dyn->d_un.d_ptr); \
240     if (found_needed) printf(","); \
241     printf("%s", needed); \
242     found_needed = 1; \
243     } \
244     ++dyn; \
245     } \
246     } }
247     SHOW_NEEDED(32)
248     SHOW_NEEDED(64)
249     }
250     if (!be_quiet && !found_needed)
251     printf(" - ");
252     else if (found_needed)
253     printf(" ");
254     }
255    
256     /* search the symbol table for a specified symbol */
257 vapier 1.27 if (find_sym) {
258     void *symtab_void, *strtab_void;
259 vapier 1.32 char *versioned_symname;
260     size_t len;
261 solar 1.28
262 vapier 1.32 len = strlen(find_sym) + 1;
263     versioned_symname = (char *)malloc(sizeof(char) * (len+1));
264     if (!versioned_symname) {
265     warnf("Could not malloc() mem for sym scan");
266     return;
267     }
268 solar 1.28 sprintf(versioned_symname, "%s@", find_sym);
269 vapier 1.32
270 vapier 1.27 symtab_void = elf_findsecbyname(elf, ".symtab");
271     strtab_void = elf_findsecbyname(elf, ".strtab");
272    
273     if (symtab_void && strtab_void) {
274     #define FIND_SYM(B) \
275     if (elf->elf_class == ELFCLASS ## B) { \
276     Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \
277     Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \
278     Elf ## B ## _Sym *sym = SYM ## B (elf->data + EGET(symtab->sh_offset)); \
279     int cnt = EGET(symtab->sh_size) / EGET(symtab->sh_entsize); \
280     char *symname; \
281     for (i = 0; i < cnt; ++i) { \
282     if (sym->st_name) { \
283     symname = (char *)(elf->data + EGET(strtab->sh_offset) + EGET(sym->st_name)); \
284 solar 1.28 if (*find_sym == '*') { \
285 vapier 1.32 printf("%s(%s) %5lX %15s %s\n", \
286     ((found_sym == 0) ? "\n\t" : "\t"), \
287     (char *)basename(filename), \
288     (long)sym->st_size, \
289     (char *)get_elfstttype(sym->st_info), \
290     symname); \
291     found_sym = 1; \
292     } else if ((strcmp(find_sym, symname) == 0) || \
293     (strncmp(symname, versioned_symname, len) == 0)) \
294 solar 1.28 found_sym++; \
295 vapier 1.27 } \
296     ++sym; \
297     } }
298     FIND_SYM(32)
299     FIND_SYM(64)
300     }
301 solar 1.28 free(versioned_symname);
302 vapier 1.29 if (*find_sym != '*') {
303     if (found_sym)
304     printf(" %s ", find_sym);
305     else if (!be_quiet)
306 solar 1.33 fputs(" - ", stdout);
307 vapier 1.29 }
308 vapier 1.27 }
309 vapier 1.10
310 vapier 1.32 if (!be_quiet || found_pax || found_stack || found_textrel || \
311     found_rpath || found_needed || found_sym)
312 solar 1.33 puts(filename);
313 solar 1.28
314 vapier 1.10 unreadelf(elf);
315 solar 1.6 }
316    
317 solar 1.1 /* scan a directory for ET_EXEC files and print when we find one */
318 vapier 1.10 static void scanelf_dir(const char *path)
319 solar 1.1 {
320 vapier 1.10 register DIR *dir;
321     register struct dirent *dentry;
322 vapier 1.14 struct stat st_top, st;
323 solar 1.21 char buf[_POSIX_PATH_MAX];
324 vapier 1.32 size_t pathlen = 0, len = 0;
325 vapier 1.10
326     /* make sure path exists */
327 vapier 1.14 if (lstat(path, &st_top) == -1)
328 vapier 1.10 return;
329 solar 1.11
330 vapier 1.10 /* ok, if it isn't a directory, assume we can open it */
331 vapier 1.14 if (!S_ISDIR(st_top.st_mode)) {
332 vapier 1.10 scanelf_file(path);
333     return;
334     }
335    
336     /* now scan the dir looking for fun stuff */
337     if ((dir = opendir(path)) == NULL) {
338     warnf("could not opendir %s: %s", path, strerror(errno));
339     return;
340     }
341 vapier 1.15 if (be_verbose) printf("%s: scanning dir\n", path);
342 solar 1.11
343 vapier 1.32 pathlen = strlen(path);
344 vapier 1.10 while ((dentry = readdir(dir))) {
345     if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, ".."))
346     continue;
347 vapier 1.32 len = (pathlen + 1 + strlen(dentry->d_name) + 1);
348     if (len >= sizeof(buf)) {
349     warnf("Skipping '%s': len > sizeof(buf); %d > %d\n", path, (int)len, (int)sizeof(buf));
350     continue;
351     }
352 solar 1.31 sprintf(buf, "%s/%s", path, dentry->d_name);
353 solar 1.20 if (lstat(buf, &st) != -1) {
354 vapier 1.10 if (S_ISREG(st.st_mode))
355 solar 1.20 scanelf_file(buf);
356 vapier 1.10 else if (dir_recurse && S_ISDIR(st.st_mode)) {
357 vapier 1.14 if (dir_crossmount || (st_top.st_dev == st.st_dev))
358 solar 1.20 scanelf_dir(buf);
359 vapier 1.10 }
360     }
361     }
362     closedir(dir);
363 solar 1.1 }
364    
365 vapier 1.10 /* scan /etc/ld.so.conf for paths */
366     static void scanelf_ldpath()
367     {
368 vapier 1.17 char scan_l, scan_ul, scan_ull;
369 vapier 1.10 char *path, *p;
370     FILE *fp;
371    
372     if ((fp = fopen("/etc/ld.so.conf", "r")) == NULL)
373     err("Unable to open ld.so.conf: %s", strerror(errno));
374    
375 vapier 1.17 scan_l = scan_ul = scan_ull = 0;
376    
377 solar 1.30 if ((path = malloc(_POSIX_PATH_MAX)) == NULL) {
378     warn("Can not malloc() memory for ldpath scanning");
379     return;
380     }
381 vapier 1.10 while ((fgets(path, _POSIX_PATH_MAX, fp)) != NULL)
382     if (*path == '/') {
383     if ((p = strrchr(path, '\r')) != NULL)
384     *p = 0;
385     if ((p = strrchr(path, '\n')) != NULL)
386     *p = 0;
387 vapier 1.17 if (!scan_l && !strcmp(path, "/lib")) scan_l = 1;
388     if (!scan_ul && !strcmp(path, "/usr/lib")) scan_ul = 1;
389     if (!scan_ull && !strcmp(path, "/usr/local/lib")) scan_ull = 1;
390 vapier 1.10 scanelf_dir(path);
391     }
392     free(path);
393 vapier 1.32 fclose(fp);
394 vapier 1.10
395 vapier 1.17 if (!scan_l) scanelf_dir("/lib");
396     if (!scan_ul) scanelf_dir("/usr/lib");
397     if (!scan_ull) scanelf_dir("/usr/local/lib");
398 vapier 1.10 }
399 solar 1.1
400 vapier 1.10 /* scan env PATH for paths */
401     static void scanelf_envpath()
402 solar 1.1 {
403 solar 1.34 char *path, *p;
404 vapier 1.10
405     path = getenv("PATH");
406     if (!path)
407     err("PATH is not set in your env !");
408    
409 solar 1.34 if ((path = strdup(path)) == NULL)
410 vapier 1.32 err("strdup failed: %s", strerror(errno));
411 vapier 1.10
412     while ((p = strrchr(path, ':')) != NULL) {
413     scanelf_dir(p + 1);
414     *p = 0;
415     }
416 vapier 1.17
417 solar 1.34 free(path);
418 solar 1.1 }
419    
420    
421 vapier 1.10
422     /* usage / invocation handling functions */
423 vapier 1.37 #define PARSE_FLAGS "plRmyxetrns:aqvo:BhV"
424 vapier 1.27 #define a_argument required_argument
425 vapier 1.10 static struct option const long_opts[] = {
426     {"path", no_argument, NULL, 'p'},
427     {"ldpath", no_argument, NULL, 'l'},
428     {"recursive", no_argument, NULL, 'R'},
429 vapier 1.14 {"mount", no_argument, NULL, 'm'},
430 vapier 1.37 {"symlink", no_argument, NULL, 'y'},
431 vapier 1.10 {"pax", no_argument, NULL, 'x'},
432 solar 1.16 {"header", no_argument, NULL, 'e'},
433 vapier 1.10 {"textrel", no_argument, NULL, 't'},
434     {"rpath", no_argument, NULL, 'r'},
435 vapier 1.32 {"needed", no_argument, NULL, 'n'},
436 vapier 1.27 {"symbol", a_argument, NULL, 's'},
437 vapier 1.10 {"all", no_argument, NULL, 'a'},
438     {"quiet", no_argument, NULL, 'q'},
439 vapier 1.14 {"verbose", no_argument, NULL, 'v'},
440 vapier 1.27 {"file", a_argument, NULL, 'o'},
441 solar 1.16 {"nobanner", no_argument, NULL, 'B'},
442 vapier 1.10 {"help", no_argument, NULL, 'h'},
443     {"version", no_argument, NULL, 'V'},
444     {NULL, no_argument, NULL, 0x0}
445     };
446     static char *opts_help[] = {
447     "Scan all directories in PATH environment",
448     "Scan all directories in /etc/ld.so.conf",
449 vapier 1.14 "Scan directories recursively",
450 vapier 1.37 "Don't recursively cross mount points",
451     "Don't scan symlinks\n",
452 vapier 1.10 "Print PaX markings",
453     "Print GNU_STACK markings",
454     "Print TEXTREL information",
455     "Print RPATH information",
456 vapier 1.32 "Print NEEDED information",
457 vapier 1.27 "Find a specified symbol",
458 solar 1.16 "Print all scanned info (-x -e -t -r)\n",
459 vapier 1.14 "Only output 'bad' things",
460     "Be verbose (can be specified more than once)",
461 vapier 1.24 "Write output stream to a filename",
462 vapier 1.14 "Don't display the header",
463 vapier 1.10 "Print this help and exit",
464     "Print version and exit",
465     NULL
466     };
467    
468     /* display usage and exit */
469     static void usage(int status)
470 solar 1.1 {
471 vapier 1.10 int i;
472 vapier 1.37 printf(" Scan ELF binaries for stuff\n\n"
473 solar 1.35 "Usage: %s [options] <dir1/file1> [dir2 dirN fileN ...]\n\n", argv0);
474     printf("Options: -[%s]\n", PARSE_FLAGS);
475 vapier 1.10 for (i = 0; long_opts[i].name; ++i)
476 vapier 1.27 if (long_opts[i].has_arg == no_argument)
477     printf(" -%c, --%-13s %s\n", long_opts[i].val,
478     long_opts[i].name, opts_help[i]);
479     else
480     printf(" -%c, --%-6s <arg> %s\n", long_opts[i].val,
481     long_opts[i].name, opts_help[i]);
482 vapier 1.10 exit(status);
483 solar 1.1 }
484    
485     /* parse command line arguments and preform needed actions */
486 vapier 1.10 static void parseargs(int argc, char *argv[])
487     {
488     int flag;
489    
490     opterr = 0;
491     while ((flag=getopt_long(argc, argv, PARSE_FLAGS, long_opts, NULL)) != -1) {
492     switch (flag) {
493    
494     case 'V': /* version info */
495 solar 1.19 printf("%s compiled %s\n%s\n"
496     "%s written for Gentoo Linux by <solar and vapier @ gentoo.org>\n",
497     __FILE__, __DATE__, rcsid, argv0);
498 vapier 1.10 exit(EXIT_SUCCESS);
499     break;
500     case 'h': usage(EXIT_SUCCESS); break;
501    
502 vapier 1.24 case 'o': {
503 solar 1.21 FILE *fp = NULL;
504     fp = freopen(optarg, "w", stdout);
505 vapier 1.24 if (fp == NULL)
506     err("Could not open output stream '%s': %s", optarg, strerror(errno));
507     stdout = fp;
508 solar 1.21 break;
509     }
510 vapier 1.24
511 vapier 1.27 case 's': find_sym = strdup(optarg); break;
512    
513 vapier 1.37 case 'y': scan_symlink = 0; break;
514 solar 1.16 case 'B': show_banner = 0; break;
515 vapier 1.10 case 'l': scan_ldpath = 1; break;
516     case 'p': scan_envpath = 1; break;
517     case 'R': dir_recurse = 1; break;
518 vapier 1.14 case 'm': dir_crossmount = 0; break;
519 vapier 1.10 case 'x': show_pax = 1; break;
520 solar 1.16 case 'e': show_stack = 1; break;
521 vapier 1.10 case 't': show_textrel = 1; break;
522     case 'r': show_rpath = 1; break;
523 vapier 1.32 case 'n': show_needed = 1; break;
524 vapier 1.10 case 'q': be_quiet = 1; break;
525 vapier 1.14 case 'v': be_verbose = (be_verbose % 20) + 1; break;
526 vapier 1.32 case 'a': show_pax = show_stack = show_textrel = show_needed = show_rpath = 1; break;
527 vapier 1.10
528     case ':':
529     warn("Option missing parameter");
530     usage(EXIT_FAILURE);
531     break;
532     case '?':
533     warn("Unknown option");
534     usage(EXIT_FAILURE);
535     break;
536     default:
537     err("Unhandled option '%c'", flag);
538     break;
539     }
540     }
541    
542 vapier 1.14 if (be_quiet && be_verbose)
543     err("You can be quiet or you can be verbose, not both, stupid");
544    
545 vapier 1.10 if (scan_ldpath) scanelf_ldpath();
546     if (scan_envpath) scanelf_envpath();
547 vapier 1.25 if (optind == argc && !scan_ldpath && !scan_envpath)
548     err("Nothing to scan !?");
549 vapier 1.10 while (optind < argc)
550     scanelf_dir(argv[optind++]);
551 vapier 1.27
552     if (find_sym) free(find_sym);
553 vapier 1.10 }
554    
555    
556    
557     int main(int argc, char *argv[])
558 solar 1.1 {
559 vapier 1.10 if (argc < 2)
560     usage(EXIT_FAILURE);
561     parseargs(argc, argv);
562 solar 1.21 fclose(stdout);
563 vapier 1.10 return EXIT_SUCCESS;
564 solar 1.1 }

  ViewVC Help
Powered by ViewVC 1.1.20