“aw"是什么意思?部分属性中的标志是什么意思?

编程入门 行业动态 更新时间:2024-10-26 08:25:25
本文介绍了“aw"是什么意思?部分属性中的标志是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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:

.section section-name,"aw",@progbits

When you set section-name to ".myVarSection,"aw",@nobits#" you exploit a kind of "code injection" in GCC to produce:

.section .myVarSection,"aw",@nobits#,"aw",@progbits

Note that # sign starts a one-line comment.

See GNU Assembler manual for the full description of .section directive. A general syntax is

.section name [, "flags"[, @type[,flag_specific_arguments]]]

so "aw" are flags:

  • a: section is allocatable
  • w: section is writable

and @nobits is a type:

  • @nobits: section does not contain data (i.e., section only occupies space)

All the above is also applicable to functions, not just variables.

更多推荐

“aw"是什么意思?部分属性中的标志是什么意思?

本文发布于:2023-11-03 01:16:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1553890.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   标志   aw   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!