diff options
author | phk <phk@FreeBSD.org> | 1995-10-15 14:31:10 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 1995-10-15 14:31:10 +0000 |
commit | 1852092e180f76b600e82beedab2e8fb5746f389 (patch) | |
tree | efda5382b7d8a5598943b04bdd698b2ff6beac20 /usr.bin/symorder/symorder.c | |
parent | ad11483a50f2885456d80eab7b33c69ea05a57e6 (diff) | |
download | FreeBSD-src-1852092e180f76b600e82beedab2e8fb5746f389.zip FreeBSD-src-1852092e180f76b600e82beedab2e8fb5746f389.tar.gz |
Add a '-c' option for cleaning namelists of various things.
Diffstat (limited to 'usr.bin/symorder/symorder.c')
-rw-r--r-- | usr.bin/symorder/symorder.c | 29 |
1 files changed, 25 insertions, 4 deletions
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; |