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] [RFC] [PATCH V2] arm: arm926ejs: use ELF relocations
Date: Tue, 05 Oct 2010 11:00:57 +0200	[thread overview]
Message-ID: <4CAAE949.1010200@denx.de> (raw)
In-Reply-To: <4CAAE4BF.3030306@free.fr>

Hello Albert,

Albert ARIBAUD wrote:
> Le 05/10/2010 10:33, Heiko Schocher a ?crit :
>> Hello Reinhard,
>>
>> Reinhard Meyer wrote:
>>> I _think_ the linker file needs a .align there:
>>>
>>> (.data ends with a non-aligned address!)
>>
>> actually trying on the tx25 board, and I see a hang after
>> the dram output too:
>>
>> DRAM:  32 MiB
>>
>> I inserted a breakpoint in start.S at clear_bss, never reached...
>>
>> Maybe the fixloop
>>
>> start.S:
>> [...]
>> fixnext:
>>          str     r1, [r0]
>>          add     r2, r2, #8      /* each rel.dyn entry is 8 bytes */
>>          cmp     r2, r3
>>          ble     fixloop
>> #endif
>> #endif  /* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */
>>
>> clear_bss:
>>
>> never reaches a end ... but just debugging it ...
>>
>> register dump in fixloop:
>>
>> TX25>ti;r
>>      Core number       : 0
>>      Core state        : debug mode (ARM)
>>      Debug entry cause : Single Step
>>      Current PC        : 0x812000d8
>>      Current CPSR      : 0x800000d3 (Supervisor)
>> GPR00: 81fbe020 81fbe1a0 81224364 812285cc
>> GPR04: 81ebdf88 81ebdf8c 81fe6ac8 81fbe000
>> GPR08: 00000017 00dbe000 812285cc 00000000
>> GPR12: 00000000 81ebdf88 812006f4 812000d8
>> PC   : 812000d8    CPSR: 800000d3
>> TX25>
>>
>> r2 and r3 are a multiple of 8, so this must end, but never
>> see it ending ...
> 
> Ihe loop exit test is a ble, not a bne, so even if r2 or r3 were not
> properly aligned, this should still exit eventually.

But in my case this looks good.

> A reason why it would not, though, is if the loop trashes the code in
> RAM. That can happen if e.g. TEXT_BASE is wrong (my bad). In two hour's
> time I will build (not test) for tx25 and then do a quick check on the
> content of .rel.dyn and .dynsym in the resulting u-boot.

TX25>ti;r
    Core number       : 0
    Core state        : debug mode (ARM)
    Debug entry cause : Single Step
    Current PC        : 0x812000e4
    Current CPSR      : 0x200000d3 (Supervisor)
GPR00: 81fbe020 00000017 8122435c 812285cc
GPR04: 81ebdf88 81ebdf8c 81fe6ac8 81fbe000
GPR08: 80000f80 00dbe000 812285cc 00000000
GPR12: 00000000 81ebdf88 812006f4 812000e4
PC   : 812000e4    CPSR: 200000d3

Looking at the last entry @812285cc.

TX25>md 0x812285cc
812285cc : 00000000 00000000 00000000 00000000  ................
812285dc : 00000000 81200000 00000000 00010003  ...... .........
812285ec : 0000004f 8122435c 00000000 fff10010  O...\C".........
812285fc : 00000092 812286bc 00000000 fff10010  ......".........
8122860c : 00000028 812242d0 00000000 00060010  (....B".........

now looking what did fixloop with this:

fixloop:
        ldr     r0, [r2]        /* r0 <- location to fix up, IN FLASH! */
        add     r0, r9          /* r0 <- location to fix up in RAM */


so after this r0 would be 0x00dbe000

so, later in code:

fixrel:
        /* relative fix: increase location by offset */
        ldr     r1, [r0]
        add     r1, r1, r9
fixnext:
        str     r1, [r0]

this stores @00dbe000 will fail ... no idea why I have here @812285cc
just 00000000

Hah... with this patch it works:

diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 5a7ae7e..cf3a59f 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -266,7 +266,7 @@ fixnext:
        str     r1, [r0]
        add     r2, r2, #8      /* each rel.dyn entry is 8 bytes */
        cmp     r2, r3
-       ble     fixloop
+       bne     fixloop
 #endif
 #endif /* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */

@@ -297,8 +297,9 @@ clbss_l:str r2, [r0]                /* clear loop...                    */
        ldr     r0, _nand_boot_ofs
        adr     r1, _start
        add     pc, r0, r1
-_nand_boot_ofs
-       : .word nand_boot - _start
+
+_nand_boot_ofs:
+       .word nand_boot - _start
 #else
        ldr     r0, _board_init_r_ofs
        adr     r1, _start

Ok, we could not ignore the last entry ...

Hmm.. any idea why I have such a buggy last entry in __rel_dyn_start ?

(I have to admit, that I didn;t tried to start from nand with nand_spl
code, I just load u-boot with the bdi in ram (such as the nand_spl code
this did ... now I have to try to boot from nand)

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

  reply	other threads:[~2010-10-05  9:00 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-05  6:31 [U-Boot] [RFC] [PATCH V2] arm: arm926ejs: use ELF relocations Albert Aribaud
2010-10-05  6:45 ` Wolfgang Denk
2010-10-05  7:05   ` Reinhard Meyer
2010-10-05  7:23     ` Reinhard Meyer
2010-10-05  7:52       ` Reinhard Meyer
2010-10-05  8:33         ` Heiko Schocher
2010-10-05  8:41           ` Albert ARIBAUD
2010-10-05  9:00             ` Heiko Schocher [this message]
2010-10-05  9:10               ` Reinhard Meyer
2010-10-05  9:15                 ` Heiko Schocher
2010-10-05  9:19                   ` Reinhard Meyer
2010-10-05  9:29                     ` Heiko Schocher
2010-10-05  9:33                       ` Reinhard Meyer
2010-10-05  9:39                         ` Reinhard Meyer
2010-10-05 10:11                           ` Albert ARIBAUD
2010-10-05 10:36                             ` Reinhard Meyer
2010-10-05 10:49                               ` Graeme Russ
2010-10-05 11:01                                 ` Reinhard Meyer
2010-10-05 11:18                                   ` Albert ARIBAUD
2010-10-05 10:33                         ` Albert ARIBAUD
2010-10-05 10:40                           ` Wolfgang Denk
2010-10-05 11:10                             ` Albert ARIBAUD
2010-10-05 11:17                               ` Reinhard Meyer
2010-10-05 11:46                                 ` Albert ARIBAUD
2010-10-05 13:18                                   ` Reinhard Meyer
2010-10-05 13:24                                     ` Graeme Russ
2010-10-05 13:36                                     ` Albert ARIBAUD
2010-10-05 14:06                                       ` Reinhard Meyer
2010-10-05 11:43                               ` Wolfgang Denk
2010-10-05 10:20         ` Albert ARIBAUD
2010-10-05  8:27     ` Wolfgang Denk
2010-10-05  8:38       ` Reinhard Meyer
2010-10-05  8:50         ` Albert ARIBAUD
2010-10-05  8:59           ` Reinhard Meyer
2010-10-05  7:07   ` Wolfgang Denk
2010-10-05  7:40 ` Heiko Schocher
2010-10-05  8:32   ` Albert ARIBAUD
2010-10-05  8:02 ` Wolfgang Denk
2010-10-05  9:25 ` Heiko Schocher
2010-10-05  9:32   ` Albert ARIBAUD
2010-10-05 12:07   ` Heiko Schocher
2010-10-05 12:52 ` Heiko Schocher

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=4CAAE949.1010200@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