Until recently I thought that section names generally have to start with a dot .
. However, When studying the sample linker file of my bare-metal-C-IDE, I noticed that there seems to be one exception: The section COMMON
.
.text :
{
KEEP(*(.isr_vector))
*(.text*)
KEEP(*(.init))
KEEP(*(.fini))
/* .ctors */
*crtbegin.o(.ctors)
*crtbegin?.o(.ctors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
*(SORT(.ctors.*))
*(.ctors)
/* .dtors */
*crtbegin.o(.dtors)
*crtbegin?.o(.dtors)
*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
*(SORT(.dtors.*))
*(.dtors)
*(.rodata*)
KEEP(*(.eh_frame*))
} > ROM
.bss (NOLOAD):
{
*(.bss*)
*(COMMON)
} > RAM
This led me to the conclusion that beginning the section names with .
seems to merely be a convention rather than a requirement.
So, my questions are:
- What is the reason for starting section names with a dot? I suppose there there was a (perhaps historical?) reason for this convention to be established.
- Why was an exception made for
COMMON
? - Why do usually output sections have the same name as input sections? It was rather confusing for me that there is actually a non-
.bss
sections included in my.bss
output section. Same goes with the.text
section. There are plenty of non-.text
sections included in my.text
output section. Why isn't it common just to give them their own output section? Wouldn't that be much more logical?
Are there any real reasons behind this, or is it just the way it is?