1 /* size - tell size of an object file Author: Andy Tanenbaum */
10 int heading
; /* set when heading printed */
13 int main(int argc
, char **argv
);
14 void size(char *name
);
26 for (i
= 1; i
< argc
; i
++) size(argv
[i
]);
39 if ((fd
= open(name
, O_RDONLY
)) < 0) {
40 fprintf(stderr
, "size: can't open %s\n", name
);
44 if (read(fd
, (char *)&exec
, sizeof(struct exec
)) != sizeof(struct exec
)) {
45 fprintf(stderr
, "size: %s: header too short\n", name
);
51 fprintf(stderr
, "size: %s not an object file\n", name
);
56 separate
= (exec
.a_flags
& A_SEP
? 1 : 0);
57 dynam
= exec
.a_total
- exec
.a_text
- exec
.a_data
- exec
.a_bss
;
58 if (separate
) dynam
+= exec
.a_text
;
59 allmem
= (separate
? exec
.a_total
+ exec
.a_text
: exec
.a_total
);
60 if (heading
++ == 0) printf(" text data bss stack memory\n");
61 printf("%7ld %7ld %7ld %8ld %8ld %s\n",
62 exec
.a_text
, exec
.a_data
, exec
.a_bss
, dynam
, allmem
, name
);