-.\" $OpenBSD: size.1,v 1.3 1996/06/26 05:39:17 deraadt Exp $
+.\" $OpenBSD: size.1,v 1.4 1997/01/28 07:12:25 deraadt Exp $
.\" $NetBSD: size.1,v 1.6 1996/01/14 23:07:11 pk Exp $
.\"
.\" Copyright (c) 1990, 1993, 1994
.Nd display object file segment sizes (text, data and bss)
.Sh SYNOPSIS
.Nm size
+.Op Fl t
.Op Fl w
.Ar
.Sh DESCRIPTION
attempts to report on the file
.Pa a.out .
.Bl -tag -width flag
+.It Fl t
+At the end of the output print a total of the
+sizes of all the object files processed.
.It Fl w
Warn about non-object archive members.
Normally,
-/* $OpenBSD: size.c,v 1.5 1997/01/15 23:43:13 millert Exp $ */
+/* $OpenBSD: size.c,v 1.6 1997/01/28 07:12:27 deraadt Exp $ */
/* $NetBSD: size.c,v 1.7 1996/01/14 23:07:12 pk Exp $ */
/*
#if 0
static char sccsid[] = "@(#)size.c 8.2 (Berkeley) 12/9/93";
#endif
-static char rcsid[] = "$OpenBSD: size.c,v 1.5 1997/01/15 23:43:13 millert Exp $";
+static char rcsid[] = "$OpenBSD: size.c,v 1.6 1997/01/28 07:12:27 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
#include <stdio.h>
#include <err.h>
+unsigned long total_text, total_data, total_bss, total_total;
int ignore_bad_archive_entries = 1;
+int print_totals = 0;
int process_file __P((int, char *));
int show_archive __P((int, char *, FILE *));
{
int ch, eval;
- while ((ch = getopt(argc, argv, "w")) != -1)
+ while ((ch = getopt(argc, argv, "wt")) != -1)
switch(ch) {
case 'w':
ignore_bad_archive_entries = 0;
break;
+ case 't':
+ print_totals = 1;
+ break;
case '?':
default:
usage();
} while (*++argv);
else
eval |= process_file(1, "a.out");
+
+ if (print_totals)
+ (void)printf("\n%lu\t%lu\t%lu\t%lu\t%lx\tTOTAL\n",
+ total_text, total_data, total_bss,
+ total_total, total_total);
exit(eval);
}
FILE *fp;
int retval;
char magic[SARMAG];
-
+
if (!(fp = fopen(fname, "r"))) {
warnx("cannot read %s", fname);
return(1);
head.a_bss, total, total);
if (count > 1)
(void)printf("\t%s", name);
+
+ total_text += head.a_text;
+ total_data += head.a_data;
+ total_bss += head.a_bss;
+ total_total += total;
+
(void)printf("\n");
return (0);
}