Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题 伪寄存器在函数调用前后是如何恢复现场的 #47

Open
zhaozy93 opened this issue May 9, 2021 · 2 comments
Open
Labels
question Further information is requested

Comments

@zhaozy93
Copy link

zhaozy93 commented May 9, 2021

C系语言中,调用函数把硬件寄存器BP值写入栈中,被调用函数ret后,读取当前bp加固定位移得到调用函数的硬件寄存器BP值,即可恢复现场,看plan9的文章对4个伪寄存器并没有进行类似操作。
请问 伪寄存器在函数调用前后是如何恢复现场的?

@zhaozy93
Copy link
Author

zhaozy93 commented May 9, 2021

或者说 不需要恢复现场 伪SP和伪BP可以通过硬件寄存器的BP计算出来?

@cch123
Copy link
Owner

cch123 commented May 10, 2021

BP 在 callee 的 framesize 大小 > 0 的时候也是会在栈上存的
ret 的流程和其他语言应该是一样的

另外,伪寄存器编译后都会转成真实的物理寄存器,不会在最终生成的汇编代码中有任何伪寄存器的

@cch123 cch123 added the question Further information is requested label May 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants