The section attribute specifies that a variable must be placed in a particular data section.
Normally, armclang places the data it generates in
sections like .data and .bss. However, you might require additional data sections or you might want a
variable to appear in a special section, for example, to map to special hardware.
If you use the section attribute, read-only
variables are placed in RO data sections, writable variables are placed in RW data
sections.
To place ZI data in a named section, the section must start with the prefix
.bss.. Non-ZI data cannot be placed in a section named
.bss.
Example
/* in RO section */
const int descriptor[3] __attribute__((section ("descr"))) = { 1,2,3 };
/* in RW section */
long long rw_initialized[10] __attribute__((section ("INITIALIZED_RW"))) = {5};
/* in RW section */
long long rw[10] __attribute__((section ("RW")));
/* in ZI section */
int my_zi __attribute__((section (".bss.my_zi_section")));
Note:
Section names must be unique. The compiler produces an error if:
You use the same section name for different section types.
You use a section name that is the same as a variable, function, or
other symbol in your program.
Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers of your data.