调用方按照x86 ABI的相反顺序推送参数,然后调用
fun
. 这个
call
指令推送
eip
在跳到
乐趣
. 然后,设置堆栈帧,使
ebp
堆栈顶部,因此arg1必须比堆栈帧高8个字节:
higher mem
+----------+---------+
| arg 3 | 4 bytes | push arg 3
+----------+---------+ (ebp + 16)
| arg 2 | 4 bytes | push arg 2
+----------+---------+ (ebp + 12)
| arg 1 | 4 bytes | push arg 1
+----------+---------+ (ebp + 8)
| ret addr | 4 bytes | call fun
+----------+---------+ (ebp + 4)
| old ebp | 4 bytes | push ebp; mov ebp, esp
+----------+---------+ <-------- (ebp + 0) STACK FRAME START
lower mem