Decompiling C programs into assembly code: analysis and reflection on the execution process of assembly code

Source: Internet
Author: User

Decompiling C programs into assembly code: analysis and reflection on the execution process of assembly code
System: 32-bit Ubuntu14.04
Write C program: (save to main. c)
int g(int x){return x + 3;} int f(int x){return g(x);} int main(void){return f(8) + 1;} Console decompilation command:
Obtain main. s. The content is as follows:


Delete the command starting with "." In main. s (the auxiliary information during the link) and get:


The following is an analysis of the last main_final.s execution process: (this Assembly is a syntax in linux, which is different from intel's Assembly)





The analysis process is as follows: ret returns, one is popl eip, And the return value is stored in eax.
The core of a computer is the CPU, register, and memory stack. Register cs: The eip always points to the command to be executed, and jumps to it based on the command itself; the cpu executes the command according to the command; the memory stores the command to be executed, and the stack is executed with the cpu.

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.