[U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with -msingle-pic-base

Albert ARIBAUD
2010-09-23T21:30:56Z

Le 23/09/2010 23:13, Ben Gardiner a ?crit :

> On Thu, Sep 23, 2010 at 1:04 PM, Albert ARIBAUD<albert.aribaud@free.fr> wrote:
>> Note that if I'm not mistaken, your build uses r9 as the pic base, not 10 --
>> this is a possibility, and my patches are written so as to allow either
>> register use.
>
> I don't know for sure so I did a little poking around:
>
> c1080688<board_init_f>:
> c1080688: e59fa118 ldr sl, [pc, #280] ; c10807a8
> <board_init_f+0x120>
> c108068c: e59f8118 ldr r8, [pc, #280] ; c10807ac
> <board_init_f+0x124>
>
> (gdb) info registers
> [...]
> r9 0xc1098564 3238626660
> r10 0xc1098564 3238626660
> [...]
> pc 0xc1080688 0xc1080688<board_init_f>
> [...]
> (gdb) ni
> 514 gd = (gd_t *) (CONFIG_SYS_INIT_SP_ADDR);
> (gdb) info registers
> [...]
> r9 0xc1098564 3238626660
> r10 0x17ecc 97996
> [...]
> pc 0xc108068c 0xc108068c<board_init_f+4>
> [...]
> (gdb) p /x $sl
> $1 = 0x17ecc
> (gdb) p /x $r10
> $2 = 0x17ecc
> (gdb) p /x $r9
> $3 = 0xc1098564
> (gdb) p *0xc10807a8
> $4 = 97996
> (gdb) p /x *0xc10807a8
> $5 = 0x17ecc
>
> I think that confirms that sl == r10 .

Watch out: 'sl' is always 'r10': those are alias names of the register;
I specify both names because depending on the tool you use, you might
see either name. But the pic base, i.e. the register which holds the
address of the GOT, is not necessarily sl! It can can be r10 *or* r9,
depending on the toolchain and options.

Here your excepts show that r9 remains constant (and, I suspect, its
value is the address of the symbol __got_base) while r10 varies; r9 is
the pic base. Which is lucky because r10 is trashed by the loop that
goes through init_sequence and runs each of the functions it points to.

> There is no arch_cpu_init or board_early_init_f; timer_init is at
> 0xc1091e6c. So it is timer_init which is being called above.
>
> The call to timer_init completes successfully; the next function
> pointer dereferenced and called is 0xc1087e04 == env_init. That call
> completes successfully. The next is 0xc10804f8 == init_baudrate; it
> completes successfully. The next call is 0xc108119c == serial_init; it
> completes successfully. The next is 0xc1086550 == console_init_f; it
> completes successfully. The next is 0xc10804d0 == display_banner; it
> completes successfully. They all did.

Ok, so all this goes fine, yet you do not see the banner displayed?

> Execution reaches the call to
> relocate_code and enters; the last instruction I am able to
> single-step is the 'ldr r10, _got_base' in the following lines
> from your patch:

What happens when you single-step through it? Any kind of error message,
or does the target simply not respond any more?

>> Thanks again for your help in testing my patches!
>
> My pleasure. I hope we can get them working on the da850evm.

We certainly will. For me to reproduce your SW setting and build exactly
the same binary as you do, can you confirm that you are again using the
2009q1 toolchain, and indicate the exact command line you use to build
your target?

Amicalement,
--
Albert.