#pragma arm section [section_type_list]

This pragma specifies a section name to be used for subsequent functions or objects. This includes definitions of anonymous objects the compiler creates for initializations.

Note

You can use __attribute__((section(..))) for functions or variables as an alternative to #pragma arm section.

Show/hideSyntax

#pragma arm section [section_type_list]

Where:

section_type_list

specifies an optional list of section names to be used for subsequent functions or objects. The syntax of section_type_list is:

section_type[[=]"name"] [,section_type="name"]*

Valid section types are:

  • code

  • rodata

  • rwdata

  • zidata.

Show/hideUsage

Use #pragma arm section [section_type_list] to place functions and variables in separate named sections. The scatter-loading description file can then be used to locate these at a particular address in memory.

Show/hideRestrictions

This option has no effect on:

  • Inline functions and their local static variables.

  • Template instantiations and their local static variables.

  • Elimination of unused variables and functions. However, using #pragma arm section might enable the linker to eliminate a function or variable that might otherwise be kept because it is in the same section as a used function or variable.

  • The order that definitions are written to the object file.

Show/hideExample

int x1 = 5;                     // in .data (default)
int y1[100];                    // in .bss (default)
int const z1[3] = {1,2,3};      // in .constdata (default)
#pragma arm section rwdata = "foo", rodata = "bar"
int x2 = 5;                     // in foo (data part of region)
int y2[100];                    // in .bss
int const z2[3] = {1,2,3};      // in bar
char *s2 = "abc";               // s2 in foo, "abc" in .conststring
#pragma arm section rodata
int x3 = 5;                     // in foo
int y3[100];                    // in .bss
int const z3[3] = {1,2,3};      // in .constdata
char *s3 = "abc";               // s3 in foo, "abc" in .conststring
#pragma arm section code = "foo"
int add1(int x)                   // in foo (code part of region)
{
    return x+1;
} 
#pragma arm section code

Show/hideSee also

Copyright © 2010-2011 ARM. All rights reserved.ARM DUI 0491E
Non-ConfidentialID071611