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

Contents of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.32 - (hide annotations) (download) (as text)
Thu Apr 7 00:01:40 2005 UTC (9 years, 3 months ago) by vapier
Branch: MAIN
Changes since 1.31: +85 -26 lines
File MIME type: text/x-csrc
merge some fixes from tigger and add support for dumping DT_NEEDED information

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

  ViewVC Help
Powered by ViewVC 1.1.20