A mapping directive tells ld how to map input sections to segments. Basically, you name the segment that you are mapping to and indicate what the attributes of a section must be in order to map into the named segment. The set of section_attribute_values that a section must have to map into a specific segment is called the entrance criteria for that segment. In order to be placed in a specified segment of the a.out, a section must meet the entrance criteria for a segment exactly.
A mapping directive has the following syntax:
For a segment_name, you specify any number of section_attribute_values in any order, each separated by a space. (At most one section attribute value is allowed for each section attribute.) You can also specify that the section must come from a certain .o file(s) via the file_name substitutable. The section attributes and their valid values are as follows:
Wfor writable, or
Xfor executable. If an individual flag is preceded by an exclamation mark (
!), the linker checks to make sure that the flag is not set. No spaces are allowed between the question mark, exclamation point(s), and the individual flags that make up the section_flags value.
A file name may be of the form
(see next bullet item). Note that ld does not check the syntax of
file_name, ld simulates a basename(C) on the file name from the command line and uses that to match against the mapfile file_name. In other words, the file_name from the mapfile only needs to match the last part of the file name from the command line. (See ``Mapping example'' for more information.)
S1 : $PROGBITS; S1 : $NOBITS;Entering more than one mapping directive line for a segment is the only way to specify multiple values of a section attribute.
S1 : $PROGBITS; S2 : $PROGBITS;the
$PROGBITSsections are mapped to segment