|
|
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:
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.
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.
.data2
section in
``Simple map structure''
was placed in this manner.
$DYNAMIC $PROGBITS $SYMTAB $STRTAB $RELA $REL $HASH $NOTE $NOBITSThe
.bss
section in
``Simple map structure''
illustrates this point.
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.
For more information, see
``Section header''.
$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.