Help with understanding a very basic main() disassembly in GDB

后端 未结 4 921
闹比i
闹比i 2021-02-02 00:48

Heyo,

I have written this very basic main function to experiment with disassembly and also to see and hopefully understand what is going on at the lower level:



        
4条回答
  •  不思量自难忘°
    2021-02-02 01:16

    You did pretty good with your interpretation. When a function is called, the return address is automatically pushed to the stack, which is why argc, the first argument, has been pushed back to 4(%esp). argv would start at 8(%esp), with a pointer for each argument, followed by a null pointer. This function pushes the old value of %esp to the stack so that it can contain the original, unaligned value upon returned. The value of %ecx at return doesn't matter, which is why it is used as temporary storage for the %esp reference. Other than that, you are correct with everything.

提交回复
热议问题