Mapping Directives

A mapping directive instructs the link-editor how to map input sections to output segments. Basically, you name the segment that you are mapping to and indicate what the attributes of a section must be in order to map into the named segment. The set of section_attribute_values that a section must have to map into a specific segment is called the entrance criteria for that segment. In order to be placed in a specified segment of the output file, a section must meet the entrance criteria for a segment exactly.

A mapping directive has the following syntax.

        segment_name : {section_attribute_value}* [: {file_name}+];

For a segment_name, you specify any number of section_attribute_values in any order, each separated by a space. At most, one section attribute value is allowed for each section attribute. You can also specify that the section must come from a certain .o file through a file_name declaration. The section attributes and their valid values are shown in the following table.

Table B-2 Section Attributes

Section Attribute Value

section_name

Any valid section name

section_type

$PROGBITS

$SYMTAB

$STRTAB

$REL

$RELA

$NOTE

$NOBITS

section_flags

? [[!]A] [[!]W] [[!]X]

Note the following points when entering mapping directives.

  • You must choose at most one section_type from the section_types listed previously. The section_types listed previously are built-in types. For more information on section_types, see Section Headers.

  • The section_flags values are A for allocatable, W for writable, or X for executable. If an individual flag is preceded by an exclamation mark (!), the link-editor checks that the flag is not set. No spaces are allowed between the question mark, exclamation marks, and the individual flags that make up the section_flags value.

  • file_name can be any legal file name, of the form *filename, or of the form archive_name(component_name), for example, /lib/libc.a(printf.o). The link-editor does not check the syntax of file names.

  • If a file_name is of the form *filename, the link-editor determines the basename(1) of the file from the command line. This base name is used to match against the specified file name. In other words, the filename from the mapfile only needs to match the last part of the file name from the command line. See Mapping Example.

  • If you use the -l option during a link-edit, and the library after the -l option is in the current directory, you must precede the library with ./, or the entire path name, in the mapfile in order to create a match.

  • More than one directive line can appear for a particular output segment. For example, the following set of directives is legal.

            S1 : $PROGBITS;
            S1 : $NOBITS;

    Entering more than one mapping directive line for a segment is the only way to specify multiple values of a section attribute.

  • A section can match more than one entrance criteria. In this case, the first segment encountered in the mapfile with that entrance criteria is used. For example, if a mapfile reads as follows.

            S1 : $PROGBITS;
            S2 : $PROGBITS;

    The $PROGBITS sections are mapped to segment S1.