[U-Boot] Trying to understand ARM926EJS/start.S

Albert ARIBAUD
2010-10-30T18:54:28Z

Le 30/10/2010 20:09, Reinhard Meyer a ?crit :

> %%% both yield constants that are in TEXT and can be accessed
> %%% PC relative, right?

Constants, yes; in .text, yes; can be accessed pc-relative, yes, as any
other location in .text actually. But you probably meant "expected to be
accessed PC relative", in which case: yes.

> %%% adr reg, label sets reg to the address of label?
> %%% ldr reg, label sets reg to the content of mem at label?

Correct.

> ldr r2, _TEXT_BASE
> $$$ r2 is overwritten two lines below, right?
> ldr r3, _bss_start_ofs
> add r2, r0, r3 /* r2<- source end address */

Correct.

> ldr r0, _TEXT_BASE /* r0<- Text base */
> %%% why are we using _TEXT_BASE here and not _start?

Because we're accessing the relocation tables in the FLASH (or freshly
NAND-loaded) "source" copy of u-boot, not in the RAM "target" copy (in
which the relocation tables won't exist).

> ldr r3, _TEXT_BASE /* Text base */
> $$$ r3 is not used below this

If it is useless then it can be removed (but would not cause any issue).
Note that it may be used implicitly as the 3rd argument to a C function
call... But I don't think it is, no function called below uses 3
arguments I think.

> mov r4, r7 /* reloc addr */
> %%% why move it to r4? could we not add r7 in the next 2 lines?

We could indeed -- actually, we could probably otimize register usage in
other places too.

> bne clbss_l
> %%% this should better be blo, just in case _end is not aligned?

Correct. I thinought I'd sent a patch to fix all these... Seems I missed
some.

> %%% I cannot see anything here that would prevent BSS being cleared.

Neither do I -- if you think of Alexander's issue, I think it is not
related to BSS initialization.

> Best Regards,
> Reinhard

Amicalement,
--
Albert.