According to disassembler, there are some functions look like
sub esp, 0x20
push some registers
do some stuffs
pop the registers
add esp, 0x20
ret
At first I thought it was to allocate memory for local variables, but I realize there are other functions look like just simply
push some registers
do stuffs
pop some registers
ret
which does not subtract esp manually.
I have done some searching and apparently the push command already automatically subtract esp for the size of the value pushed; if this is the case, then why in the first function we still need to manually subtract esp at the beginning of the function? Or in other words, what exactly is the difference in purpose between the two functions?
I'ts a reservation (allocation) of stack space for local variables. Also, some versions of ABI may require specific stack pointer alignment upon function entry
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With