gpt4 book ai didi

gcc - 为什么u-boot可以把全局数据的地址放到r9寄存器中?

转载 作者:行者123 更新时间:2023-12-05 02:22:50 27 4
gpt4 key购买 nike

查看u-boot源码,发现它是这样通过r9寄存器传递全局数据的

register volatile gd_t *gd asm ("r9")

所以,我很好奇,u-boot 如何确保更多代码不会使用 r9 寄存器和破坏全局数据。是否有选项告诉编译器不要使用特定寄存器?

最佳答案

来自 Procedure Call Standard for the ARM Architecture :

The role of register r9 is platform specific. A virtual platform may assign any role to this register and must document this usage. For example, it may designate it as the static base (SB) in a position-independent data model, or it may designate it as the thread register (TR) in an environment with thread-local storage. The usage of this register may require that the value held is persistent across all calls. A virtual platform that has no need for such a special register may designate r9 as an additional callee-saved variable register, v6.

GCC doesn't have a abi profile for reserving r9平台使用thus the way u-boot does this is with -ffixed-r9 option .

关于gcc - 为什么u-boot可以把全局数据的地址放到r9寄存器中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26966514/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com