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:
textsegment it must have a section_type value of
$PROGBITSand have a section_flags value of
?A!W. It need not have the name
.textsince no name is specified in the Entrance Criteria. The section may be either
!X(in the section_flags value) since nothing was specified for the execute bit in the Entrance Criteria.
For instance, a section with a section_name value of
a section_type value of
$PROGBITS, and a section_flags
?AWX falls into the
second Entrance Criteria box in
``Simple map structure'',
placing it in the
The section matches the second
Output Section Descriptor box exactly
and is added to the end of the list associated with that box.
.data1 sections from
fido.o, rover.o, and sam.o
illustrate this point.
.data2section in ``Simple map structure'' was placed in this manner.
$DYNAMIC $PROGBITS $SYMTAB $STRTAB $RELA $REL $HASH $NOTE $NOBITSThe
.bsssection in ``Simple map structure'' illustrates this point.
SHT_HIUSER) it is treated as a
$PROGBITSsection. 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. For more information, see ``Section header''.
$RELAare used internally by ld. Directives that refer to these section_types can only map output sections produced by ld to segments.