|
|
``User-defined mapfile'' is an example of a user-defined mapfile. The numbers on the left are included in the example for tutorial purposes. Only the information to the right of the numbers would actually appear in the mapfile.
User-defined mapfile
1 elephant : .bss : peanuts.o *popcorn.o; 2 monkey : $PROGBITS ?AX; 3 monkey : .bss; 4 monkey = LOAD V0x80000000 L0x4000; 5 monkey = LOAD; 6 donkey = ?RWX; 7 donkey : .bss; 8 donkey = ?RX A0x1000; 9 text = ?RWX V0x80008000;Four separate segments are manipulated in this example. The implicitly declared segment
elephant
(line 1) receives
all of the .bss
sections from the files peanuts.o and
popcorn.o.
Note that popcorn.o matches any
popcorn.o file that may have been entered on the
ld command line; the file need not be in
the current directory.
On the other hand,
if /var/tmp/peanuts.o were entered on the ld command line,
it would not match
peanuts.o because it is not preceded by a .
The implicitly declared segment monkey
(line 2) receives all
sections that are both $PROGBITS
and allocatable-executable
(?AX
), as well as all sections (not already in the segment
elephant
) with the name .bss
(line 3).
The .bss
sections entering the monkey
segment need not be
$PROGBITS
or allocatable-executable because the
section_type and
section_flags values were entered on a separate line from the
section_name value.
(An ``and'' relationship exists between attributes
on the same line as illustrated by
$PROGBITS
``and'' ?AX
on line 2.
An ``or'' relationship exists between attributes
for the same segment that span more than
one line as illustrated by $PROGBITS ?AX
on line 2 ``or'' .bss
on line 3.)
The monkey
segment is implicitly declared in line 2
with segment_type value LOAD
, segment_flags
value ?RWX
,
and default virtual_address, physical_address, length,
and alignment values specified per CPU type.
In line 4 the segment_type value of
monkey
is set
to LOAD
,
virtual_address value to 0x80000000
and
maximum length value to 0x4000
.
In line 5 the segment_type value of
monkey
is again set to LOAD
(since the segment_type attribute value does not change,
no warning is issued).
Line 6 implicitly declares the donkey
segment.
The entrance criteria is designed to route all
.bss
sections to this segment.
Actually, no sections fall into this segment
because the entrance criteria for monkey
in line 3
capture all of these sections.
In line 8, the segment_flags value is set to ?RX
and the alignment value is set to 0x1000
(since the segment_flags value changes, a warning is issued).
Line 9 changes the segment_flags value to ?RWX
and the
virtual_address value
of the text
segment to 0x80008000
(since the segment_flags value changes,
a warning is issued).
The example user-defined mapfile in ``User-defined mapfile'' is designed to cause warnings for illustration purposes. If you wanted to change the order of the directives to avoid warnings, the example would appear as follows:
Clean user-defined mapfile
1 elephant : .bss : peanuts.o *popcorn.o; 4 monkey = LOAD V0x80000000 L0x4000; 2 monkey : $PROGBITS ?AX; 3 monkey : .bss; 6 donkey = ?RX A0x1000; 5 donkey : .bss; 7 text = V0x80008000;This order eliminates all warnings.