[U-Boot] Relocation confusion

Po-Yu Chuang ratbert.chuang at gmail.com
Thu Apr 23 06:34:08 CEST 2009


Hi Drasko DRASKOVIC,


"adr" is to calculate a runtime address by PC+offset.
"adr r0, _start" is like:
"add r0, pc, #0x80" for example.

e.g. TEXT_BASE == 0x1000 0000 and you are using u-boot to boot from flash.

link address of _start probably equals to 0x1000 0000
the location _armboot_start stores the link address of _start

Therefore,
adr    r0, _start
you probably got r0 == 0.

ldr    r2, _armboot_start
you probably got r2 == 0x1000 0000.

It is just some assembly tricks.


regards

Po-Yu Chuang

2009/4/22 Drasko DRASKOVIC <drasko.draskovic at gmail.com>
>
> Hi all,
> I have some questions regarding start.S code for arm926ejs. Looking at the
> relocation code of u-boot:
>
> relocate:                   /* relocate U-Boot to RAM        */
>    adr    r0, _start            /* r0 <- current position of code   */
>    ldr    r1, _TEXT_BASE        /* test if we run from flash or RAM */
>    cmp     r0, r1          /* don't reloc during debug         */
>    beq     stack_setup
>
>    ldr    r2, _armboot_start
>    ldr    r3, _bss_start
>    sub    r2, r3, r2            /* r2 <- size of armboot            */
>    add    r2, r0, r2            /* r2 <- source end address         */
>
>
> 1) What is exactly difference between _start and _armboot_start ? I can see
> in the same file definition of _armboot_start :
>
> .globl _armboot_start
> _armboot_start:
>    .word _start
>
> So, I am confused there - it looks like they are the same thing.
>
> 2)  Line:
>  sub    r2, r3, r2
> is logical, but after we do :
> add    r2, r0, r2      /* r2 <- source end address         */
> to find source end address. But if _start and _armboot_start are the same,
> we already have this source end address : it is _bss_start.
>
> 3) Based on this, if _armboot_start and _start are not the same thing, I
> could guess that _start is pointing at 0x0 of the flash (or SDRAM), i.e. it
> is uP entry point after reset, and _armboot_start is the place where we
> start to put u-boot instructions (TEXT section). That would mean that we
> either have
> a) some program uP will execute before u-boot. What could that ever be?
> b) some section of u-boot that goes before TEXT section, and will never be
> relocated to RAM _TEXT_BASE. What could that ever be?
>
> Thanks for your answers.
>
> Best regards,
> Drasko DRASKOVIC
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>


More information about the U-Boot mailing list