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.