curious_jp ([info]curious_jp) wrote,
@ 2007-07-11 11:16:00
Previous Entry  Add to memories!  Tell a Friend  Next Entry
Hold! What you are doing to us is wrong! Why do you do this thing?
Apple, I don't understand the function prolog as documented in the IA32 Calling Conventions ABI Reference Document.
  1. Pushes the value of the stack frame pointer (EBP) onto the stack.
  2. Sets the stack frame pointer to the value of the stack pointer (ESP).
  3. Pushes the values of the registers that must be preserved (EDI, ESI, and EBX) onto the stack.
  4. Allocates space in the stack frame for local storage.
However, an example prolog for a function with 12 bytes of locals looks like this:
pushl   %ebp
movl    %esp, %ebp
subl    $24, %esp
As you can see, none of the so-called non-volatile registers were pushed, nor were they pushed by the call statement that led to this function as far as I can tell - they're certainly not where the ABI implies they should be. Despite this, a great deal more stack ( an additional twelve bytes ) was reserved than is necessary. I guess space was reserved for pushes of edi, esi and ebx, but as these registers weren't used by the function, they never got pushed, despite compiling without optimisations. Weird.



(Read 1 comment) - (Post a new comment)


[info]wzdd
2007-07-11 10:05 am UTC (link)
I'm feeling too relaxed to find a reference now, but I think I've seen this case (always reserve space to spill, but only spill if necessary) before and I think your theory is correct.

(Reply to this)


(Read 1 comment) - (Post a new comment)

Create an Account
Forgot your login or password?
Login w/ OpenID
English • Español • Deutsch • Русский…