问题描述
我相信我了解 linux x86-64 ABI 如何使用寄存器和堆栈将参数传递给函数(参见 之前的 ABI 讨论).我感到困惑的是,如果/哪些寄存器应该在函数调用中保留.也就是说,哪些寄存器可以保证不被破坏?
I believe I understand how the linux x86-64 ABI uses registers and stack to pass parameters to a function (cf. previous ABI discussion). What I'm confused about is if/what registers are expected to be preserved across a function call. That is, what registers are guarenteed not to get clobbered?
推荐答案
这里是完整的寄存器表及其使用文档 [PDF 链接]:
Here's the complete table of registers and their use from the documentation [PDF Link]:
r12
、r13
、r14
、r15
、rbx
、rsp
、rbp
是被调用者保存的寄存器 - 它们在跨函数调用保留"列中有一个是".
r12
, r13
, r14
, r15
, rbx
, rsp
, rbp
are the callee-saved registers - they have a "Yes" in the "Preserved across function calls" column.
这篇关于通过 linux x86-64 函数调用保留了哪些寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!