coff.h" -- Header File" "
Format for COFF objects
#include <coff.h>
coff.h describes the Common Object File
Format (COFF), which is the object format used by COHERENT
386.
What Is COFF?
In brief, COFF is the UNIX System V standard for file
formats. It defines the formats for relocatable object
modules, for executable files, and for archives.
A COFF file is built around three sections, or _s_e_g_m_e_n_t_s:
- tteexxtt
- This holds executable machine code. It is write
protected -- the operating system is forbidden to overwrite
it. (This is why operating systems that use COFF or similar
formats are said to run in ``protected mode.'')
- ddaattaa
- This holds initialized data, that is, the data that the
program finds when it begins execution. The program can
read and write into this segment.
- bbssss
- This segment holds unitialized data. It is simply a
mass of space that is initialized to zeroes. It is
contiguous with the ddaattaa segment. The term bbssss from the old
IBM mainframe days, and stands for ``block started by
symbol''.
Not all segments have to be included in every COFF file.
Further, some implementations of COFF define their own
segments that manipulate special features of the operating
system or hardware.
The following describes the structure of a COFF file. The
areas within the file are described in the order in which
they appear.
- 11.. _f_i_l_e _h_e_a_d_e_r
- This holds information set when the file was created,
such as the date and time it was created, the number of
segments in the file, a pointer to the symbol table, and
status flags.
- 22.. _o_p_t_i_o_n_a_l _h_e_a_d_e_r
- This gives information set at run-time, such as the
address of the program entry point, and the size of the code
and data segments.
- 33.. _s_e_g_m_e_n_t _h_e_a_d_e_r_s
- The next area holds a header for each segment in the
file. Each header describes its segment's characteristics
and contains pointers to the segment's contents, relocation
information, line-number information, and other useful
addresses.
- 44.. _s_e_g_m_e_n_t _c_o_n_t_e_n_t_s
- The next area holds the contents of the segments used
in this file.
- 55.. _r_e_l_o_c_a_t_i_o_n _i_n_f_o_r_m_a_t_i_o_n
- The fifth area gives relocation information, one set of
information for each segment in the file. The linker
ld uses this information to generate the
executable file at link time.
- 66.. _l_i_n_e_-_n_u_m_b_e_r _i_n_f_o_r_m_a_t_i_o_n
- This area holds debug information, one set of
information for each segment. This area is optional.
- 77.. _s_y_m_b_o_l _t_a_b_l_e
- This area holds information used by both the linker and
the debugger.
- 88.. _s_t_r_i_n_g _t_a_b_l_e
- This table holds very long names of variables.
Most of this information is irrelevant to the average user,
or even the average developer of software. To the average
user, COFF is ``a machine that would go of itself''; you can
run or compile programs without worrying what the linker
puts where, or why. These details, however, can be very
important if you are writing tools that manipulate the
internals of files, such as archivers or debuggers. If you
need detailed information on COFF and how to manipulate it,
see _U_n_d_e_r_s_t_a_n_d_i_n_g _a_n_d _U_s_i_n_g _C_O_F_F (citation appears below).
For more information on how the COFF format affects
COHERENT's language tools, see the Lexicon articles for
ar, as, cc,
db, and ld.
See Also
- ar,
- as,
- cc,
- cdmp,
- coffnlist(),
- file formats,
- header files,
- ld
Gircys, G.R.: _U_n_d_e_r_s_t_a_n_d_i_n_g _a_n_d _U_s_i_n_g _C_O_F_F. Sebastopol,
Calif., O'Reilly & Associates, Inc., 1988.