`
sony-soft
  • 浏览: 1020634 次
文章分类
社区版块
存档分类
最新评论

GNU汇编程序中的分段

 
阅读更多

GNU汇编程序中的分段

<1> .section伪操作

.section <section_name> {,”<flags>”}

Starts a new code or data section. Sections in GNU are called .text, a code section, .data, an initialized data section, and .bss, an uninitialized data section.

These sections have default flags, and the linker understands the default names(similar directive to the armasm directive AREA).The following are allowable .section flags for ELF format files:

<Flag> Meaning

a allowable section

w writable section

x executable section

中文解释:

用户可以通过.section伪操作来自定义一个段,格式如下:

.section section_name [, "flags"[, %type[,flag_specific_arguments]]]

每一个段以段名为开始, 以下一个段名或者文件结尾为结束。这些段都有缺省的标志(flags连接器可以识别这些标志。(与arm asm中的AREA相同)。下面是ELF格式允许的段标志flags

<标志> 含义

a 允许段

w 可写段

x 执行段

例:定义一个“段”

.section .mysection @自定义数据段,段名为 “.mysection”

.align 2

strtemp:

.ascii "Temp string \n\0" @对这一句的理解,我觉得应该是:将"Temp string \n\0"这个字符串存储在以标号strtemp:

@为起始地址的一段内存空间里

<2> 汇编系统预定义的段名

l .text @代码段

l .data @初始化数据段 .data Read-write initialized long data.

l .bss @未初始化数据段

l .sdata @ .sdata Read-write initialized short data.

l .sbss @

注意:源程序中.bss段应该在.text段之前。

<wbr></wbr>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics