public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] arm1176: fix relocation
Date: Mon, 25 Oct 2010 08:17:14 +0200	[thread overview]
Message-ID: <4CC520EA.7030705@denx.de> (raw)
In-Reply-To: <20101024200813.26588.91315.stgit@darius-desktop>

Hello Darius,

Darius Augulis wrote:
> Fix relocation code for arm1176, do it like other ARM
> CPU's are doing.
> Tested only with CONFIG_SKIP_RELOCATE_UBOOT defined
> and using nand_spl (booting from nand). Test done on
> s3c6410 based board (not yet supported in main line).
> 
> Signed-off-by: Darius Augulis <augulis.darius@gmail.com>
> ---
>  arch/arm/cpu/arm1176/start.S    |  139 +++++++++++++++++++++++----------------
>  arch/arm/cpu/arm1176/u-boot.lds |   15 +++-
>  2 files changed, 94 insertions(+), 60 deletions(-)

Thanks, some comments below:

> diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
> index 24e5bf4..0d733f7 100644
> --- a/arch/arm/cpu/arm1176/start.S
> +++ b/arch/arm/cpu/arm1176/start.S
[...]
> @@ -288,24 +295,44 @@ copy_loop:
>  	blo	copy_loop
>  
>  #ifndef CONFIG_PRELOADER
> -	/* fix got entries */
> -	ldr	r1, _TEXT_BASE		/* Text base */
> -	mov	r0, r7			/* reloc addr */
> -	ldr	r2, _got_start		/* addr in Flash */
> -	ldr	r3, _got_end		/* addr in Flash */
> -	sub	r3, r3, r1
> -	add	r3, r3, r0
> -	sub	r2, r2, r1
> -	add	r2, r2, r0
> -
> +	/*
> +	 * fix .rel.dyn relocations
> +	 */
> +	ldr	r0, _TEXT_BASE		/* r0 <- Text base */
> +	sub	r9, r7, r0		/* r9 <- relocation offset */
> +	ldr	r10, _dynsym_start_ofs	/* r10 <- sym table ofs */
> +	add	r10, r10, r0		/* r10 <- sym table in FLASH */
> +	ldr	r2, _rel_dyn_start_ofs	/* r2 <- rel dyn start ofs */
> +	add	r2, r2, r0		/* r2 <- rel dyn start in FLASH */
> +	ldr	r3, _rel_dyn_end_ofs	/* r3 <- rel dyn end ofs */
> +	add	r3, r3, r0		/* r3 <- rel dyn end in FLASH */
>  fixloop:
> -	ldr	r4, [r2]
> -	sub	r4, r4, r1
> -	add	r4, r4, r0
> -	str	r4, [r2]
> -	add	r2, r2, #4
> +	ldr	r0, [r2]	/* r0 <- location to fix up, IN FLASH! */
> +	add	r0, r9		/* r0 <- location to fix up in RAM */

should be

add	r0, r0, r9

> +	ldr	r1, [r2, #4]
> +	and	r8, r1, #0xff
> +	cmp	r8, #23		/* relative fixup? */
> +	beq	fixrel
> +	cmp	r8, #2		/* absolute fixup? */
> +	beq	fixabs
> +	/* ignore unknown type of fixup */
> +	b	fixnext
> +fixabs:
> +	/* absolute fix: set location to (offset) symbol value */
> +	mov	r1, r1, LSR #4		/* r1 <- symbol index in .dynsym */
> +	add	r1, r10, r1		/* r1 <- address of symbol in table */
> +	ldr	r1, [r1, #4]		/* r1 <- symbol value */
> +	add	r1, r9			/* r1 <- relocated sym addr */

should be

add r1, r1, r9

> +	b	fixnext
> +fixrel:
> +	/* relative fix: increase location by offset */
> +	ldr	r1, [r0]
> +	add	r1, r1, r9
> +fixnext:
> +	str	r1, [r0]
> +	add	r2, r2, #8	/* each rel.dyn entry is 8 bytes */
>  	cmp	r2, r3
> -	bne	fixloop
> +	ble	fixloop

should be blo instead of blo

>  #endif
>  #endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
>  
[...]

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

      parent reply	other threads:[~2010-10-25  6:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-24 20:08 [U-Boot] [PATCH] arm1176: fix relocation Darius Augulis
2010-10-24 20:22 ` Darius Augulis
2010-10-25  7:11   ` Heiko Schocher
2010-10-25  7:47     ` Darius Augulis
2010-10-25  6:17 ` Heiko Schocher [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CC520EA.7030705@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox