You copied the Doc URL to your clipboard.

#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.


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


#pragma arm section [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.


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


This option has no effect on:

  • Inline functions and their local static variables if the --no_ool_section_name command-line option is specified.

  • 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.


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
Related information