Skip to main content

IAR Embedded Workbench for RH850 3.20.x

‑‑function_sections

In this section:
Syntax
--function_sections
Description

Use this option to place each function of the source file in a separate section in the resulting object file. The name of the sections are prefixed with the string .text. followed by the name of the function. In C++, due to overloading, the mangled function names are used as section names.

The option gives placement flexibility—each individual function can be placed independently of all other functions in the module—at the expense of some lost optimization opportunities. The resulting code size might also increase. For these reasons, it is often better not to use this option and instead use #pragma location to place individual functions it their own sections, as this offers flexibility for the functions that actually need it, and better optimization opportunities for the rest. The ‑‑function_sections option brings no size benefits in the IAR toolchain—when the object files are built with an IAR compiler, unused functions are always discarded, regardless of this option.

This option corresponds to the GNU C compilation option ‑ffunction-sections.

Example
int func1() { return 0; }
int func2() { return 1; }

If compiled in C mode, the func1 and func2 functions would be placed in these two sections: .text.func1 and .text.func2.

See also

Controlling data and function placement in memory and Section reference.

Caution

To set this option, use Project>Options>C/C++ Compiler>Extra Options.