4.6.3. #pragma arm section [section_sort_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_sort_list]

Where:

section_sort_list

specifies an optional list of section names to be used for subsequent functions or objects.

Usage

Use a scatter-loading description file with the ARM linker to control how to place a named section 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 enables 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

See also

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