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