Reputation: 33
I'm dissapointed, because I can't find an information about memory segmentation. I know that I should divide memory into basic sections such as .text, .data, .bss, .stack, that are used in object files of compiled program. I know that there are many more other sections, some are necessary for C and other for C++. I'm searching information about, which sections should be included in linker script?
Upvotes: 0
Views: 1724
Reputation: 6026
It depends on your specific compiler and target architecture which output sections will be present or possibly present. And in your code, you can define input sections with arbitrary names. Your linker script serves to bind symbols from files, or symbols listed in explicitly defined input sections, to the output sections.
The best way to find out which output sections are present, is to just compile and link an example application, and inspect the generated map file (if the map file is not automatically generated, you should adjust your linker options). A map file is not meant for consumption by another tool, but serves as a readable description of what goes in your program, on what location, in which section, and why. Note: in that map file you will also find some section names that are not part of your program, and won't translate to physical bits that get executed or used by your program, but are rather aids for your debugger.
When you don't explicitly map some symbols to an output section, the linker will generally just append all remaining symbols after the last explicitly defined section.
You could therefore also define some kind of 'catch-all' section, that will surely attract all not-yet-assigned-symbols, and then verify whether the output section remains empty. i.e.
At the end of your SECTIONS block, add
SECTION
{
<snip>
.mustbeempty
{
*(.*) ;
}
ASSERT( SIZEOF( .mustbeempty ) = 0 ) ;
}
More info about linker scripts can be found on many places:
Upvotes: 3