1*52132Smckusick /*
2*52132Smckusick * Copyright (c) 1992 Regents of the University of California.
3*52132Smckusick * All rights reserved.
4*52132Smckusick *
5*52132Smckusick * This code is derived from software contributed to Berkeley by
6*52132Smckusick * Ralph Campbell.
7*52132Smckusick *
8*52132Smckusick * %sccs.include.redist.c%
9*52132Smckusick *
10*52132Smckusick * @(#)coff.c 7.1 (Berkeley) 01/07/92
11*52132Smckusick */
12*52132Smckusick
13*52132Smckusick #define COFF
14*52132Smckusick #include <sys/exec.h>
15*52132Smckusick
16*52132Smckusick /*
17*52132Smckusick * Print header info for coff files.
18*52132Smckusick */
19*52132Smckusick void
main(argc,argv)20*52132Smckusick main(argc, argv)
21*52132Smckusick int argc;
22*52132Smckusick char **argv;
23*52132Smckusick {
24*52132Smckusick register struct devices *dp;
25*52132Smckusick register int fd, i, n;
26*52132Smckusick char *fname;
27*52132Smckusick struct exec aout;
28*52132Smckusick
29*52132Smckusick if (argc < 2) {
30*52132Smckusick printf("usage: %s <file>\n");
31*52132Smckusick goto err;
32*52132Smckusick }
33*52132Smckusick if ((fd = open(fname = argv[1], 0)) < 0)
34*52132Smckusick goto err;
35*52132Smckusick
36*52132Smckusick /* read the COFF header */
37*52132Smckusick i = read(fd, (char *)&aout, sizeof(aout));
38*52132Smckusick if (i != sizeof(aout)) {
39*52132Smckusick printf("No a.out header\n");
40*52132Smckusick goto cerr;
41*52132Smckusick }
42*52132Smckusick printf("HDR: magic 0x%x(0%o) nsec %d nsym %d optheader %d textoff %x\n",
43*52132Smckusick aout.ex_fhdr.magic,
44*52132Smckusick aout.ex_fhdr.magic,
45*52132Smckusick aout.ex_fhdr.numSections,
46*52132Smckusick aout.ex_fhdr.numSyms,
47*52132Smckusick aout.ex_fhdr.optHeader,
48*52132Smckusick N_TXTOFF(aout));
49*52132Smckusick printf("A.out: magic 0x%x(0%o) ver %d entry %x gprM %x gpV %x\n",
50*52132Smckusick aout.ex_aout.magic,
51*52132Smckusick aout.ex_aout.magic,
52*52132Smckusick aout.ex_aout.verStamp,
53*52132Smckusick aout.ex_aout.entry,
54*52132Smckusick aout.ex_aout.gprMask,
55*52132Smckusick aout.ex_aout.gpValue);
56*52132Smckusick printf("\tstart %x,%x,%x size %d+%d+%d\n",
57*52132Smckusick aout.ex_aout.codeStart,
58*52132Smckusick aout.ex_aout.heapStart,
59*52132Smckusick aout.ex_aout.bssStart,
60*52132Smckusick aout.ex_aout.codeSize,
61*52132Smckusick aout.ex_aout.heapSize,
62*52132Smckusick aout.ex_aout.bssSize);
63*52132Smckusick
64*52132Smckusick cerr:
65*52132Smckusick close(fd);
66*52132Smckusick err:
67*52132Smckusick exit(0);
68*52132Smckusick }
69