7.6.6.2 The -ffunction-sections
Option
The -ffunction-sections
command-line option will try
and put all functions into its own section. However, there are many conditions that can
effect what exactly this means. Here is a summary:
- Normal (non interrupt) functions will have the current section name
and a "." prepended to them, for example:
void foo() {}
will be placed into section
.text.fo
o (the default code section name is.text
). - The default section name can be modified with the
-mtext
option. If this option has been used, then current section name will be changed. For example, if-mtext=mytext
is specified, then the above function will be placed intomytext.foo
. - If the function has a section attribute, then it will be placed
into that named section without any adulteration. Therefore,
void __attribute__((section("mytext"))) foo() {}
will always be placed into the section
mytext
regardless of whether or not-ffunction-sections
is specified. - Interrupt functions are normally placed into a special section with
the name
.isr
prepended to the normal section name (as above). Therefore if the current section name is.text
(the default), then the ISR is placed into.isr.text.function_name
.If the
-mtext
is used to change the name of the default section name, then this will be substituted instead of.text
. However, if a named section is used with a section attribute,.isr
will still be prepended to the section name.The
.isr
is prepended to allow the--gc-sections
option to not throw away interrupt functions. These must be kept.