|
|
1.1 root 1: /* UNIX HEADER */
2: #include <stdio.h>
3:
4: /* SGS SPECIFIC HEADER */
5: #include "sgs.h"
6:
7: /* STRIP HEADER */
8: #include "defs.h"
9:
10: /* EXTERNAL VARIABLES DEFINED */
11: int lflag = OFF;
12: int xflag = OFF;
13: int bflag = OFF;
14: int rflag = OFF;
15: int sflag = OFF;
16: int fflag = OFF;
17:
18:
19: /* setflags(flagc, flagv)
20: *
21: * scans the command line for flags (arguments beginning with a '-')
22: * sets the appropriate flags and removes the flag arguments from the
23: * command line
24: *
25: * defines:
26: * - lflag = OFF by default
27: * = ON if -l appears in the command line: strip line nos only
28: * - xflag = OFF by default
29: * = ON if -x appears in command line: strip local symbols and
30: * line numbers only
31: * - bflag = OFF by default
32: * = ON if -b appears in command line: strip all local symbols
33: * except beginning and end of block (.bb and .eb) and
34: * beginning and end of function (.bf and .ef).
35: * - rflag = OFF by default
36: * = ON if -r appears in command line: strip all but static
37: * externs, .bf, and .ef
38: * - fflag = OFF by default
39: * = ON if -f appears in the command line, same as xflag plus
40: * strip relocation information for sections not of type
41: * type copy, for DMERT only
42: *
43: * prints an error message if any unknown flag shows up
44: *
45: * returns the number of arguments remaining in argv (they are repositioned
46: * in filev and are presumed to be object files).
47: */
48:
49:
50: int
51: setflags(flagc, flagv)
52:
53: int flagc;
54: char **flagv;
55:
56: {
57: /* UNIX FUNCTIONS CALLED */
58: extern fprintf( );
59:
60: /* EXTERNAL VARIABLES USED */
61: extern int lflag;
62: extern int xflag;
63: extern int bflag;
64: extern int rflag;
65: extern int sflag;
66: #if !UNIX
67: extern int fflag;
68: #endif
69:
70: /* LOCAL VARIABLES */
71: int filec;
72: char **filev;
73:
74:
75: for (filec = 0, filev = flagv; flagc > 0; --flagc, ++flagv) {
76: if (**flagv == '-') {
77: while(*++*flagv != '\0') {
78: switch(**flagv) {
79: case 'l':
80: lflag = ON;
81: break;
82:
83: case 'x':
84: xflag = ON;
85: break;
86:
87: case 'b':
88: bflag = ON;
89: break;
90:
91: case 'r':
92: rflag = ON;
93: break;
94: #if !UNIX
95: case 's':
96: sflag = ON;
97: break;
98: #endif
99:
100: #if !UNIX
101: case 'f':
102: fflag = ON;
103: rflag = ON;
104: break;
105: #endif
106: case 'V':
107: fprintf(stderr,"%s: strip -%s\n",SGSNAME,RELEASE);
108: break;
109:
110: default:
111: fprintf(stderr,
112: "%sstrip: unknown option \"%c\" ignored\n",
113: SGS, **flagv);
114: break;
115: }
116: }
117: } else {
118: *filev++ = *flagv;
119: ++filec;
120: }
121: }
122:
123:
124: if (lflag && sflag)
125: {
126: fprintf( stderr, "%sstrip: -l and -s are incompatible options\n", SGS );
127: exit(1);
128: }
129: if ((xflag || bflag) && rflag)
130: {
131: fprintf( stderr, "%sstrip: -x and -r are incompatible options\n", SGS );
132: exit(1);
133: }
134: if (lflag)
135: xflag = bflag = rflag = fflag = sflag = OFF;
136:
137: return(filec);
138: }
139: /*
140: * @(#)setflags.c 1.6 11/11/83;
141: */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.