x86-CALL指令是否总是将EIP指向的地址压入堆栈? [英] x86 - Does CALL instruction ALWAYS push the address pointed by EIP to stack?
问题描述
在x86体系结构中的函数调用期间,是否存在返回地址没有被压入堆栈的情况?
Is there any condition where the return address is not pushed into stack during a function call in x86 architecture?
推荐答案
否.根据定义,CALL
将把返回地址压入堆栈,然后再跳转到目标地址.该返回地址为EIP
(或RIP
)+ sizeof(call instruction)
(通常为5个字节).
No. CALL
will, by definition, push the return address onto the stack before jumping to the target address. That return address is EIP
(or RIP
) + sizeof(call instruction)
(usually 5 bytes.)
将过程链接信息保存在堆栈上,并跳转到使用目标指定的被调用过程
操作数.
Saves procedure linking information on the stack and branches to the called procedure specified using the target
operand. 这包括: 我熟悉的每个C编译器将始终使用 Every C compiler I'm familiar with will always implement function calls on x86 using a 这篇关于x86-CALL指令是否总是将EIP指向的地址压入堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
JMP
.CALL
指令在x86上实现函数调用,但有一个例外: tail call (可以通过JMP
实现).当一个函数返回另一函数调用的结果时,尤其会发生这种情况.例如CALL
instruction, with one exception: a tail call, which can be implemented with a JMP
. This happens especially when one function returns the result of another function call. E.g.int bar(int a, int b);
int foo(int a, int b)
{
if (a < b)
return 0;
return bar(a, b); // Will probably be: jmp bar
}