AT汇编常见命令

来源:互联网 发布:格格广场舞服装淘宝店 编辑:程序博客网 时间:2024/06/05 19:09

1.section 命令作用是定义内存段

.section .text         #定义文本段(代码段)    

.section .data        #定义数据段(数据段通常是指用来存放程序中已初始化的全局变量的一块内存区域)    

.section .bss         #定义 bss 段(通常是指用来存放程序中未初始化的全局变量的一块内存区域)

这个命令开始比较困惑,手册介绍很清晰,可以我没有看看到它的作用,结果在博客:

http://blog.csdn.net/tigerjibo/article/details/7673061

里面讲解得很好

每一个段以段名为开始, 以下一个段名或者文件结尾为结束。

之前一直把伪指令逐个的读,简而言之就是标志某个段

2.global/ .globl :用来定义一个全局的符号

              格式如下:  .global symbol 或者 .globl symbol

3.type:用来指定一个符号的类型是函数类型或者是对象类型, 对象类型一般是数据


4.cfi_startproc is used at the beginning of each function that should have an entry in


5.eh_frame. It initializes some internal data structures and emits architecture dependent initial CFI instructions. Don't forget to close the function by .cfi_endproc.


6.file tells as that we are about to start a new logical file. string is the new file name


7.global makes the symbol visible to ld. If you define symbol in your partial program, its value is made available to other partial programs that are linked with it. Otherwise, symbol takes its attributes from a symbol of the same name from another file linked into the same program.



其他的可以看看

http://web.mit.edu/rhel-doc/3/rhel-as-en-3/

或者看看

at汇编语法讲解(百度下载...)




一个简单的例子


        .file   "gcc_learning.c"        .section        .rodata.LC0:        .string "some gcc options test"        .text.globl main        .type   main, @functionmain:.LFB0:        .cfi_startproc        pushq   %rbp        .cfi_def_cfa_offset 16        movq    %rsp, %rbp        .cfi_offset 6, -16        .cfi_def_cfa_register 6        movl    $.LC0, %eax        movq    %rax, %rdi        movl    $0, %eax        call    printf        leave        ret        .cfi_endproc.LFE0:        .size   main, .-main        .ident  "GCC: (Ubuntu/Linaro 4.4.4-14ubuntu5.1) 4.4.5"        .section        .note.GNU-stack,"",@progbits~

它的等价C

#include <stdio.h>void main(){        printf("some gcc options test");}



0 0
原创粉丝点击