A segment declaration creates a new segment in the a.out
or changes the attribute values of an existing segment.
(An existing segment is one that you previously defined or one of the
three built-in segments described below.)
A segment declaration has the following
syntax:
segment_name= {segment_attribute_value}*;
For each segment_name, you can specify any number
of segment_attribute_values in any order, each
separated by a space.
(Only one attribute value is allowed for each segment attribute.)
The segment attributes and their valid values are as follows:
segment_type:
LOAD
NOTE
segment flags:
?[R][W][X]
virtual_address:
Vnumber
physical_address:
Pnumber
length:
Lnumber
alignment:
Anumber
There are three built-in segments with the following default attribute values:
text (LOAD, ?RX, virtual_address,
physical_address, length, and
alignment values set to defaults per CPU type)
data
(LOAD, ?RWX, virtual_address, physical_address,
length, and alignment values set to defaults per
CPU type)
note (NOTE)
ld behaves as if these segments had been declared before your
mapfile is read in.
See
``Mapfile option defaults''
for more information.
Note the following when entering segment declarations:
A number can be hexadecimal, decimal, or octal, following the same
rules as in the C language.
No space is allowed between the V, P, L, or A
and the number.
The segment_type value can be either LOAD or NOTE.
The segment_type value defaults to LOAD.
The segment_flags values are R for readable,
W for writable, and X for executable.
No spaces are allowed between the question mark and the individual flags
that make up the segment_flags value.
The segment_flags value for a LOAD segment defaults to ?RWX.
NOTE segments cannot be assigned any segment attribute value
other than a segment_type.
Implicitly declared segments default to segment_type value LOAD,
segment_flags value ?RWX, virtual_address,
physical_address, length, and alignment values
set to defaults per CPU type.
NOTE:ld
calculates the addresses and length of the current segment based on the
previous segment's attribute values.
Also, even though implicitly declared segments default to
``no length limit'', any machine memory limitations still apply.
LOAD segments can have an explicitly specified virtual_address
value and/or
physical_address value, as well as a maximum segment length
value.
If a segment has a segment_flags value of ? with nothing following,
the value defaults
to not readable, not writable and not executable.
The alignment value is used in calculating the virtual address of the
beginning of the segment.
This alignment only affects the segment for which it is specified;
other segments still have the default alignment unless their
alignments are also changed.
If any of the virtual_address, physical_address, or length
attribute values are not set,
ld calculates these values as it builds the a.out.
If an alignment value is not specified for a segment, it is set to
the built-in default.
(The default differs from one CPU to another and
may even differ between kernel versions.
You should check the appropriate
documentation for these numbers).
If both a virtual_address and an alignment value are specified for a
segment, the virtual_address value takes priority.
If a virtual_address value is specified for a segment, the alignment field
in the program header contains the default alignment value.
CAUTION:
If a virtual_address value is specified, the segment is placed at that
virtual address.
For the UNIX system kernel this creates a correct result.
For files that start via exec, this method creates an incorrect
a.out file
because the segments do not have correct offsets relative to their
page boundaries.