From 1852092e180f76b600e82beedab2e8fb5746f389 Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 15 Oct 1995 14:31:10 +0000 Subject: Add a '-c' option for cleaning namelists of various things. --- usr.bin/symorder/symorder.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'usr.bin/symorder/symorder.c') diff --git a/usr.bin/symorder/symorder.c b/usr.bin/symorder/symorder.c index c7fbe4c..8ccb113 100644 --- a/usr.bin/symorder/symorder.c +++ b/usr.bin/symorder/symorder.c @@ -68,7 +68,7 @@ struct exec exec; struct stat stb; struct nlist *newtab, *symtab; off_t sa; -int nexclude, nsym, strtabsize, symfound, symkept, small, missing; +int nexclude, nsym, strtabsize, symfound, symkept, small, missing, clean; char *kfile, *newstrings, *strings, asym[BUFSIZ]; main(argc, argv) @@ -84,8 +84,11 @@ main(argc, argv) int ch, n, o; xfilename = NULL; - while ((ch = getopt(argc, argv, "mtx:")) != EOF) + while ((ch = getopt(argc, argv, "cmtx:")) != EOF) switch(ch) { + case 'c': + clean = 1; + break; case 'm': missing = 1; break; @@ -199,8 +202,12 @@ main(argc, argv) for (symp = symtab; --i >= 0; symp++) { if (symp->n_un.n_strx == 0) continue; - if (small && inlist(symp) < 0) - continue; + if (inlist(symp) < 0) { + if (small) + continue; + if (clean && !savesymb(symp)) + symp->n_type &= ~N_EXT; + } symp->n_un.n_strx -= sizeof(int); (void)strcpy(t, &strings[symp->n_un.n_strx]); symp->n_un.n_strx = (t - newstrings) + sizeof(int); @@ -240,6 +247,20 @@ main(argc, argv) exit(OKEXIT); } +savesymb(s) + register struct nlist *s; +{ + if ((s->n_type & N_EXT) != N_EXT) + return 0; + switch (s->n_type & N_TYPE) { + case N_TEXT: + case N_DATA: + return 0; + default: + return 1; + } +} + reorder(st1, st2, entries) register struct nlist *st1, *st2; int entries; -- cgit v1.1