这个函数callee初始化和清理序列有什么作用?

时间:2015-04-02 19:49:26

标签: assembly x86

我正在使用CompCert并编译

int main() { return 0; }

# File generated by CompCert 2.3pl2
# Command line: -S test2.c
    .text
    .align  16
    .globl main
main:
    .cfi_startproc
    subl    $12, %esp
    .cfi_adjust_cfa_offset  12
    leal    16(%esp), %edx
    movl    %edx, 0(%esp)
    xorl    %eax, %eax
    addl    $12, %esp
    ret
    .cfi_endproc
    .type   main, @function
    .size   main, . - main

请注意,这是AT& T语法。

这是做什么的?

我不熟悉subl,leal,movl模式。

我只看过

push %ebp
movl %esp, %ebp
...
leave

图案。

1 个答案:

答案 0 :(得分:1)

[ESP + 4]指向proc条目的返回地址 [ESP + xx]指的是proc输入参数
[ESP - xx]为地方变量保留地点

enter image description here

相关问题