July 11th, 2007

Japan

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.
Japan

August 2007

S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Advertisement

Powered by LiveJournal.com