[U-Boot] [PATCH 0/3] ARM: use r9 for gd instead of r8

Albert ARIBAUD
2013-08-12T05:49:51Z

Hi Beno?t,

On Mon, 12 Aug 2013 00:08:59 +0200 (CEST), Beno?t Th?baudeau
<benoit.thebaudeau@advansee.com> wrote:

> Dear Jeroen Hofstee,
>
> On Sunday, August 11, 2013 10:58:36 PM, Jeroen Hofstee wrote:
> > To be EABI compliant (r9 is a platform specific register) and as
> > a prepration for building u-boot with clang/llvm (with does / will
> > support r9 as reserved register), store the pointer to gd in r9.
>
> If r9 is reserved, I understand that its current usage may conflict with clang's
> but why would gd have to be stored in r9 for clang? Moreover, if r9 is reserved
> for clang (reserved for what?), why can it be used for gd?

Actually, you have to think about this the other way around:

1. In LLVM/clang, r9 can be reserved, i.e., LLVM/clang can be told to
not touch it at all, because it is the AAPCS platform register.

2. Because r9 is the AAPCS platform register, it is the natural choice
for GD.

> I'm also wondering if r9 as initialized by relocate.S is not sometimes used by
> GCC to handle position-independent code within generated code, i.e. like the
> static base feature described for r9 as a possible usage in the ARM EABI AAPCS
> document (5.1.1). If this is the case, changing r9 to gd would break GCC code at
> runtime.

This would be useful when your code gets moved around several times
during its lifetime, which is not a requirement in U-Boot. We get
perfectly working U-Boot relocation without a base register.

> Best regards,
> Beno?t

Amicalement,
--
Albert.