In the following line of code (which declares a global variable),
unsigned int __attribute__((section(".myVarSection,\"aw\",@nobits#"))) myVar;
what does the “aw” flag mean?
My understanding is that the nobits flag will prevent the variable from being initialised to zero, but I am struggling to find info about the “aw” flag.
Also, what meaning do the @ and # have around the nobits flag?
The
section("section-name")attribute places a variable in a specific section by producing the following assembler line:When you set
section-nameto".myVarSection,\"aw\",@nobits#"you exploit a kind of “code injection” in GCC to produce:Note that
#sign starts a one-line comment.See GNU Assembler manual for the full description of
.sectiondirective. A general syntax isso
"aw"are flags:and
@nobitsis a type:All the above is also applicable to functions, not just variables.