x86 调用约定

调用约定主要规定参数传递顺序,传递方式(栈还是寄存器),调用者/被调用函数需要保留的寄存器(caller-saved registers or volatile registers / callee-saved registers or non-volatile registers)以及栈的使用与恢复(caller与callee谁负责平栈)

linux中常用的调用约定就两种,32位下cdecl,64位下SysV,stack cleanup 都是caller负责

cdecl

(c declaration)

32位下,函数参数从右往左依次被push到栈上

Registers EAX, ECX, and EDX are caller-saved, and the rest are callee-saved.

SysV

64位下,参数依次由RDI,RSI,RDX,RCX,R8,R9寄存器传递,如果还有更多参数,则和cdecl一样,从右往左把剩余参数压栈

Registers RBX, RBP, and R12–R15 are callee saved, all other registers are caller saved

其他约定

其他调用约定参考wiki: x86 calling conventions

参考

  • wiki: x86 calling conventions
  • ctf101: Calling Conventions

你可能感兴趣的:(x86 调用约定)