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")
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?
From 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.
Yet GCC doesn't have a abi profile for reserving r9
for platform usage thus the way u-boot does this is with -ffixed-r9 option.