| |||
| Home > Compiler-specific Features > Function attributes > __attribute__((section("name"))) function attribute | |||
The section function attribute enables
you to place code in different sections of the image.
This function attribute is a GNU compiler extension that is supported by the ARM compiler.
In the following example, Function_Attributes_section_0 is
placed into the RO section new_section rather
than .text.
void Function_Attributes_section_0 (void)
__attribute__ ((section ("new_section")));
void Function_Attributes_section_0 (void)
{
static int aStatic =0;
aStatic++;
}
In the following example, section function
attribute overrides the #pragma arm section setting.
#pragma arm section code="foo"
int f2()
{
return 1;
} // into the 'foo' area
__attribute__ ((section ("bar"))) int f3()
{
return 1;
} // into the 'bar' area
int f4()
{
return 1;
} // into the 'foo' area
#pragma arm section