[U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with -msingle-pic-base
Albert ARIBAUD
albert.aribaud at free.fr
Thu Sep 23 19:04:57 CEST 2010
Le 23/09/2010 18:37, Ben Gardiner a écrit :
> On Wed, Sep 22, 2010 at 3:07 PM, Albert ARIBAUD<albert.aribaud at free.fr> wrote:
>> 1) build with your fix in;
>
> $git log --format=oneline|head -n 3
> f619c1537af105cd1471f9447ac9132feab79c3a arm926ejs: reduce code size
> with -msingle-pic-base
> 6285f63589a87dfd28c7d73ff68075c5d1ee7f35 arm: change relocation flag
> from -fPIC to -fPIE
> e69e520f9d235bb7d96296081fdfc09b9fee8c46 fsl: refactor MPC8610 and
> MPC5121 DIU code to use existing bitmap and logo features
>
> $git diff
> diff --git a/arch/arm/cpu/arm926ejs/config.mk b/arch/arm/cpu/arm926ejs/config.mk
> index aa84706..f8ef90f 100644
> --- a/arch/arm/cpu/arm926ejs/config.mk
> +++ b/arch/arm/cpu/arm926ejs/config.mk
> @@ -23,11 +23,6 @@
>
> PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
>
> -ifndef CONFIG_SYS_ARM_WITHOUT_RELOC
> -# needed for optimal relocation
> -PLATFORM_RELFLAGS += -msingle-pic-base
> -endif
> -
> PLATFORM_CPPFLAGS += -march=armv5te
> # =========================================================================
> #
>
> $make mrproper; make da850evm_config; make -j9 all
> [...]
> make[1]: Entering directory `[...]arch/arm/lib'
> arm-none-linux-gnueabi-gcc -g -Os -fPIE -fno-common -ffixed-r8
> -msoft-float -fno-common -ffixed-r8 -msoft-float -D__KERNEL__
> -DTEXT_BASE=0xC1080000 -I[...]/include -fno-builtin -ffreestanding
> -nostdinc -isystem
> /opt/codesourcery-arm-none-eabi-2009q1/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.3/include
> -pipe -DCONFIG_ARM -D__ARM__ -marm -mabi=aapcs-linux
> -mno-thumb-interwork -march=armv5te -march=armv5te -Wall
> -Wstrict-prototypes -fno-stack-protector \
> -o board.o board.c -c
> [...]
>
>> 2) debug (at the assembly instruction level) the start.S code and see what
>> value ends up in r10 (aka sl) right before calling board_init_f;
>
> (gdb) p /x $r10
> $1 = 0xc1098564
> (gdb) p /x $pc
> $2 = 0xc1080088
>
>> 3) proceed (still at the assembly instruction level) until you get within
>> board_init_f. Among the first instructions will be the recomputation of
>> 10/sl; see what value it is assigned;
>
> (gdb) p /x $r10
> $5 = 0xc1098564
> (gdb) p /x $pc
> $6 = 0xc1080694
> (gdb)
>
>> 4) compare values found in 2 and 3 with the value of __got_base in the .map
>> file.
>
> $cat System.map |grep __got_base
> c1098564 A __got_base
>
> I hope that helps.
Well, it confirms that the start.S code computes a correct r10 / sl
register, since it is the same value as board_init_f (and any other
function) computes when -msingle-pic-base is not present, and this value
is that of __got_base.
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.
Now, we need to find out why board_init_f fails to go through the init
sequence and print out at least the banner and some diagnostics.
Please build with my two patches alone (i.e., put -msingle-pic-base back
in place, which will remove the recomputation of the pic base in every
function), and run it until board_init_f() calls its first init function
through (*init_fnc_ptr)(). This call should be materialized by a 'blx
<reg>' instruction; please report the value of <reg> at that point as
well as the addresses of arch_cpu_init, board_early_init_f, and
timer_init; <reg> should be one of these depending on the board config.
> Best Regards,
> Ben Gardiner
Thanks again for your help in testing my patches!
Amicalement,
--
Albert.
More information about the U-Boot
mailing list