4.5.6. __attribute__((section))

Normally, the ARM compiler places the objects 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. The section attribute specifies that a variable must be placed in a particular data section. If you use the section attribute, read-only variables are placed in RO data sections, read-write variables are placed in RW data sections unless you use the zero_init attribute. In this case, the variable is placed in a ZI section.


This variable attribute is a GNU compiler extension that is supported by the ARM compiler.


/* in RO section */
const int descriptor[3] __attribute__ ((section ("descr"))) = { 1,2,3 };

/* in RW section */
long long rw[10] __attribute__ ((section ("RW")));

/* in ZI section *
long long altstack[10] __attribute__ ((section ("STACK"), zero_init));/
Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A