Normally the linker stores sections from input object code in the sections of the linker's output file that have the same name. The linker command file's SECTIONS and GROUP directives allow you to specify other ways to associate input object code with sections in linker output. Associating object code with sections in linker output shows an example.
SECTIONS
{
GROUP :
{
.myText : { main.o (.text) }
.text : ( *(.text) }
} > text
}
This example defines a section in the output file named .myText . This section will contain the objects that are in the .text section in the object code taken from the input file named main.o . The example also defines a section in the output file named .text . This section will contain all objects in the .text sections of all input files containing object code. Both these sections in the output file, .myText and .text , will be loaded in the memory area named text on the target platform.
The SECTIONS and GROUP directives also allow you to filter what kinds of object code from input files will be stored in a section in the output file. Filter types for object code in input files shows the kinds of data that may be filtered.
| This filter | allows input objects that have these permissions | and contain this kind of object code |
|---|---|---|
| TEXT | readable, executable | initialized |
| CODE | readable, executable | initialized |
| DATA | readable, writable | initialized |
| BSS | readable, writable | uninitialized |
| CONST | readable | initialized |
| MIXED | readable, writable, executable | initialized |
| VLECODE | readable, executable | initialized |
Filtering objects from input files shows an example.
SECTIONS
{
.text (TEXT) : { } > text
.bss (BSS) : { } > data
}
This example defines a section in the output file named .text . The linker will only store objects from input object code that are readable, executable, and initialized. This example also defines a section in the output file named .bss . This section will only contain objects from the linker's input files that are readable, writable, and uninitialized.