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

Contents of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.36 - (hide annotations) (download) (as text)
Fri Apr 15 22:02:03 2005 UTC (10 years, 1 month ago) by vapier
Branch: MAIN
Changes since 1.35: +3 -14 lines
File MIME type: text/x-csrc
move common warn/warnf/err macros to paxelf.h

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

  ViewVC Help
Powered by ViewVC 1.1.20