push %ebp
push %esp, %ebp
push edi
push esi
push ebx
(x86 32bit Linux)
Why are these registers pushed to stack?
Migrated for some reason...?
But, why only 'edi' 'esi' 'ebx' are pushed?
It is a gcc implementation detail for the x86 code generator. Surprisingly hard to find good docs for it, I did find this page which is pretty accurate. Key part:
after ret instruction:
%eip contains return address %esp points at arguments pushed by caller called function may have trashed arguments %eax contains return value (or trash if function is void) %ecx, %edx may be trashed %ebp, %ebx, %esi, %edi must contain contents from time of call
The "must contain content from time of call" phrase explains why their are pushed in the function prologue and popped again in the epilogue.
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