summaryrefslogtreecommitdiffstats
path: root/usr.bin/symorder
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-10-15 14:31:10 +0000
committerphk <phk@FreeBSD.org>1995-10-15 14:31:10 +0000
commit1852092e180f76b600e82beedab2e8fb5746f389 (patch)
treeefda5382b7d8a5598943b04bdd698b2ff6beac20 /usr.bin/symorder
parentad11483a50f2885456d80eab7b33c69ea05a57e6 (diff)
downloadFreeBSD-src-1852092e180f76b600e82beedab2e8fb5746f389.zip
FreeBSD-src-1852092e180f76b600e82beedab2e8fb5746f389.tar.gz
Add a '-c' option for cleaning namelists of various things.
Diffstat (limited to 'usr.bin/symorder')
-rw-r--r--usr.bin/symorder/symorder.15
-rw-r--r--usr.bin/symorder/symorder.c29
2 files changed, 30 insertions, 4 deletions
diff --git a/usr.bin/symorder/symorder.1 b/usr.bin/symorder/symorder.1
index 1ed0888..2616ab3 100644
--- a/usr.bin/symorder/symorder.1
+++ b/usr.bin/symorder/symorder.1
@@ -39,6 +39,7 @@
.Nd rearrange name list
.Sh SYNOPSIS
.Nm symorder
+.Fl c
.Fl m
.Fl t
.Fl x
@@ -58,6 +59,10 @@ symbols read from
.Ar symlist
are relocated to the beginning of the table and in the order given.
.Bl -tag -width flag
+.It Fl c
+Makes all any symbols not in
+.Ar symlist
+local to this file.
.It Fl t
Restrict the symbol table to the symbols listed in
.Ar symlist .
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;
OpenPOWER on IntegriCloud