ASSIGN_SECTION Attribute (LOAD,
NOTE, NULL)
ASSIGN_SECTION specifies a combination of section
attributes, such as section name, type, and flags, that collectively qualify a
section for assignment to a given segment. Each such set of attributes is called
an entrance criterion. A section matches when the section
attributes match those of an entrance criterion exactly. An
ASSIGN_SECTION that does not specify any attributes
matches any section that criterion is compared to.
Multiple ASSIGN_SECTION attributes are allowed for a given
segment. Each ASSIGN_SECTION attribute is independent of the
others. A section will be assigned to a segment if the section matches any one
of the ASSIGN_SECTION definitions associated with that
segment. The link-editor will not assign sections to a segment unless the
segment has at least one ASSIGN_SECTION attribute.
The link-editor uses an internal list of entrance criteria to assign sections
to segments. Each ASSIGN_SECTION declaration encountered in
the mapfile is placed on this list, in the order
encountered. The entrance criteria for the built-in segments discussed in Predefined Segments are placed on this list
immediately following the final mapfile defined
entry.
The entrance criterion can be given an optional name
(assign_name). This name can be used in
conjunction with the IS_ORDER attribute to specify the order
in which input sections are placed in the output section.
To place an input section, the link-editor starts at the head of the entrance criteria list, and compares the attributes of the section to each entrance criterion in turn. The section is assigned to the segment associated with the first entrance criterion that matches the section attributes exactly. If there is no match, the section is placed at the end of the file, as is generally the case for all non-allocable sections.
ASSIGN_SECTION accepts the following.
-
FILE_BASENAME,FILE_OBJNAME,FILE_PATH -
These attributes allow the selection of sections based on the path (
FILE_PATH), basename (FILE_BASENAME), or object name (FILE_OBJNAME) of the file they come from. The path or name can be specified as a string literal, or as aMATCHexpression. See MATCH and MATCHREF Expressions.File paths are specified using the standard UNIX slash delimited convention. The final path segment is the basename of the path, also known simply as the filename. In the case of an archive, the basename can be augmented with the name of the archive member, using the form
archive_name(component_name). For example,/lib/libfoo.a(bar.o)specifies the objectbar.o, found in an archive named/lib/libfoo.a.FILE_BASENAMEandFILE_OBJNAMEare equivalent when applied to a non-archive, and compare the given name to the basename of the file. When applied to an archive,FILE_BASENAMEexamines the basename of the archive name, whileFILE_OBJNAMEexamines the name of the object contained within the archive.Each
ASSIGN_SECTIONmaintains a list of allFILE_BASENAME,FILE_PATH, andFILE_OBJNAMEvalues. A file match occurs if any one of these definitions match an input file. -
IS_NAME -
Input section name. The name can be specified as a string literal, or as a
MATCHexpression. See MATCH and MATCHREF Expressions. -
TYPE -
Specifies an ELF section_type, which can be any of the
SHT_constants defined in<sys/elf.h>, with theSHT_prefix removed. For example,PROGBITS,SYMTAB, orNOBITS. -
FLAGS -
The
FLAGSattribute uses section_flags to specify section attributes as a space separated list of one or more of theSHF_constants defined in<sys/elf.h>, with theSHFprefix removed. The most commonly used flags are given in Table 10-7, which correspond to theSHF_values defined in<sys/elf.h>. If an individual flag is preceded by an exclamation mark (!), that attribute must explicitly not be present. In the following example, a section is defined allocable and not writable.ALLOC !WRITE
Flags not explicitly in a section_flags list are ignored. In the preceding example, only the value of
ALLOCandWRITEare examined when matching a section against the specified flags. The other section flags can have any value. -
OUTPUT_SECTION -
By default, output sections inherit their name and other properties from the input sections that are assigned to them. The
OUTPUT_SECTIONattribute is used to modify or override these properties.OUTPUT_SECTIONaccepts the following.-
ANCILLARY -
Specifies that the data for a matched non-allocable section should be directed to the ancillary output object given by
anc_name. Theanc_namemust be defined by a previousANCILLARYdirective. See ANCILLARY Directive.ANCILLARYcan only be used withSEGMENT_NULLdirectives. -
DISCARD -
Discard the matched input section instead of copying it to the output object. The
DISCARDattribute cannot be combined with any otherOUTPUT_SECTIONattribute. -
FLAGS -
The
FLAGSattribute specifies section flags as a space separated list of theSHF_constants defined in<sys/elf.h>, with theSHF_prefix removed. There are three forms allowed.FLAGS = section_flags; FLAGS += section_flags; FLAGS -= section_flags;
The simple "=" assignment operator replaces the flags inherited from the input section with the new set, the "+=" form adds the new flags to the existing set, and the "-=" form removes the specified flags from the existing set.
-
NAME -
Specifies a new name for the output section, either as a string literal, or with a
MATCHREFexpression. When aMATCHREFexpression is used, substrings from the input section and file name can be substituted fromMATCHexpressions used with theASSIGN_SECTIONFILE_BASENAME,FILE_OBJNAME,FILE_PATH, andIS_NAMEattributes. TheMATCHREFsubstitution tokens for theFILE_attributes use the identifier characterf, and are of the form${fN}, where N is an integer value specifying the substring. Substitution tokens for theIS_NAMEattribute use the identifier charactern, and have the form${nN}. See MATCH and MATCHREF Expressions. -
TYPE -
Specifies an ELF section_type, which can be any of the
SHT_constants defined in<sys/elf.h>, with theSHT_prefix removed. For example,PROGBITS,SYMTAB, orNOBITS.
-
Table 10-7 Section FLAGS Values
| Flag Value | Meaning |
|---|---|
|
|
Section is allocable |
|
|
Section is writable |
|
|
Section is executable |
|
|
Section can be larger than 2 Gbytes |