|
|
This chapter describes the link editor, ld(CP). It is organized as follows:
ld creates a program by combining object files, performing relocations, and resolving external symbols. The input files are normally relocatable object files, or library files containing relocatable object files which have been created by cc(CP) or by previous invocations of ld. The output file created by ld may be a relocatable object file or an absolute (executable) object file.
Two object file formats, COFF (Common Object File Format) and ELF (Executable and Linking Format), are supported by this release of the link editor. The command language supported by the COFF version of ld allows the user a greater degree of control over object files and their memory locations. A similar facility, the mapfile option, is provided for the ELF linker. See ``Mapfile option'' for details on how to change the default mapping provided by the ELF linker.
If a particular file format is not explicitly specified through the -b option, ld scans all the user specified object files and user provided libraries (if any) that are to be linked. It determines whether an object file is in COFF or ELF format and executes the appropriate binaries in each case. See the ld(CP) man page for more information.
The discussion that follows relies heavily on the reader's knowledge of the COFF file format. In particular, familiarity with the concept of a section is essential to understanding this material. See ``Common Object File Format (COFF)'' for a general discussion of the file format.