|
|
1.1 root 1: /*
2: * Copyright (c) 1988 Regents of the University of California.
3: * All rights reserved.
4: *
5: * Redistribution and use in source and binary forms are permitted
6: * provided that the above copyright notice and this paragraph are
7: * duplicated in all such forms and that any documentation,
8: * advertising materials, and other materials related to such
9: * distribution and use acknowledge that the software was developed
10: * by the University of California, Berkeley. The name of the
11: * University may not be used to endorse or promote products derived
12: * from this software without specific prior written permission.
13: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14: * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15: * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16: */
17:
18: #ifndef lint
19: char copyright[] =
20: "@(#) Copyright (c) 1988 Regents of the University of California.\n\
21: All rights reserved.\n";
22: #endif /* not lint */
23:
24: #ifndef lint
25: static char sccsid[] = "@(#)size.c 4.6 (Berkeley) 6/18/88";
26: #endif /* not lint */
27:
28: #include <sys/param.h>
29: #include <sys/file.h>
30: #include <a.out.h>
31: #include <stdio.h>
32:
33: main(argc, argv)
34: int argc;
35: char **argv;
36: {
37: struct exec head;
38: u_long total;
39: int exval, fd, first;
40:
41: if (!*argv[1])
42: *argv = "a.out";
43: else
44: ++argv;
45: for (first = 1, exval = 0; *argv; ++argv) {
46: if ((fd = open(*argv, O_RDONLY, 0)) < 0) {
47: fprintf(stderr, "size: ");
48: perror(*argv);
49: exval = 1;
50: continue;
51: }
52: if (read(fd, (char *)&head, sizeof(head)) != sizeof(head) ||
53: N_BADMAG(head)) {
54: fprintf(stderr, "size: %s: not in a.out format.\n",
55: *argv);
56: exval = 1;
57: continue;
58: }
59: (void)close(fd);
60: if (first) {
61: first = 0;
62: printf("text\tdata\tbss\tdec\thex\n");
63: }
64: total = head.a_text + head.a_data + head.a_bss;
65: printf("%lu\t%lu\t%lu\t%lu\t%lx", head.a_text, head.a_data,
66: head.a_bss, total, total);
67: if (argc > 2)
68: printf("\t%s", *argv);
69: printf("\n");
70: }
71: exit(exval);
72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.