Use the linker command file's SECTIONS directive to
Use GROUP directives in a SECTIONS directive to organize objects.
The linker will only create a section in the output file if the section is not empty, even if the section is defined in a SECTIONS or GROUP directive.
SECTIONS and GROUP example shows an example.
SECTIONS
{
GROUP :
{
.text : {}
.rodata : {}
} > text
GROUP
{
.sdata : {}
.sbss : {}
} > data
GROUP
{
.sdata2 : {}
.sbss2 : {}
} > data
}
This example defines the .text and .rodata sections in the output file and specifies that they should be loaded in the memory area named text on the target platform at runtime. The example then defines sections named .sdata and .sbss . These sections will be loaded in the memory named data . The last GROUP directive in the example defines sections named .sdata2 , and .sbss2 . These sections will also be loaded in the memory area named data , after the sections .sdata and .sbss .