linux汇编指令

在程序中,.bss段用于存放未初始化的全局变量和静态变量,而用gcc -S生成的c语言源文件的汇编代码中找不到.bss段,未初始化的全局变量都出现在.comm后;而未初始化的静态变量先以.local限制,然后再出现在.comm后。  下面是引自Using as的一段文字,详细解释了.comm以及各参数的含义:

.comm symbol , length

.comm declares a common symbol named symbol . When linking, a common symbol in one object file may be merged with a defined or common symbol of the same name in another object file. If ld does not see a definition for the symbol–just one or more common symbols–then it will allocate length bytes of uninitialized memory. length must be an absolute expression. If ld sees multiple common symbols with the same name, and they do not all have the same size, it will allocate space using the largest size.


When using ELF or (as a GNU extension) PE, the .comm directive takes an optional third argument. This is the desired alignment of the symbol, specified for ELF as a byte boundary (for example, an alignment of 16 means that the least significant 4 bits of the address should be zero), and for PE as a power of two (for example, an alignment of 5 means aligned to a 32-byte boundary). The alignment must be an absolute expression, and it must be a power of two. If ld as will set the alignment to the largest power of two less than or equal to the size of the symbol, up to a maximum of 16 on ELF, or the default section alignment of 4 on PE1 . allocates uninitialized memory for the common symbol, it will use the alignment when placing the symbol. If no alignment is specified,

The syntax for .comm differs slightly on the HPPA. The syntax is `symbol .comm, length '; symbol is optional.


Footnotes

[1 ] This is not the same as the executable image file alignment controlled by ld 's `--section-alignment ' option; image file sections in PE are aligned to multiples of 4096, which is far too large an alignment for ordinary variables. It is rather the default alignment for (non-debug) sections within object (`*.o ') files, which are less strictly aligned.

 

 

英文源于:http://sourceware.org/binutils/docs-2.20/as/Comm.html#Comm

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值