Stack: return address

Is return address on the stack the same as the value of program counter before a function was called? They both seem to relate to the same concept, ie to the next instruction that is going to be executed after the function returns.


Yes. The calling mechanism works like this (it may not work exactly this way, because different x86 architectures have different microarchitectures, but this "algorithm" gives the gist):

As the call instruction is fetchedexecuted, RIP is ephemerally set to the address of the instruction following the call. The execution of call will push the value of RIP onto the stack, then it will set RIP to the resolved address of the target of the call .

Details in the official manual in Volume 1, Chapter 6.

链接地址: http://www.djcxy.com/p/14106.html

上一篇: 如何在Windows函数调用中设置堆栈?

下一篇: 堆栈:返回地址