Disassembly of a simple C program and analysis

Source: Internet
Author: User

Disassembly of a simple C program and analysis

C Source:

int g(int x){    return x+1;}int f(int x){    return g(x);}int main(void){    return f(2) + 3;}

Compilation Source:

1 g:2   pushl   %ebp3   movl    %esp, %ebp4   movl    8(%ebp), %eax5   addl    $1, %eax6   popl    %ebp7   ret8 f:9   pushl   %ebp10  movl    %esp, %ebp11  subl    $4, %esp12  movl    8(%ebp), %eax13  movl    %eax, (%esp)14  call    g15  leave16  ret17 main:18  pushl   %ebp19  movl    %esp, %ebp20  subl    $4, %esp21  movl    $2, (%esp)22  call    f23  addl    $3, %eax24  leave25  ret

Execution process: (starting from main)

Original works reproduced please indicate the source


http://blog.luoyuanhang.cn

MOOC Course
"Linux kernel Analysis"

Created by Luo voyage

[Email protected]

July 03,2015

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Disassembly of a simple C program and analysis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.