www.delorie.com/djgpp/doc/coff/filhdr.html   search  
COFF: File Header

typedef struct {
  unsigned short f_magic;         /* magic number             */
  unsigned short f_nscns;         /* number of sections       */
  unsigned long  f_timdat;        /* time & date stamp        */
  unsigned long  f_symptr;        /* file pointer to symtab   */
  unsigned long  f_nsyms;         /* number of symtab entries */
  unsigned short f_opthdr;        /* sizeof(optional hdr)     */
  unsigned short f_flags;         /* flags                    */

This structure always exists at the beginning of the COFF object. When reading this header, you should read FILHSZ bytes, and not rely on sizeof(FILHDR) to give the correct size.

f_magic - magic number
This is a constant value for all COFF files, and is used to detect the fact that the file is COFF. The value of this field must be I386MAGIC (0x14c) and is stored in little-endian format, so the first two bytes of any DJGPP COFF file are 0x4c and 0x01.

f_nscns - number of sections
The number of sections (and thus section headers) contained within this file.

f_timdat - file time & date stamp
The time that this coff file was created. The value has the same meaning as the time_t type.

f_symptr - symbol table pointer
Contains the file offset of the symbol table.

f_nsyms - number of symbols in the symbol table
The number of symbols in the symbol table.

f_opthdr - optional header size
The number of extra bytes that follow the file header, before the section headers begin. Often used to store the optional a.out header. Regardless of what optional header you expect, you should read (or skip) exactly the number of bytes given in this field before reading the section headers.

f_flags - flag bits
These flags provide additional information about the state of this coff object. The flags are as follows:

0x0001 F_RELFLG If set, there is no relocation information in this file. This is usually clear for objects and set for executables.
0x0002 F_EXEC If set, all unresolved symbols have been resolved and the file may be considered executable.
0x0004 F_LNNO If set, all line number information has been removed from the file (or was never added in the first place).
0x0008 F_LSYMS If set, all the local symbols have been removed from the file (or were never added in the first place).
0x0100 F_AR32WR Indicates that the file is 32-bit little endian

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