The calling sequence and stack frame

When your function first gets control, the stack frame looks like:
  Caller's frame
  last overflow arg
8(%rsp) 1st overflow arg
0(%rsp) return address
-8(%rsp) begin red zone (16-byte aligned)
-128(%rsp) end of red zone

The ``red zone'' is an reserved area that is not modified by signal or interrupt handlers, and so may be used as the temporary area for leaf functions.

When arguments are passed, they are first passed in registers as summarized in Table 4. Only when all registers of a given type are used up are they passed on the stack (the ``overflow'' args above). Note that the 7th and later integral arguments will overflow, as will the 9th and later floating point arguments. All argument lengths are rounded up to 8 bytes (i.e., a 4-byte integer is passed in the %edi portion of the %rdi register, for instance), both in register passing and in stack passing.

Clint Whaley 2012-07-10