IS_ORDER Attribute (LOAD,
NOTE, NULL)
The link-editor normally places output sections into the segment in the order
they are encountered. Similarly, the input sections that make up the output
section are placed in the order they are encountered. The
IS_ORDER attribute can be used to alter this default
placement of input sections. IS_ORDER specifies a space
separated list of entrance criterion names
(assign_name). Sections matched by one of these
entrance criteria are placed at the head of the output section, sorted in the
order given by IS_ORDER. Sections matched by entrance
criteria not found in the IS_ORDER list are placed following
the sorted sections, in the order they are encountered.
When the "=" form of assignment is used, the
previous value of IS_ORDER for the given segment is
discarded, and replaced with the new list. The
"+=" form of IS_ORDER
concatenates the new list to the end of the existing list.
The IS_ORDER attribute is of particular interest when used
in conjunction with the -xF option to the compilers. When a file
is compiled with the -xF option, each function in that file is
placed in a separate section with the same attributes as the
text section. These sections are called
.text%function_name.
For example, a file containing three functions, main(),
foo() and bar(), when compiled with
the -xF option, yields a relocatable object file with text for
the three functions being placed in sections called
.text%main, .text%foo, and
.text%bar. When the link-editor places these sections
into the output, the % and anything following the
% are removed. Hence, all three of these functions will
be placed in the .text output section. The
IS_ORDER attribute can be used to force them to be placed
in a specific order within the .text output section relative
to each other.
Consider the following user-defined mapfile.
$mapfile_version 2
LOAD_SEGMENT text {
ASSIGN_SECTION text_bar { IS_NAME = .text%bar };
ASSIGN_SECTION text_main { IS_NAME = .text%main };
ASSIGN_SECTION text_foo { IS_NAME = .text%foo };
IS_ORDER = text_foo text_bar text_main;
};No matter the order in which these three functions are found in the source
code, or encountered by the link-editor, their order in the output object text
segment will be foo(), bar(), and
main().