Mapfile
Directives for Predefined Segments and Entrance
Criteria
The link-editor provides a predefined set of output segment descriptors and
entrance criteria, as described in Predefined Segments. The link-editor already knows about these sections, so
mapfile
directives are not required to create them. The
mapfile
directives that could be used to produce them are shown
for illustrative purposes, and as an example of a relatively complex
mapfile
specification. Mapfile
segment
directives can be used to modify or augment these built in definitions.
Normally, section to segment assignments are done within a single segment
directive. However, the predefined sections have more complex requirements,
requiring their entrance criteria to be processed in a different order than the
segments are laid out in memory. Two passes are used to achieve this, the first to
define all the segments in the desired order, and the second to establish entrance
criteria in an order that will achieve the desired results. It is rare for a user
mapfile
to require this strategy.
# Predefined segments and entrance criteria for the Oracle Solaris # link-editor $mapfile_version 2 # The lrodata and ldata segments only apply to x86-64 objects. # Establish amd64 as a convenient token for conditional input $if _ELF64 && _x86 $add amd64 $endif # Pass 1: Define the segments and their attributes, but # defer the entrance criteria details to the 2nd pass. LOAD_SEGMENT text { FLAGS = READ EXECUTE; }; LOAD_SEGMENT data { FLAGS = READ WRITE EXECUTE; }; LOAD_SEGMENT bss { DISABLE; FLAGS=DATA; }; $if amd64 LOAD_SEGMENT lrodata { FLAGS = READ }; LOAD_SEGMENT ldata { FLAGS = READ WRITE; }; $endif NOTE_SEGMENT note; NULL_SEGMENT extra; # Pass 2: Define ASSIGN_SECTION attributes for the defined segments, # in the order the link-editor should evaluate them. # All SHT_NOTE sections go to the note segment NOTE_SEGMENT note { ASSIGN_SECTION { TYPE = NOTE; }; }; $if amd64 # Medium/large model x86-64 readonly sections to lrodata LOAD_SEGMENT lrodata { ASSIGN_SECTION { FLAGS = ALLOC AMD64_LARGE; }; }; $endif # text receives all readonly allocable sections LOAD_SEGMENT text { ASSIGN_SECTION { FLAGS = ALLOC !WRITE; }; }; # If bss is enabled, it takes the writable NOBITS sections # that would otherwise end up in ldata or data. LOAD_SEGMENT bss { DISABLE; ASSIGN_SECTION { FLAGS = ALLOC WRITE; TYPE = NOBITS; }; }; $if amd64 # Medium/large model x86-64 writable sections to ldata LOAD_SEGMENT ldata { ASSIGN_SECTION { FLAGS = ALLOC WRITE AMD64_LARGE; }; ASSIGN_SECTION { TYPE = NOBITS; FLAGS = AMD64_LARGE }; }; $endif # Any writable allocable sections not taken by a preceding # assignment go to data LOAD_SEGMENT data { ASSIGN_SECTION { FLAGS = ALLOC WRITE; }; }; # Any section that makes it to this point ends up at the # end of the object file in the extra segment. This accounts # for the bulk of non-allocable sections. NULL_SEGMENT extra { ASSIGN_SECTION; };