SEGMENT_ORDER
Directive
The SEGMENT_ORDER
directive is used to specify a non-default
ordering for segments in the output object.
SEGMENT_ORDER
accepts a space separated list of segment
names.
SEGMENT_ORDER = segment_name....; SEGMENT_ORDER += segment_name....;
When the "=
" form of assignment is used, the
previous SEGMENT_ORDER
list is discarded, and replaced with the
new list. The "+=
" form of assignment concatenates
the new list to the end of the existing list.
By default, the link-editor orders segments as follows.
-
Loadable segments with explicit addresses set with the
VADDR
attribute of theLOAD_SEGMENT
directive, sorted by address. -
Segments ordered using the
SEGMENT_ORDER
directive, in the order specified. -
Loadable segments without explicit addresses, not found in the
SEGMENT_ORDER
list. -
Note segments without explicit addresses, not found in the
SEGMENT_ORDER
list. -
Null segments without explicit addresses, not found in the
SEGMENT_ORDER
list.
Note:
ELF has some implicit conventions that must be followed by a well formed object.-
The first loadable segment is expected to be read-only, allocable, and executable, and receives the ELF header and program header array. This is usually the predefined text segment.
-
The final loadable segment in an executable is expected to be writable, and the head of the dynamic heap is usually located immediately following within the same virtual memory mapping.
Mapfiles
can be used to create objects that violate these
requirements. This should be avoided, as the result of running such an object is
undefined.
Unless the HDR_NOALLOC
directive is specified, the link-editor
enforces the requirement that the first segment must be a loadable segment, and not
a note or null segment. HDR_NOALLOC
cannot be used for
userland objects, and is therefore of little practical use.
This feature is used when building operating system kernels.