Generating the Output File
After input file processing and symbol resolution has completed with no fatal errors, the link-editor generates the output file. The link-editor first generates the additional sections necessary to complete the output file. These sections include the symbol tables, which contain local symbol definitions together with resolved global symbol and weak symbol information, from all the input files.
Also included are any output relocation and dynamic information sections required by the runtime linker. After all the output section information has been established, the total output file size is calculated. The output file image is then created accordingly.
When creating a dynamic object, two symbol tables are usually generated. The .dynsym
table and its associated string table .dynstr
contain register, global, weak, and section symbols. These sections become part of the text
segment that is mapped as part of the process image at runtime. See
mmapobj
(2). This mapping enables the runtime linker to read these sections to perform any necessary relocations.
The .symtab
table, and its associated string
table .strtab
contain all the symbols collected from the
input file processing. These sections are not mapped as part of the process
image. These sections can be stripped from the image by using the
link-editor's -z strip-class
option, or after the
link-edit by using
strip
(1).
During the generation of the symbol tables, reserved symbols are created. These symbols have special meaning to the linking process. These symbols should not be defined in your code.
-
_etext
-
The first location after all read-only information, typically referred to as the text segment.
-
_edata
-
The first location after initialized data.
-
_end
-
The first location after all data.
-
_DYNAMIC
-
The address of the
.dynamic
information section. -
_END_
-
The same as
_end
. The symbol has local scope and, together with the_START_
symbol, provides a simple means of establishing an object's address range. -
_GLOBAL_OFFSET_TABLE_
-
The position-independent reference to a link-editor supplied table of addresses, the
.got
section. This table is constructed from position-independent data references that occur in objects that have been compiled with the-K pic
option. See Position-Independent Code. -
_PROCEDURE_LINKAGE_TABLE_
-
The position-independent reference to a link-editor supplied table of addresses, the
.plt
section. This table is constructed from position-independent function references that occur in objects that have been compiled with the-K pic
option. See Position-Independent Code. -
_START_
-
The first location within the text segment. The symbol has local scope and, together with the
_END_
symbol, provides a simple means of establishing an object's address range.
When generating an executable, the link-editor looks for
additional symbols to define the executable's entry point. If a symbol was
specified using the link-editor's -e
option, that symbol is
used. Otherwise the link-editor looks for the reserved symbol names
_start
, and then main
.