Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Darius Augulis
Hi Albert,

On 11/25/2010 11:45 PM, Albert Aribaud wrote:
 bulk addition of ELF relocation support to ARM cpus
 arm946es, arm720t,arm920t, arm925t, arm_intcm, ixp,
 lh7a40x, s3c44b0, and sa1100.

 Signed-off-by: Albert Aribaudalbert.arib...@free.fr
 ---
   arch/arm/cpu/arm720t/start.S  |  119 +
   arch/arm/cpu/arm720t/u-boot.lds   |   39 +++
   arch/arm/cpu/arm920t/start.S  |  125 ++-
   arch/arm/cpu/arm920t/u-boot.lds   |   38 +++
   arch/arm/cpu/arm925t/start.S  |  127 
 +++-
   arch/arm/cpu/arm925t/u-boot.lds   |   38 +++
   arch/arm/cpu/arm946es/start.S |  123 ++-
   arch/arm/cpu/arm946es/u-boot.lds  |   38 +++
   arch/arm/cpu/arm_intcm/start.S|  127 +++
   arch/arm/cpu/arm_intcm/u-boot.lds |   38 +++
   arch/arm/cpu/ixp/start.S  |  118 +
   arch/arm/cpu/ixp/u-boot.lds   |   38 +++
   arch/arm/cpu/lh7a40x/start.S  |  119 +
   arch/arm/cpu/lh7a40x/u-boot.lds   |   38 +++
   arch/arm/cpu/s3c44b0/start.S  |  131 
 +
   arch/arm/cpu/s3c44b0/u-boot.lds   |   38 +++
   arch/arm/cpu/sa1100/start.S   |  119 +
   arch/arm/cpu/sa1100/u-boot.lds|   38 +++
   18 files changed, 785 insertions(+), 666 deletions(-)


how about arm1136 and arm1176? Perhaps they both have relocation code 
but also they try to use _datarel_* which are not exported by linker 
anymore.
I have my own local patches but I think would be better if you change it 
together with all other cpus.

 diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
 index 8cd267b..46050da 100644
 --- a/arch/arm/cpu/arm720t/start.S
 +++ b/arch/arm/cpu/arm720t/start.S
 @@ -81,14 +81,17 @@ _TEXT_BASE:

   /*
* These are defined in the board-specific linker script.
 + * Subtracting _start from them lets the linker put their
 + * relative position in the executable instead of leaving
 + * them null.
*/
 -.globl _bss_start
 -_bss_start:
 - .word __bss_start
 +.globl _bss_start_ofs
 +_bss_start_ofs:
 + .word __bss_start - _start

 -.globl _bss_end
 -_bss_end:
 - .word _end
 +.globl _bss_end_ofs
 +_bss_end_ofs:
 + .word _end - _start

   #ifdef CONFIG_USE_IRQ
   /* IRQ stack memory (calculated at run-time) */
 @@ -107,30 +110,6 @@ FIQ_STACK_START:
   IRQ_STACK_START_IN:
   .word   0x0badc0de

 -.globl _datarel_start
 -_datarel_start:
 - .word __datarel_start
 -
 -.globl _datarelrolocal_start
 -_datarelrolocal_start:
 - .word __datarelrolocal_start
 -
 -.globl _datarellocal_start
 -_datarellocal_start:
 - .word __datarellocal_start
 -
 -.globl _datarelro_start
 -_datarelro_start:
 - .word __datarelro_start
 -
 -.globl _got_start
 -_got_start:
 - .word __got_start
 -
 -.globl _got_end
 -_got_end:
 - .word __got_end
 -
   /*
* the actual reset code
*/
 @@ -184,9 +163,8 @@ stack_setup:

   adr r0, _start
   ldr r2, _TEXT_BASE
 - ldr r3, _bss_start
 - sub r2, r3, r2  /* r2- size of armboot */
 - add r2, r0, r2  /* r2- source end address  */
 + ldr r3, _bss_start_ofs
 + add r2, r0, r3  /* r2- source end address  */
   cmp r0, r6
   beq clear_bss

 @@ -197,35 +175,53 @@ 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, r0, r9  /* r0- location to fix up in RAM */
 + ldr r1, [r2, #4]
 + and r8, r1, #0xff
 + cmp r8, #23 /* relative fixup? 

Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Albert ARIBAUD
Hi Darius,

Le 26/11/2010 19:04, Darius Augulis a écrit :

 Hi Albert,

 how about arm1136 and arm1176? Perhaps they both have relocation code
 but also they try to use _datarel_* which are not exported by linker
 anymore.

If I am not mistaken, arm1136 and arm1176 are dealt with in v5 of my 
patch http://article.gmane.org/gmane.comp.boot-loaders.u-boot/88966, 
which is already applied to u-boot-arm and will thus be pulled into 
u-boot soon.

 I have my own local patches but I think would be better if you change it
 together with all other cpus.

Please verify my V5 patch and, if your patches are needed above it, 
please post them here to be apllied above mine.

Amicalement,
-- 
Albert.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Darius Augulis
Hi,

On 11/26/2010 08:12 PM, Albert ARIBAUD wrote:
 Hi Darius,

 Le 26/11/2010 19:04, Darius Augulis a écrit :

 Hi Albert,

 how about arm1136 and arm1176? Perhaps they both have relocation code
 but also they try to use _datarel_* which are not exported by linker
 anymore.

 If I am not mistaken, arm1136 and arm1176 are dealt with in v5 of my
 patchhttp://article.gmane.org/gmane.comp.boot-loaders.u-boot/88966,
 which is already applied to u-boot-arm and will thus be pulled into
 u-boot soon.

as I can see only u-boot.lds is changed for arm1176 and start.S isn't.
arm1136 got changed both these files.


 I have my own local patches but I think would be better if you change it
 together with all other cpus.

 Please verify my V5 patch and, if your patches are needed above it,
 please post them here to be apllied above mine.

they are very raw and not ready yet. Not sure when will have time to 
finish it.

Darius.


 Amicalement,

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Albert ARIBAUD
Le 26/11/2010 19:18, Darius Augulis a écrit :
 Hi,

 On 11/26/2010 08:12 PM, Albert ARIBAUD wrote:
 Hi Darius,

 Le 26/11/2010 19:04, Darius Augulis a écrit :

 Hi Albert,

 how about arm1136 and arm1176? Perhaps they both have relocation code
 but also they try to use _datarel_* which are not exported by linker
 anymore.

 If I am not mistaken, arm1136 and arm1176 are dealt with in v5 of my
 patchhttp://article.gmane.org/gmane.comp.boot-loaders.u-boot/88966,
 which is already applied to u-boot-arm and will thus be pulled into
 u-boot soon.

 as I can see only u-boot.lds is changed for arm1176 and start.S isn't.
 arm1136 got changed both these files.

Correct, the arm1176 start.S is only half-fixed for ELF relocations. 
I'll post a bugfix right away.

 I have my own local patches but I think would be better if you change it
 together with all other cpus.

 Please verify my V5 patch and, if your patches are needed above it,
 please post them here to be apllied above mine.

 they are very raw and not ready yet. Not sure when will have time to
 finish it.

What do they add beside the fix to arm1136/1176 ?

Amicalement,
-- 
Albert.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Darius Augulis
On 11/26/2010 08:34 PM, Albert ARIBAUD wrote:
 Le 26/11/2010 19:18, Darius Augulis a écrit :
 Hi,

 On 11/26/2010 08:12 PM, Albert ARIBAUD wrote:
 Hi Darius,

 Le 26/11/2010 19:04, Darius Augulis a écrit :

 Hi Albert,

 how about arm1136 and arm1176? Perhaps they both have relocation code
 but also they try to use _datarel_* which are not exported by linker
 anymore.

 If I am not mistaken, arm1136 and arm1176 are dealt with in v5 of my
 patchhttp://article.gmane.org/gmane.comp.boot-loaders.u-boot/88966,
 which is already applied to u-boot-arm and will thus be pulled into
 u-boot soon.

 as I can see only u-boot.lds is changed for arm1176 and start.S isn't.
 arm1136 got changed both these files.

 Correct, the arm1176 start.S is only half-fixed for ELF relocations.
 I'll post a bugfix right away.

 I have my own local patches but I think would be better if you
 change it
 together with all other cpus.

 Please verify my V5 patch and, if your patches are needed above it,
 please post them here to be apllied above mine.

 they are very raw and not ready yet. Not sure when will have time to
 finish it.

 What do they add beside the fix to arm1136/1176 ?

actually it's not a separate patch but merged into other big patch which 
adds support for mini6410 board. I will resolve my local conflicts after 
pulling your bugfix.

Darius.


 Amicalement,

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-26 Thread Wolfgang Denk
Dear Albert Aribaud,

In message 1290721502-410-1-git-send-email-albert.arib...@free.fr you wrote:
 bulk addition of ELF relocation support to ARM cpus
 arm946es, arm720t,arm920t, arm925t, arm_intcm, ixp,
 lh7a40x, s3c44b0, and sa1100.
 
 Signed-off-by: Albert Aribaud albert.arib...@free.fr
 ---
  arch/arm/cpu/arm720t/start.S  |  119 +
  arch/arm/cpu/arm720t/u-boot.lds   |   39 +++
  arch/arm/cpu/arm920t/start.S  |  125 ++-
  arch/arm/cpu/arm920t/u-boot.lds   |   38 +++
  arch/arm/cpu/arm925t/start.S  |  127 +++-
  arch/arm/cpu/arm925t/u-boot.lds   |   38 +++
  arch/arm/cpu/arm946es/start.S |  123 ++-
  arch/arm/cpu/arm946es/u-boot.lds  |   38 +++
  arch/arm/cpu/arm_intcm/start.S|  127 +++
  arch/arm/cpu/arm_intcm/u-boot.lds |   38 +++
  arch/arm/cpu/ixp/start.S  |  118 +
  arch/arm/cpu/ixp/u-boot.lds   |   38 +++
  arch/arm/cpu/lh7a40x/start.S  |  119 +
  arch/arm/cpu/lh7a40x/u-boot.lds   |   38 +++
  arch/arm/cpu/s3c44b0/start.S  |  131 
 +
  arch/arm/cpu/s3c44b0/u-boot.lds   |   38 +++
  arch/arm/cpu/sa1100/start.S   |  119 +
  arch/arm/cpu/sa1100/u-boot.lds|   38 +++
  18 files changed, 785 insertions(+), 666 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH, MD: Wolfgang Denk  Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
On our campus the UNIX system has proved to be not only an  effective
software tool, but an agent of technical and social change within the
University.  - John Lions (U. of Toronto (?))
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] arm: add ELF relocation support to rest of cpus

2010-11-25 Thread Albert Aribaud
bulk addition of ELF relocation support to ARM cpus
arm946es, arm720t,arm920t, arm925t, arm_intcm, ixp,
lh7a40x, s3c44b0, and sa1100.

Signed-off-by: Albert Aribaud albert.arib...@free.fr
---
 arch/arm/cpu/arm720t/start.S  |  119 +
 arch/arm/cpu/arm720t/u-boot.lds   |   39 +++
 arch/arm/cpu/arm920t/start.S  |  125 ++-
 arch/arm/cpu/arm920t/u-boot.lds   |   38 +++
 arch/arm/cpu/arm925t/start.S  |  127 +++-
 arch/arm/cpu/arm925t/u-boot.lds   |   38 +++
 arch/arm/cpu/arm946es/start.S |  123 ++-
 arch/arm/cpu/arm946es/u-boot.lds  |   38 +++
 arch/arm/cpu/arm_intcm/start.S|  127 +++
 arch/arm/cpu/arm_intcm/u-boot.lds |   38 +++
 arch/arm/cpu/ixp/start.S  |  118 +
 arch/arm/cpu/ixp/u-boot.lds   |   38 +++
 arch/arm/cpu/lh7a40x/start.S  |  119 +
 arch/arm/cpu/lh7a40x/u-boot.lds   |   38 +++
 arch/arm/cpu/s3c44b0/start.S  |  131 +
 arch/arm/cpu/s3c44b0/u-boot.lds   |   38 +++
 arch/arm/cpu/sa1100/start.S   |  119 +
 arch/arm/cpu/sa1100/u-boot.lds|   38 +++
 18 files changed, 785 insertions(+), 666 deletions(-)

diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
index 8cd267b..46050da 100644
--- a/arch/arm/cpu/arm720t/start.S
+++ b/arch/arm/cpu/arm720t/start.S
@@ -81,14 +81,17 @@ _TEXT_BASE:
 
 /*
  * These are defined in the board-specific linker script.
+ * Subtracting _start from them lets the linker put their
+ * relative position in the executable instead of leaving
+ * them null.
  */
-.globl _bss_start
-_bss_start:
-   .word __bss_start
+.globl _bss_start_ofs
+_bss_start_ofs:
+   .word __bss_start - _start
 
-.globl _bss_end
-_bss_end:
-   .word _end
+.globl _bss_end_ofs
+_bss_end_ofs:
+   .word _end - _start
 
 #ifdef CONFIG_USE_IRQ
 /* IRQ stack memory (calculated at run-time) */
@@ -107,30 +110,6 @@ FIQ_STACK_START:
 IRQ_STACK_START_IN:
.word   0x0badc0de
 
-.globl _datarel_start
-_datarel_start:
-   .word __datarel_start
-
-.globl _datarelrolocal_start
-_datarelrolocal_start:
-   .word __datarelrolocal_start
-
-.globl _datarellocal_start
-_datarellocal_start:
-   .word __datarellocal_start
-
-.globl _datarelro_start
-_datarelro_start:
-   .word __datarelro_start
-
-.globl _got_start
-_got_start:
-   .word __got_start
-
-.globl _got_end
-_got_end:
-   .word __got_end
-
 /*
  * the actual reset code
  */
@@ -184,9 +163,8 @@ stack_setup:
 
adr r0, _start
ldr r2, _TEXT_BASE
-   ldr r3, _bss_start
-   sub r2, r3, r2  /* r2 - size of armboot*/
-   add r2, r0, r2  /* r2 - source end address */
+   ldr r3, _bss_start_ofs
+   add r2, r0, r3  /* r2 - source end address */
cmp r0, r6
beq clear_bss
 
@@ -197,35 +175,53 @@ 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, r0, r9  /* r0 - location to fix up in RAM */
+   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