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

Syntax

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

Usage

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.

Restrictions

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.

Example

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 reference
9.46 __attribute__((section("name"))) function attribute
Related information
Scatter-loading Features
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.