Add new option -P to print only the symbol table size.

This commit is contained in:
joerg 2014-08-17 19:12:59 +00:00
parent 5b3354816c
commit 5983af161f
2 changed files with 21 additions and 7 deletions

View File

@ -1,6 +1,6 @@
.\" $NetBSD: dbsym.8,v 1.3 2012/03/19 09:13:33 wiz Exp $ .\" $NetBSD: dbsym.8,v 1.4 2014/08/17 19:12:59 joerg Exp $
.\" .\"
.Dd March 19, 2012 .Dd August 14, 2014
.Dt DBSYM 8 .Dt DBSYM 8
.Os .Os
.Sh NAME .Sh NAME
@ -8,7 +8,7 @@
.Nd copy kernel symbol table into db_symtab space .Nd copy kernel symbol table into db_symtab space
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl pv .Op Fl Ppv
.Op Fl b Ar bfdname .Op Fl b Ar bfdname
.Ar kernel .Ar kernel
.Sh DESCRIPTION .Sh DESCRIPTION
@ -34,6 +34,12 @@ To recognize kernel executable format, the
flag specifies BFD name of kernel. flag specifies BFD name of kernel.
.Pp .Pp
If the If the
.Fl P
flag is given,
.Nm
will report the size of the kernel symbol table.
.Pp
If the
.Fl p .Fl p
flag is given, flag is given,
.Nm .Nm

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $ */ /* $NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $ */
/* /*
* Copyright (c) 2001 Simon Burge (for Wasabi Systems) * Copyright (c) 2001 Simon Burge (for Wasabi Systems)
@ -39,7 +39,7 @@
__COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\ __COPYRIGHT("@(#) Copyright (c) 1996 Christopher G. Demetriou.\
Copyright 2001 Simon Burge.\ Copyright 2001 Simon Burge.\
All rights reserved."); All rights reserved.");
__RCSID("$NetBSD: dbsym.c,v 1.3 2012/03/19 09:14:15 wiz Exp $"); __RCSID("$NetBSD: dbsym.c,v 1.4 2014/08/17 19:12:59 joerg Exp $");
#endif /* not lint */ #endif /* not lint */
#include <sys/param.h> #include <sys/param.h>
@ -76,6 +76,7 @@ int load_symtab(bfd *, int fd, char **, u_int32_t *);
int verbose; int verbose;
int printsize; int printsize;
int printsize2;
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -91,7 +92,7 @@ main(int argc, char **argv)
setprogname(argv[0]); setprogname(argv[0]);
bfdname = NULL; bfdname = NULL;
while ((ch = getopt(argc, argv, "b:pv")) != -1) while ((ch = getopt(argc, argv, "b:Ppv")) != -1)
switch (ch) { switch (ch) {
case 'b': case 'b':
bfdname = optarg; bfdname = optarg;
@ -102,6 +103,9 @@ main(int argc, char **argv)
case 'p': case 'p':
printsize = 1; printsize = 1;
break; break;
case 'P':
printsize2 = 1;
break;
case '?': case '?':
default: default:
usage(); usage();
@ -158,6 +162,10 @@ main(int argc, char **argv)
printf("%d %d\n", symtabsize, symtab_space); printf("%d %d\n", symtabsize, symtab_space);
goto done; goto done;
} }
if (printsize2) {
printf("%d\n", symtabsize);
goto done;
}
if (symtabsize > symtab_space) if (symtabsize > symtab_space)
errx(1, "symbol table (%u bytes) too big for buffer (%u bytes)\n" errx(1, "symbol table (%u bytes) too big for buffer (%u bytes)\n"
@ -194,7 +202,7 @@ usage(void)
const char **list; const char **list;
fprintf(stderr, fprintf(stderr,
"usage: %s [-pv] [-b bfdname] kernel\n", "usage: %s [-Ppv] [-b bfdname] kernel\n",
getprogname()); getprogname());
fprintf(stderr, "supported targets:"); fprintf(stderr, "supported targets:");
for (list = bfd_target_list(); *list != NULL; list++) for (list = bfd_target_list(); *list != NULL; list++)