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.foo (the default code section name is.text). - The default section name can be modified with the
-mtextoption. If this option has been used, then current section name will be changed. For example, if-mtext=mytextis 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
mytextregardless of whether or not-ffunction-sectionsis specified. - Interrupt functions are normally placed into a special section with
the name
.isrprepended 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
-mtextis 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,.isrwill still be prepended to the section name.The
.isris prepended to allow the--gc-sectionsoption to not throw away interrupt functions. These must be kept.
