[U-Boot] [Patch 1/2] MIPS: fix a latent bug on initialize $gp

Daniel Schwierzeck daniel.schwierzeck at gmail.com
Sun Nov 25 21:30:54 CET 2012


2012/11/24 Zhi-zhou Zhang <zhizhou.zh at gmail.com>:
> If bal is 8 bytes aligned, the _gp will not be 8 bytes aligned.
> then the following ld insntrustion generates a Adel exception.
> So here make _gp be always aligned in 8 bytes.

which toolchain do you use? Actually _gp is aligned to 16 bytes in the
linker script.
Thus the instruction "ld gp, 0(ra)" and the address loaded into gp is
always aligned to 8 bytes.
This works at least with ELDK-5.2.1 and a self-built gcc-4.7.2.

>
> Signed-off-by: Zhi-zhou Zhang <zhizhou.zh at gmail.com>
> ---
>  arch/mips/cpu/mips64/start.S |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/cpu/mips64/start.S b/arch/mips/cpu/mips64/start.S
> index 4112de7..8e8cc33 100644
> --- a/arch/mips/cpu/mips64/start.S
> +++ b/arch/mips/cpu/mips64/start.S
> @@ -108,7 +108,10 @@ reset:
>         mtc0    t0, CP0_CONFIG
>  #endif
>
> -       /* Initialize $gp */
> +       /* Initialize $gp, _gp must be 8 bytes algined. */
> +       .align 3
> +       nop
> +       nop
>         bal     1f
>          nop
>         .dword  _gp
> --
> 1.7.9.5
>

-- 
Best regards,
Daniel


More information about the U-Boot mailing list