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
In Example8-3, the linker takes all the .text sections from the input files and combines them into the .text output section. The linker concatenates the .text input sections in the order that it encounters them in the input files. The linker performs similar operations with the .data and .bss sections. You can use this type of specification for any output section.
You can explicitly specify the input sections that form an output section. Each input section is identified by its filename and section name. If the filename is hyphenated (or contains special characters), enclose it within quotes:
SECTIONS
{
.text : /* Build .text output section */
{
f1.c.obj(.text) /* Link .text section from f1.c.obj */
f2.c.obj(sec1) /* Link sec1 section from f2.c.obj */
"f3-new.c.obj" /* Link ALL sections from f3-new.c.obj */
f4.c.obj(.text,sec2) /* Link .text and sec2 from f4.c.obj */
f5.c.obj(.task??) /* Link .task00, .task01, .taskXX, etc. from f5.c.obj */
f6.c.obj(*_ctable) /* Link sections ending in "_ctable" from f6.c.obj */
X*.c.obj(.text) /* Link .text section for all files starting with */
/* "X" and ending in ".c.obj" */
}
}
It is not necessary for input sections to have the same name as each other or as the output section they become part of. If a file is listed with no sections, all of its sections are included in the output section. If any additional input sections have the same name as an output section but are not explicitly specified by the SECTIONS directive, they are automatically linked in at the end of the output section. For example, if the linker found more .text sections in the preceding example and these .text sections were not specified anywhere in the SECTIONS directive, the linker would concatenate these extra sections after f4.c.obj(sec2).
The specifications in Example8-3 are actually a shorthand method for the following:
SECTIONS
{
.text: { *(.text) }
.data: { *(.data) }
.bss: { *(.bss) }
}
The specification *(.text) means the unallocated .text sections from all input files. This format is useful if:
The following example illustrates the two purposes above:
SECTIONS
{
.text : {
abc.c.obj(xqt)
*(.text)
}
.data : {
*(.data)
fil.c.obj(table)
}
}
In this example, the .text output section contains a named section xqt from file abc.c.obj, which is followed by all the .text input sections. The .data section contains all the .data input sections, followed by a named section table from the file fil.c.obj. This method includes all the unallocated sections. For example, if one of the .text input sections was already included in another output section when the linker encountered *(.text), the linker could not include that first .text input section in the second output section.
Each input section acts as a prefix to gather longer-named sections. For example, the pattern *(.data) matches .dataspecial. Thus, prefixes enable subsections, which are described in the following section.