www.delorie.com/djgpp/doc/coff/opthdr.html   search  
COFF: Optional Header

The optional header immediately follows the file header in the COFF file. The size of this header is stored in the f_opthdr field of the file header. You must read that many bytes from the file regardless of how big you expect the optional header to be.

Two optional headers are defined for DJGPP objects:

Struct
Size
Purpose
AOUTHDR 28 Added to executables to provide the entry point of the program
GNU_AOUT 32 Unknown

typedef struct {
  unsigned short magic;          /* type of file                         */
  unsigned short vstamp;         /* version stamp                        */
  unsigned long  tsize;          /* text size in bytes, padded to FW bdry*/
  unsigned long  dsize;          /* initialized data    "  "             */
  unsigned long  bsize;          /* uninitialized data  "  "             */
  unsigned long  entry;          /* entry pt.                            */
  unsigned long  text_start;     /* base of text used for this file      */
  unsigned long  data_start;     /* base of data used for this file      */
} AOUTHDR;

The only two fields you should rely on are described below.

magic - magic number
Always the value ZMAGIC (0x010b).

entry - entry point
This should be used to provide the initial value of %eip when the program is initialized.

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 1996   by DJ Delorie     Updated Oct 1996