4.3.9. __attribute__((section))

The section function attribute enables you to place code in different sections of the image.

Note

This function attribute is a GNU compiler extension that is supported by the ARM compiler.

Example

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

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A
Non-Confidential