5 * Print simple check sum for text and data section.
12 register int fd
, i
, n
;
18 printf("usage: sum <file>\n");
21 if ((fd
= open(fname
= argv
[1], 0)) < 0)
24 /* read the COFF header */
25 i
= read(fd
, (char *)&ex
, sizeof(ex
));
26 if (i
!= sizeof(ex
) || COFF_BADMAG(ex
)) {
27 printf("No COFF header\n");
30 if (lseek(fd
, COFF_TEXTOFF(ex
), 0)) {
35 for (n
= ex
.aouthdr
.tsize
; n
> 0; n
-= sizeof(int)) {
36 if (read(fd
, &word
, sizeof(word
)) != sizeof(word
)) {
43 for (n
= ex
.aouthdr
.dsize
; n
> 0; n
-= sizeof(int)) {
44 if (read(fd
, &word
, sizeof(word
)) != sizeof(word
)) {
50 printf("tsum %d dsum %d\n", tsum
, dsum
);