Transferred from: http://blog.csdn.net/humanbeng/article/details/7971570
4.6.3 #pragma arm section [section_sort_list]
This compilation indicates that the section name to use for subsequent functions or objects is specified. This includes the definition of the anonymous object that the compiler created for initialization. Note that you can __attribute__ (Section (..)) Used for functions or variables to replace #pragma arm section.
Syntax
#pragma arm section [section_sort_list]
which
section_sort_list specifies an optional list of section names to use for subsequent functions or objects.
Section_sort_list syntax is: section_type[[=] "name"] [, section_type= "name"]*
Valid section types are: code, rodata, rwdata, zidata.
Usage
You can use the scatter-load profile with the ARM linker to control how a named section is placed in a specific memory address.
Limit
This option is not valid for the following:
• Inline functions and their local static variables.
• Template instantiation and its local static variables.
• Delete unused variables and functions. However, you can use the #pragma arm section to make the link
function or variable that might otherwise be retained because it is associated with a function or variable bit used
In the same section.
• The order in which the definitions are written to the object file.
Example
int x1 = 5; In. Data (default)
int y1[100]; In. BSS (default)
int const Z1[3] = {n/a}; 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] = {n/a}; 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] = {n/a}; 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
In fact, add the additional Name field, place the paragraph at the beginning of code, Rodata, Rwdata, or zidata, and as to which segment is specified by Section_type in section_type[[=] "name".
#pragma arm Section Description