SPNU118Z September 1995 – March 2023 66AK2E05 , 66AK2H06 , 66AK2H12 , 66AK2H14 , AM1705 , AM1707 , AM1802 , AM1806 , AM1808 , AM1810 , AM5K2E04 , OMAP-L132 , OMAP-L137 , OMAP-L138 , SM470R1B1M-HT , TMS470R1A288 , TMS470R1A384 , TMS470R1A64 , TMS470R1B1M , TMS470R1B512 , TMS470R1B768
The SECTIONS directive is specified in a command file by the word SECTIONS (uppercase), followed by a list of output section specifications enclosed in braces.
The general syntax for the SECTIONS directive is:
SECTIONS | |
{ | |
name : [property [, property] [, property] . . . ] | |
name : [property [, property] [, property] . . . ] | |
name : [property [, property] [, property] . . . ] | |
} |
Each section specification, beginning with name, defines an output section. (An output section is a section in the output file.) Section names can refer to sections, subsections, or archive library members. (See Section 8.5.5.4 for information on multi-level subsections.) After the section name is a list of properties that define the section's contents and how the section is allocated. The properties can be separated by optional commas. Possible properties for a section are as follows:
|
|||
Syntax: | load = allocation | or | |
> allocation | |||
|
|||
Syntax: | run = allocation | or | |
run > allocation | |||
|
|||
Syntax: | { input_sections } | ||
|
|||
Syntax: | type = COPY | or | |
type = DSECT | or | ||
type = NOLOAD | |||
|
|||
Syntax: | fill = value |
The following example shows a SECTIONS directive in a sample linker command file.
/**************************************************/
/* Sample command file with SECTIONS directive */
/**************************************************/
file1.c.obj file2.c.obj /* Input files */
--output_file=prog.out /* Options */
SECTIONS
{
.text: load = EXT_MEM, run = 0x00000800
.const: load = FAST_MEM
.bss: load = SLOW_MEM
.vectors: load = 0x00000000
{
t1.c.obj(.intvec1)
t2.c.obj(.intvec2)
endvec = .;
}
.data:alpha: align = 16
.data:beta: align = 16
}
Figure 8-2 shows the output sections defined by the SECTIONS directive in the previous example (.vectors, .text, .const, .bss, .data:alpha, and .data:beta) and shows how these sections are allocated in memory using the MEMORY directive given in Section 8.5.4.2.