Why are these registers being pushed onto the stack?
1 answer
This is a gcc implementation for an x86 code generator. Surprisingly hard to find good docs for this, I found this page to be pretty accurate. Main part:
after the ret statement:
%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 phrase "should contain content from the time of the conversation" explains why they are inserted in the function prologue and pushed again in the epilogue.
+5
source to share