1987-03-09 19:15:41 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1994-06-24 11:31:16 +00:00
|
|
|
/* $Id$ */
|
1985-04-12 14:55:00 +00:00
|
|
|
|
2006-10-16 23:20:11 +00:00
|
|
|
#include <stdlib.h>
|
1985-04-12 14:55:00 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "out.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
asize -- determine object size
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
main(argc, argv)
|
|
|
|
char **argv;
|
|
|
|
{
|
|
|
|
struct outhead buf;
|
|
|
|
struct outsect sbuf;
|
1991-12-18 09:45:26 +00:00
|
|
|
unsigned short nrsect;
|
1985-04-12 14:55:00 +00:00
|
|
|
long sum;
|
|
|
|
int gorp;
|
|
|
|
|
|
|
|
if (--argc == 0) {
|
|
|
|
argc = 1;
|
|
|
|
argv[1] = "a.out";
|
|
|
|
}
|
|
|
|
gorp = argc;
|
|
|
|
|
|
|
|
while(argc--) {
|
1987-01-15 22:06:16 +00:00
|
|
|
if (! rd_open(*++argv)) {
|
1985-04-12 14:55:00 +00:00
|
|
|
fprintf(stderr, "asize: cannot open %s\n", *argv);
|
|
|
|
continue;
|
|
|
|
}
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_ohead(&buf);
|
1985-04-12 14:55:00 +00:00
|
|
|
if(BADMAGIC(buf)) {
|
|
|
|
fprintf(stderr, "asize: %s-- bad format\n", *argv);
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_close();
|
1985-04-12 14:55:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
nrsect = buf.oh_nsect;
|
|
|
|
if (nrsect == 0) {
|
|
|
|
fprintf(stderr, "asize: %s-- no sections\n", *argv);
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_close();
|
1985-04-12 14:55:00 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (gorp > 1)
|
|
|
|
printf("%s: ", *argv);
|
|
|
|
|
|
|
|
sum = 0;
|
|
|
|
while (nrsect-- > 0) {
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_sect(&sbuf, 1);
|
1985-04-12 14:55:00 +00:00
|
|
|
printf("%ld", sbuf.os_size);
|
|
|
|
sum += sbuf.os_size;
|
|
|
|
if (nrsect > 0)
|
|
|
|
putchar('+');
|
|
|
|
}
|
|
|
|
printf(" = %ld = 0x%lx\n", sum, sum);
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_close();
|
1985-04-12 14:55:00 +00:00
|
|
|
}
|
1987-03-09 13:04:58 +00:00
|
|
|
exit(0);
|
1985-04-12 14:55:00 +00:00
|
|
|
}
|
|
|
|
|
1987-01-15 22:06:16 +00:00
|
|
|
rd_fatal()
|
1985-04-12 14:55:00 +00:00
|
|
|
{
|
1987-01-15 22:06:16 +00:00
|
|
|
fprintf(stderr, "read error\n");
|
|
|
|
exit(2);
|
1985-04-12 14:55:00 +00:00
|
|
|
}
|