HP UX Software Transition Kit (STK) Internal Map Structure, Mapping Input Sections to Segments

Models: UX Software Transition Kit (STK)

1 228
Download 228 pages 54.84 Kb
Page 198
Image 198

At most one section_type can be specified in a mapping directive.

If a section flag is preceded by an exclamation mark (!), it indicates that the flag must not be set to meet the entrance criteria. If you do not specify section_flags, the flag can have any value to meet the entrance criteria.

S1 : ?X;

The linker maps all executable sections onto segment S1.

The section_name attribute indicates that the linker must map the input sections with the specified name onto the named segment.

text : .rodata;

An input section can satisfy more than one entrance criterion.

S1 : $PROGBITS;

S2 : $PROGBITS;

In this case, all sections with section type $PROGBITS are mapped onto segment S1 as the first rule takes precedence.

An AND relationship exists between attributes specified on the same line. An OR relationship exists between attributes specified for the same segment that span more than one line.

Example 1: All sections with section_type $PROGBITS and section_flags AX (allocatable

and executable) are mapped onto the text segment. text : $PROGBITS ?AX;

Example 2: text : $PROGBITS ?AX; text : .rodata; In this case, the linker maps

a section onto the text segment if: Its section_type is $PROGBITS and section_flags is AX. (or) Its section_name is .rodata.

Internal Map Structure

The linker use a default map structure corresponding to the default mapfile. When you use the mapfile option with the ld command, the linker appends the default mapfile to the end of your user-specified mapfile. (You can override the default mapfile by using the +nodefaultmap option.)

Placement of Segments in an Executable

As it processes each segment declaration in the mapfile, the linker compares it with the existing list of segment declarations as follows:

If the segment does not exist already, but another with the same segment_type exists, the linker adds the segment after all of the existing segments with the same segment_type.

If no segment with the same segment_type exists, the linker adds the new segment to the list to maintain the following order based on segment_type:

LOAD

HP_TLS

NOTE

NONSEGMENT

If segments of same type already exists, the linker adds the new segment after the last segment with the same type.

Mapping Input Sections to Segments

As each section mapping directive in a mapfile is read in, the linker creates a new entrance criteria and appends it to the existing list of entrance criteria. It applies the entrance criteria in the order

198 Using Mapfiles

Page 198
Image 198
HP UX Software Transition Kit (STK) manual Internal Map Structure, Placement of Segments in an Executable