Internal map structure
One of the most important data structures in the ELF-based
ld
is the
map structure.
A default map structure,
corresponding to the model default mapfile mentioned above,
is used by
ld
when the command is executed.
Then, if the mapfile option is used,
ld
parses the mapfile
to augment and/or override certain values in the default map structure.
A typical (although somewhat simplified) map structure is illustrated in
``Simple Map Structure''.
The ``Entrance Criteria'' boxes correspond to the information in
the default mapping directives and the
``Segment Attribute Descriptors'' boxes
correspond to the information in the default segment declarations.
The ``Output Section Descriptors'' boxes give the detailed attributes of the
sections that fall under each segment.
The sections themselves are in circles.
Simple Map Structure
ld
performs the following steps when mapping sections to segments:
-
When a section is read in,
ld
checks the list of Entrance Criteria looking for a match.
(All specified
criteria must match):
-
In
``Simple Map Structure'',
for a section to
fall into the text segment it must have a section_type
value of $PROGBITS and have a section_flags value of ?A!W.
It need not have
the name .text since no name is specified in the Entrance Criteria.
The section may be either X or !X (in the section_flags value)
since nothing was specified for the execute bit in the Entrance Criteria.
-
If no Entrance Criteria match is found, the section is placed at the end of
the a.out file after all other segments.
No program header entry is created for this information.
See
``Object files''
for information on program headers.
-
When the section falls into a segment,
ld
checks the list of existing Output Section Descriptors in that
segment as follows:
-
If the section attribute values match those of an existing
Output Section Descriptor exactly, the section is placed at the end
of the list of sections associated with that Output Section Descriptor.
For instance, a section with a section_name value of .data1,
a section_type value of $PROGBITS, and a section_flags
value of ?AWX falls into the
second Entrance Criteria box in
``Simple Map Structure'',
placing it in the
data segment.
The section matches the second
Output Section Descriptor box exactly
(.data1, $PROGBITS, ?AWX)
and is added to the end of the list associated with that box.
The .data1 sections from
fido.o,
rover.o,
and
sam.o
illustrate this point.
-
If no matching Output Section Descriptor is found, but other Output Section
Descriptors of
the same section_type exist, a new Output Section Descriptor
is created with
the same attribute values as the section and that section is
associated with the new Output Section Descriptor.
The Output Section Descriptor (and the section)
are placed
after the last Output Section Descriptor of the same section_type.
The .data2 section in
``Simple Map Structure''
was placed in this manner.
-
If no other Output Section Descriptors
of the indicated section_type exist, a new Output Section Descriptor
is created and the section is placed so as to
maintain the following section_type order:
$DYNAMIC
$PROGBITS
$SYMTAB
$STRTAB
$RELA
$REL
$HASH
$NOTE
$NOBITS
The .bss section in
``Simple Map Structure''
illustrates this point.
NOTE:
If the input section has a user-defined section_type value (that is, between
SHT_LOUSER and SHT_HIUSER)
it is treated as a $PROGBITS section.
No method exists for naming this section_type value in the
mapfile, but these sections can be redirected using the
other attribute value specifications (section_flags,
section_name) in the entrance criteria.
See
``Sections''.
-
If a segment contains no sections after all of the command line
object files and libraries have been read in, no program header entry
is produced for that segment.
NOTE:
Note that input sections of type $SYMTAB, $STRTAB,
$REL, and $RELA are used internally by ld.
Directives that refer to these section_types can only map
output sections produced by ld to segments.
Next topic:
Error messages
Previous topic:
Default Mapfile
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005