Add -x flag to remove stabs, compiler idents and local symbols.

This commit is contained in:
brezak 1993-08-27 02:33:34 +00:00
parent 815b51ef3a
commit 550ea769ff
2 changed files with 18 additions and 3 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" from: @(#)strip.1 6.6 (Berkeley) 5/26/91 .\" from: @(#)strip.1 6.6 (Berkeley) 5/26/91
.\" $Id: strip.1,v 1.2 1993/08/01 07:28:26 mycroft Exp $ .\" $Id: strip.1,v 1.3 1993/08/27 02:33:34 brezak Exp $
.\" .\"
.Dd May 26, 1991 .Dd May 26, 1991
.Dt STRIP 1 .Dt STRIP 1
@ -41,6 +41,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm strip .Nm strip
.Op Fl d .Op Fl d
.Op Fl x
.Ar file ... .Ar file ...
.Sh DESCRIPTION .Sh DESCRIPTION
The The
@ -55,6 +56,8 @@ The options are as follows:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl d .It Fl d
Delete only debugging and empty symbols. Delete only debugging and empty symbols.
.It Fl x
Delete only debugging, compiler identification, and local symbols.
.El .El
.Pp .Pp
.Nm Strip .Nm Strip

View File

@ -39,7 +39,7 @@ char copyright[] =
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)strip.c 5.8 (Berkeley) 11/6/91";*/ /*static char sccsid[] = "from: @(#)strip.c 5.8 (Berkeley) 11/6/91";*/
static char rcsid[] = "$Id: strip.c,v 1.4 1993/08/07 04:44:27 mycroft Exp $"; static char rcsid[] = "$Id: strip.c,v 1.5 1993/08/27 02:33:36 brezak Exp $";
#endif /* not lint */ #endif /* not lint */
#include <sys/types.h> #include <sys/types.h>
@ -63,6 +63,8 @@ void s_stab __P((const char *, int, EXEC *));
void s_sym __P((const char *, int, EXEC *)); void s_sym __P((const char *, int, EXEC *));
void usage __P((void)); void usage __P((void));
int xflag = 0;
main(argc, argv) main(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
@ -74,8 +76,11 @@ main(argc, argv)
char *fn; char *fn;
sfcn = s_sym; sfcn = s_sym;
while ((ch = getopt(argc, argv, "d")) != EOF) while ((ch = getopt(argc, argv, "dx")) != EOF)
switch(ch) { switch(ch) {
case 'x':
xflag = 1;
/*FALLTHROUGH*/
case 'd': case 'd':
sfcn = s_stab; sfcn = s_stab;
break; break;
@ -181,6 +186,13 @@ s_stab(fn, fd, ep)
*nsym = *sym; *nsym = *sym;
nsym->strx = nstr - nstrbase; nsym->strx = nstr - nstrbase;
p = strbase + sym->strx; p = strbase + sym->strx;
if (xflag &&
(!(sym->n_type & N_EXT) ||
strcmp(p, "gcc_compiled.") == 0 ||
strcmp(p, "gcc2_compiled.") == 0 ||
strcmp(p, "___gnu_compiled_c") == 0)) {
continue;
}
len = strlen(p) + 1; len = strlen(p) + 1;
bcopy(p, nstr, len); bcopy(p, nstr, len);
nstr += len; nstr += len;