为什么u-boot 可以把全局数据的地址放到r9 寄存器中? [英] Why u-boot can put global data's address into r9 register?
问题描述
当我查看 u-boot 源代码时,我发现它像这样通过 r9 寄存器传递全局数据
When i look through u-boot source code, i found that it pass global data through r9 register like this
register volatile gd_t *gd asm ("r9")
所以,我很好奇,u-boot 如何确保进一步的代码不会使用 r9 寄存器并破坏全局数据.有没有告诉编译器不要使用特定寄存器的选项?
So, i'm curious, how does u-boot ensure further codes won't use r9 register and corrupt the global data. Is there an options to tell compiler not to use specific register?
推荐答案
来自 ARM 架构的过程调用标准:
寄存器 r9 的作用是特定于平台的.虚拟平台可以将任何角色分配给该寄存器,并且必须记录此用法.例如,它可以将其指定为位置无关数据模型中的静态基 (SB),或者可以将其指定为具有线程本地存储的环境中的线程寄存器 (TR).该寄存器的使用可能要求保持的值在所有调用中都是持久的.不需要这种特殊寄存器的虚拟平台可以将 r9 指定为额外的被调用者保存的变量寄存器 v6.
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 没有用于保留 r9 的 abi 配置文件
用于平台使用 因此 u-boot 执行此操作的方式是使用 -ffixed-r9 选项.
这篇关于为什么u-boot 可以把全局数据的地址放到r9 寄存器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!