Calling Conventions: Difference between revisions

[unchecked revision][unchecked revision]
Line 20:
! Call List
|-
| System V i386 || eax, edx || none || stack (right to left)<sup>[[#Note1|1]]</sup> || || eax, ecx, edx || ebx, esi, edi, ebp, esp || ebp
|-
| System V X86_64<sup>[[#Note1Note2|12]]</sup> || rax, rdx || rdi, rsi, rdx, rcx, r8, r9 || stack (right to left)<sup>[[#Note1|1]]</sup> || 16-byte at call<sup>[[#Note2Not3|23]]</sup> || rax, rdi, rsi, rdx, rcx, r8, r9, r10, r11 || rbx, rsp, rbp, r12, r13, r14, r15 || rbp
|-
| ARM || r0, r1 || r0, r1, r2, r3 || stack || 8 byte<sup>[[#Note3Note4|34]]</sup> || r0, r1, r2, r3, r12 || r4, r5, r6, r7, r8, r9, r10, r11, r13, r14 ||
|}
 
<small id="Note2">Note 1: The called function is allowed to modify the arguments on the stack and the caller must not assume the stack parameters are preserved. The caller should clean up the stack.</small>
<small id="Note1">Note 1: There is a 128 byte area below the stack called the 'red zone', which may be used by leaf functions without increasing %rsp. This requires the kernel to increase %rsp by an additional 128 bytes upon signals in user-space. This is <em>not</em> done by the CPU - if interrupts use the current stack (as with kernel code), and the red zone is enabled (default), then interrupts will silently corrupt the stack. Always pass -mno-red-zone to kernel code (even support libraries such as libc's embedded in the kernel) if interrupts don't respect the red zone.</small>
 
<small id="Note1Note2">Note 12: There is a 128 byte area below the stack called the 'red zone', which may be used by leaf functions without increasing %rsp. This requires the kernel to increase %rsp by an additional 128 bytes upon signals in user-space. This is <em>not</em> done by the CPU - if interrupts use the current stack (as with kernel code), and the red zone is enabled (default), then interrupts will silently corrupt the stack. Always pass -mno-red-zone to kernel code (even support libraries such as libc's embedded in the kernel) if interrupts don't respect the red zone.</small>
<small id="Note2">Note 2: Stack is 16 byte aligned at time of call. The call pushes %rip, so the stack is 16-byte aligned again if the callee pushes %rbp.</small>
 
<small id="Note3">Note 3: Stack is 816 byte aligned at alltime timesof outsidecall. ofThe prologue/epiloguecall ofpushes %rip, so the stack is 16-byte aligned again if the callee pushes function%rbp.</small>
 
<small id="Note4">Note 4: Stack is 8 byte aligned at all times outside of prologue/epilogue of function.</small>
 
==External References==
Anonymous user