Common Object File Format (COFF)

File header

The file header contains the 20 bytes of information shown in ``File header contents''. The last 2 bytes are flags that are used by ld and object file utilities.

File header contents

Bytes Declaration Name Description
0-1 unsigned short f_magic Magic number
2-3 unsigned short f_nscns Number of sections
4-7 long int f_timdat Time and date stamp indicating when the file was created, expressed as the number of elapsed seconds since 00:00:00 GMT, January 1, 1970
8-11 long int f_symptr File pointer containing the starting address of the symbol table
12-15 long int f_nsyms Number of entries in the symbol table
16-17 unsigned short f_opthdr Number of bytes in the optional header
18-19 unsigned short f_flags Flags (see ``File header flags'')

Magic numbers

The magic number specifies the target machine on which the object file is executable.


The last 2 bytes of the file header are flags that describe the type of the object file. Currently defined flags are found in the header file filehdr.h and are shown in ``File header flags''.

File header flags

Mnemonic Flag Meaning
F_RELFLG 00001 Relocation information stripped from the file
F_EXEC 00002 File is executable (i.e., no unresolved external references)
F_LNNO 00004 Line numbers stripped from the file
F_LSYMS 00010 Local symbols stripped from the file
F_AR16WR 0000200 16-bit byte reversed word
F_AR32WR 0000400 32-bit byte reversed word

File header declaration

The C structure declaration for the file header is shown below. This declaration may be found in the header file filehdr.h.

   struct filehdr
     unsigned short   f_magic;  /* magic number */
     unsigned short   f_nscns;  /* number of section */

long f_timdat; /* time and date stamp */

long f_symptr; /* file ptr to symbol table */

long f_nsyms; /* number entries in the symbol table */

unsigned short f_opthdr; /* size of optional header */

unsigned short f_flags; /* flags */ };

#define FILHDR struct filehdr #define FILHSZ sizeof(FILHDR)

Next topic: Optional header information
Previous topic: Target machine

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003