Go to main content

Oracle® Solaris 11.3 Linkers and Libraries Guide

Exit Print View

Updated: March 2018
Chapter 2

Link Editor

The link-editing process creates an output file from one or more input files. Output file creation is directed by the options that are supplied to the link-editor and the input sections provided by the input files.

All files are represented in the executable and linking format (ELF). For a complete description of the ELF format see Object File Format. For this introduction, two ELF structures are introduced, sections and segments.

Sections are the smallest indivisible units that can be processed within an ELF file. Segments are a collection of sections that represent the smallest individual units that can be mapped to a memory image by exec(2) or by the runtime linker ld.so.1(1).

Although many types of ELF section exist, sections fall into two categories with respect to the link-editing phase.

  • Sections that contain program data, whose interpretation is meaningful only to the application, such as the program instructions .text and the associated data .data and .bss.

  • Sections that contain link-editing information, such as the symbol table information found from .symtab and .strtab, and relocation information such as .rela.text.

Basically, the link-editor concatenates the program data sections into the output file. The link-editing information sections are interpreted by the link-editor to modify other sections. The information sections are also used to generate new output information sections used in later processing of the output file.

The following simple breakdown of link-editor functionality introduces the topics that are covered in this chapter.

  • The verification and consistency checking of all options provided.

  • The concatenation of sections of the same characteristics from the input relocatable objects to form new sections within the output file. The concatenated sections can in turn be associated to output segments.

  • The processing of symbol table information from both relocatable objects and shared objects to verify and unite references with definitions. The generation of a new symbol table, or tables, within the output file.

  • The processing of relocation information from the input relocatable objects, and the application of this information to sections that compose the output file. In addition, output relocation sections might be generated for use by the runtime linker.

  • The generation of program headers that describe all the segments that are created.

  • The generation of dynamic linking information sections if necessary, which provide information such as shared object dependencies and symbol bindings to the runtime linker.

The process of concatenating like sections and associating sections to segments is carried out using default information within the link-editor. The default section and segment handling provided by the link-editor is usually sufficient for most link-edits. However, these defaults can be manipulated using the –M option with an associated mapfile. See System V Release 4 (Version 1) Mapfiles.