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

Diff of /pax-utils/scanelf.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.15 Revision 1.16
1/* 1/*
2 * Copyright 2003 Ned Ludd <solar@gentoo.org> 2 * Copyright 2003 Ned Ludd <solar@gentoo.org>
3 * Copyright 1999-2005 Gentoo Foundation 3 * Copyright 1999-2005 Gentoo Foundation
4 * Distributed under the terms of the GNU General Public License v2 4 * Distributed under the terms of the GNU General Public License v2
5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.15 2005/04/01 20:08:44 vapier Exp $ 5 * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.16 2005/04/01 20:44:11 solar Exp $
6 * 6 *
7 ******************************************************************** 7 ********************************************************************
8 * This program is free software; you can redistribute it and/or 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 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 10 * published by the Free Software Foundation; either version 2 of the
31#include <dirent.h> 31#include <dirent.h>
32#include <getopt.h> 32#include <getopt.h>
33 33
34#include "paxelf.h" 34#include "paxelf.h"
35 35
36static const char *rcsid = "$Id: scanelf.c,v 1.15 2005/04/01 20:08:44 vapier Exp $"; 36static const char *rcsid = "$Id: scanelf.c,v 1.16 2005/04/01 20:44:11 solar Exp $";
37 37
38 38
39/* helper functions for showing errors */ 39/* helper functions for showing errors */
40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/ 40#define argv0 "scanelf\0" /*((*argv != NULL) ? argv[0] : __FILE__ "\b\b")*/
41#define warn(fmt, args...) \ 41#define warn(fmt, args...) \
64static char dir_crossmount = 1; 64static char dir_crossmount = 1;
65static char show_pax = 0; 65static char show_pax = 0;
66static char show_stack = 0; 66static char show_stack = 0;
67static char show_textrel = 0; 67static char show_textrel = 0;
68static char show_rpath = 0; 68static char show_rpath = 0;
69static char show_header = 1; 69static char show_banner = 1;
70static char be_quiet = 0; 70static char be_quiet = 0;
71static char be_verbose = 0; 71static char be_verbose = 0;
72 72
73 73
74 74
93 } 93 }
94 94
95 if (be_verbose) printf("%s: scanning file\n", filename); 95 if (be_verbose) printf("%s: scanning file\n", filename);
96 96
97 /* show the header */ 97 /* show the header */
98 if (!be_quiet && show_header) { 98 if (!be_quiet && show_banner) {
99 fputs(" TYPE ", stdout); 99 fputs(" TYPE ", stdout);
100 if (show_pax) fputs(" PAX ", stdout); 100 if (show_pax) fputs(" PAX ", stdout);
101 if (show_stack) fputs(" STK/REL ", stdout); 101 if (show_stack) fputs(" STK/REL ", stdout);
102 if (show_textrel) fputs("TEXTREL ", stdout); 102 if (show_textrel) fputs("TEXTREL ", stdout);
103 if (show_rpath) fputs("RPATH ", stdout); 103 if (show_rpath) fputs("RPATH ", stdout);
104 fputs(" FILE\n", stdout); 104 fputs(" FILE\n", stdout);
105 show_header = 0; 105 show_banner = 0;
106 } 106 }
107 107
108 /* dump all the good stuff */ 108 /* dump all the good stuff */
109 if (!be_quiet) 109 if (!be_quiet)
110 printf("%-7s ", get_elfetype(elf->ehdr->e_type)); 110 printf("%-7s ", get_elfetype(elf->ehdr->e_type));
276} 276}
277 277
278 278
279 279
280/* usage / invocation handling functions */ 280/* usage / invocation handling functions */
281#define PARSE_FLAGS "plRmxstraqvHhV" 281#define PARSE_FLAGS "plRmxetraqvBhV"
282static struct option const long_opts[] = { 282static struct option const long_opts[] = {
283 {"path", no_argument, NULL, 'p'}, 283 {"path", no_argument, NULL, 'p'},
284 {"ldpath", no_argument, NULL, 'l'}, 284 {"ldpath", no_argument, NULL, 'l'},
285 {"recursive", no_argument, NULL, 'R'}, 285 {"recursive", no_argument, NULL, 'R'},
286 {"mount", no_argument, NULL, 'm'}, 286 {"mount", no_argument, NULL, 'm'},
287 {"pax", no_argument, NULL, 'x'}, 287 {"pax", no_argument, NULL, 'x'},
288 {"stack", no_argument, NULL, 's'}, 288 {"header", no_argument, NULL, 'e'},
289 {"textrel", no_argument, NULL, 't'}, 289 {"textrel", no_argument, NULL, 't'},
290 {"rpath", no_argument, NULL, 'r'}, 290 {"rpath", no_argument, NULL, 'r'},
291 {"all", no_argument, NULL, 'a'}, 291 {"all", no_argument, NULL, 'a'},
292 {"quiet", no_argument, NULL, 'q'}, 292 {"quiet", no_argument, NULL, 'q'},
293 {"verbose", no_argument, NULL, 'v'}, 293 {"verbose", no_argument, NULL, 'v'},
294 {"noheader", no_argument, NULL, 'H'}, 294 {"nobanner", no_argument, NULL, 'B'},
295 {"help", no_argument, NULL, 'h'}, 295 {"help", no_argument, NULL, 'h'},
296 {"version", no_argument, NULL, 'V'}, 296 {"version", no_argument, NULL, 'V'},
297 {NULL, no_argument, NULL, 0x0} 297 {NULL, no_argument, NULL, 0x0}
298}; 298};
299static char *opts_help[] = { 299static char *opts_help[] = {
303 "Don't recursively cross mount points\n", 303 "Don't recursively cross mount points\n",
304 "Print PaX markings", 304 "Print PaX markings",
305 "Print GNU_STACK markings", 305 "Print GNU_STACK markings",
306 "Print TEXTREL information", 306 "Print TEXTREL information",
307 "Print RPATH information", 307 "Print RPATH information",
308 "Print all scanned info (-x -s -t -r)\n", 308 "Print all scanned info (-x -e -t -r)\n",
309 "Only output 'bad' things", 309 "Only output 'bad' things",
310 "Be verbose (can be specified more than once)", 310 "Be verbose (can be specified more than once)",
311 "Don't display the header", 311 "Don't display the header",
312 "Print this help and exit", 312 "Print this help and exit",
313 "Print version and exit", 313 "Print version and exit",
322 "Usage: %s [options] <dir1> [dir2 dirN ...]\n\n", argv0); 322 "Usage: %s [options] <dir1> [dir2 dirN ...]\n\n", argv0);
323 fputs("Options:\n", stdout); 323 fputs("Options:\n", stdout);
324 for (i = 0; long_opts[i].name; ++i) 324 for (i = 0; long_opts[i].name; ++i)
325 printf(" -%c, --%-12s %s\n", long_opts[i].val, 325 printf(" -%c, --%-12s %s\n", long_opts[i].val,
326 long_opts[i].name, opts_help[i]); 326 long_opts[i].name, opts_help[i]);
327#ifdef MANLYPAGE
328 for (i = 0; long_opts[i].name; ++i)
329 printf(".TP\n\\fB\\-%c, \\-\\-%s\\fR\n%s\n", long_opts[i].val,
330 long_opts[i].name, opts_help[i]);
331#endif
327 exit(status); 332 exit(status);
328} 333}
329 334
330/* parse command line arguments and preform needed actions */ 335/* parse command line arguments and preform needed actions */
331static void parseargs(int argc, char *argv[]) 336static void parseargs(int argc, char *argv[])
341 "%s written for Gentoo Linux by <solar and vapier @ gentoo.org>\n" 346 "%s written for Gentoo Linux by <solar and vapier @ gentoo.org>\n"
342 "%s\n", 347 "%s\n",
343 __FILE__, __DATE__, argv0, rcsid); 348 __FILE__, __DATE__, argv0, rcsid);
344 exit(EXIT_SUCCESS); 349 exit(EXIT_SUCCESS);
345 break; 350 break;
351 case 's': /* reserved for -s, --symbol= */
346 case 'h': usage(EXIT_SUCCESS); break; 352 case 'h': usage(EXIT_SUCCESS); break;
347 353
348 case 'H': show_header = 0; break; 354 case 'B': show_banner = 0; break;
349 case 'l': scan_ldpath = 1; break; 355 case 'l': scan_ldpath = 1; break;
350 case 'p': scan_envpath = 1; break; 356 case 'p': scan_envpath = 1; break;
351 case 'R': dir_recurse = 1; break; 357 case 'R': dir_recurse = 1; break;
352 case 'm': dir_crossmount = 0; break; 358 case 'm': dir_crossmount = 0; break;
353 case 'x': show_pax = 1; break; 359 case 'x': show_pax = 1; break;
354 case 's': show_stack = 1; break; 360 case 'e': show_stack = 1; break;
355 case 't': show_textrel = 1; break; 361 case 't': show_textrel = 1; break;
356 case 'r': show_rpath = 1; break; 362 case 'r': show_rpath = 1; break;
357 case 'q': be_quiet = 1; break; 363 case 'q': be_quiet = 1; break;
358 case 'v': be_verbose = (be_verbose % 20) + 1; break; 364 case 'v': be_verbose = (be_verbose % 20) + 1; break;
359 case 'a': show_pax = show_stack = show_textrel = show_rpath = 1; break; 365 case 'a': show_pax = show_stack = show_textrel = show_rpath = 1; break;

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20