Factorize ARM relocation code
Subsystems (2)
cover Factorize ARM relocation code
This is V1 of the ARM relocation code factorization patch series.
Albert ARIBAUD (4):
Rename arch/arm/lib/bss.c to sections.c
arm: make __image_copy_{start,end} compiler-generated
arm: make relocation section symbols compiler-generated
arm: factorize relocate_code routine
arch/arm/cpu/arm1136/start.S | 83 --------------------
arch/arm/cpu/arm1136/u-boot-spl.lds | 3 +-
arch/arm/cpu/arm1176/start.S | 75 ------------------
arch/arm/cpu/arm720t/start.S | 79 -------------------
arch/arm/cpu/arm920t/ep93xx/u-boot.lds | 6 +-
arch/arm/cpu/arm920t/start.S | 75 ------------------
arch/arm/cpu/arm925t/start.S | 75 ------------------
arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds | 15 +++-
arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds | 15 +++-
arch/arm/cpu/arm926ejs/start.S | 83 --------------------
arch/arm/cpu/arm946es/start.S | 75 ------------------
arch/arm/cpu/arm_intcm/start.S | 75 ------------------
arch/arm/cpu/armv7/am33xx/u-boot-spl.lds | 2 -
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds | 2 -
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 1 -
arch/arm/cpu/armv7/start.S | 80 -------------------
arch/arm/cpu/ixp/start.S | 75 ------------------
arch/arm/cpu/ixp/u-boot.lds | 24 ++++--
arch/arm/cpu/pxa/start.S | 84 --------------------
arch/arm/cpu/s3c44b0/start.S | 75 ------------------
arch/arm/cpu/sa1100/start.S | 75 ------------------
arch/arm/cpu/u-boot-spl.lds | 21 +++--
arch/arm/cpu/u-boot.lds | 25 ++++--
arch/arm/lib/Makefile | 4 +-
arch/arm/lib/relocate.S | 100 ++++++++++++++++++++++++
arch/arm/lib/{bss.c => sections.c} | 7 +-
board/actux1/u-boot.lds | 18 ++++-
board/actux2/u-boot.lds | 18 ++++-
board/actux3/u-boot.lds | 19 ++++-
board/ait/cam_enc_4xx/u-boot-spl.lds | 16 +++-
board/davinci/da8xxevm/u-boot-spl-da850evm.lds | 16 +++-
board/dvlhost/u-boot.lds | 18 ++++-
board/freescale/mx31ads/u-boot.lds | 18 ++++-
board/vpac270/u-boot-spl.lds | 18 ++++-
34 files changed, 303 insertions(+), 1072 deletions(-)
create mode 100644 arch/arm/lib/relocate.S
rename arch/arm/lib/{bss.c => sections.c} (78%)Signature · 1 line
1.7.10.4
PATCH 1/4 Rename arch/arm/lib/bss.c to sections.c
This file will contain symbols other than the BSS
start and stop, so rename it for better accuracy.
---
arch/arm/lib/Makefile | 2 +-
arch/arm/lib/{bss.c => sections.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename arch/arm/lib/{bss.c => sections.c} (100%)arch/arm/lib/Makefile +1 -1
@@ -42,7 +42,7 @@ ifndef CONFIG_SPL_BUILD ifndef CONFIG_SYS_GENERIC_BOARD COBJS-y += board.o endif -COBJS-y += bss.o +COBJS-y += sections.o COBJS-y += bootm.o COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
arch/arm/lib/sections.c renamed from arch/arm/lib/bss.c +0 -0
Signature · 1 line
1.7.10.4
PATCH 2/4 arm: make __image_copy_{start, end} compiler-generated
--- arch/arm/cpu/arm1136/start.S | 7 +++---- arch/arm/cpu/arm1136/u-boot-spl.lds | 3 ++- arch/arm/cpu/arm720t/start.S | 11 +++++++---- arch/arm/cpu/arm920t/ep93xx/u-boot.lds | 6 +++++- arch/arm/cpu/arm926ejs/start.S | 7 +++---- arch/arm/cpu/armv7/am33xx/u-boot-spl.lds | 2 -- arch/arm/cpu/armv7/omap-common/u-boot-spl.lds | 2 -- arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 1 - arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/u-boot.lds | 6 +++++- arch/arm/cpu/u-boot-spl.lds | 3 +-- arch/arm/cpu/u-boot.lds | 7 +++++-- arch/arm/lib/sections.c | 4 +++- 13 files changed, 36 insertions(+), 29 deletions(-)
arch/arm/cpu/arm1136/start.S +3 -4
@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -239,6 +235,9 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start + #ifndef CONFIG_SPL_BUILD _rel_dyn_start_ofs:
arch/arm/cpu/arm1136/u-boot-spl.lds +2 -1
@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/arm1136/start.o (.text*) *(.text*) } >.sram
@@ -48,7 +47,9 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + __image_copy_end = .; + _end = .; .bss :
arch/arm/cpu/arm720t/start.S +7 -4
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -221,6 +217,11 @@ relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start + +#ifndef CONFIG_SPL_BUILD + _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +229,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm920t/ep93xx/u-boot.lds +5 -1
@@ -31,6 +31,7 @@ SECTIONS . = ALIGN(4); .text : { + *(.__image_copy_start) arch/arm/cpu/arm920t/start.o (.text*) /* the EP93xx expects to find the pattern 'CRUS' at 0x1000 */ . = 0x1000;
@@ -56,7 +57,10 @@ SECTIONS . = ALIGN(4); - __image_copy_end = .; + .image_copy_end : + { + *(.__image_copy_end); + } __bss_start = .; .bss : { *(.bss*) }
arch/arm/cpu/arm926ejs/start.S +3 -4
@@ -136,10 +136,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -256,6 +252,9 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start + #ifndef CONFIG_SPL_BUILD _rel_dyn_start_ofs:
arch/arm/cpu/armv7/am33xx/u-boot-spl.lds +0 -2
@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/armv7/start.o (.text) *(.text*) } >.sram
@@ -53,7 +52,6 @@ SECTIONS } >.sram . = ALIGN(4); - __image_copy_end = .; _end = .; .bss :
arch/arm/cpu/armv7/omap-common/u-boot-spl.lds +0 -2
@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/armv7/start.o (.text*) *(.text*) } >.sram
@@ -49,7 +48,6 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); - __image_copy_end = .; _end = .; .bss :
arch/arm/cpu/armv7/socfpga/u-boot-spl.lds +0 -1
@@ -38,7 +38,6 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sdram . = ALIGN(4); - __image_copy_end = .; _end = .; .bss : {
arch/arm/cpu/armv7/start.S +2 -4
@@ -94,10 +94,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -231,6 +227,8 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/ixp/u-boot.lds +5 -1
@@ -31,6 +31,7 @@ SECTIONS . = ALIGN(4); .text : { + *(.__image_copy_start) arch/arm/cpu/ixp/start.o(.text*) *(.text*) }
@@ -54,7 +55,10 @@ SECTIONS . = ALIGN(4); - __image_copy_end = .; + .image_copy_end : + { + *(.__image_copy_end); + } .rel.dyn : { __rel_dyn_start = .;
arch/arm/cpu/u-boot-spl.lds +1 -2
@@ -33,7 +33,6 @@ SECTIONS . = ALIGN(4); .text : { - __image_copy_start = .; CPUDIR/start.o (.text*) *(.text*) }
@@ -80,7 +79,7 @@ SECTIONS } #if defined(CONFIG_SPL_MAX_SIZE) -ASSERT(__image_copy_end - __image_copy_start < (CONFIG_SPL_MAX_SIZE), \ +ASSERT(__image_copy_end - _start < (CONFIG_SPL_MAX_SIZE), \ "SPL image too big"); #endif
arch/arm/cpu/u-boot.lds +5 -2
@@ -33,7 +33,7 @@ SECTIONS . = ALIGN(4); .text : { - __image_copy_start = .; + *(.__image_copy_start) CPUDIR/start.o (.text*) *(.text*) }
@@ -57,7 +57,10 @@ SECTIONS . = ALIGN(4); - __image_copy_end = .; + .image_copy_end : + { + *(.__image_copy_end); + } .rel.dyn : { __rel_dyn_start = .;
arch/arm/lib/sections.c +3 -1
@@ -21,7 +21,7 @@*/ /** -* These two symbols are declared in a C file so that the linker +* The following symbols are declared in a C file so that the linker * uses R_ARM_RELATIVE relocation, rather than the R_ARM_ABS32 one * it would use if the symbols were defined in the linker file. * Using only R_ARM_RELATIVE relocation ensures that references to
@@ -37,3 +37,5 @@ char __bss_start[0] __attribute__((used, section(".__bss_start"))); char __bss_end[0] __attribute__((used, section(".__bss_end"))); +char __image_copy_start[0] __attribute__((used, section(".__image_copy_start"))); +char __image_copy_end[0] __attribute__((used, section(".__image_copy_end")));
Signature · 1 line
1.7.10.4
PATCH 3/4 arm: make relocation section symbols compiler-generated
--- arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds | 15 ++++++++++++--- arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds | 15 ++++++++++++--- arch/arm/cpu/ixp/u-boot.lds | 18 ++++++++++++++---- arch/arm/cpu/u-boot-spl.lds | 18 ++++++++++++++---- arch/arm/cpu/u-boot.lds | 18 ++++++++++++++---- arch/arm/lib/sections.c | 3 +++ board/actux1/u-boot.lds | 18 ++++++++++++++---- board/actux2/u-boot.lds | 18 ++++++++++++++---- board/actux3/u-boot.lds | 19 +++++++++++++++---- board/ait/cam_enc_4xx/u-boot-spl.lds | 16 +++++++++++++--- board/davinci/da8xxevm/u-boot-spl-da850evm.lds | 16 +++++++++++++--- board/dvlhost/u-boot.lds | 18 ++++++++++++++---- board/freescale/mx31ads/u-boot.lds | 18 ++++++++++++++---- board/vpac270/u-boot-spl.lds | 18 ++++++++++++++---- 14 files changed, 180 insertions(+), 48 deletions(-)
arch/arm/cpu/arm926ejs/mxs/u-boot-spl.lds +12 -3
@@ -51,14 +51,23 @@ SECTIONS . = ALIGN(4); + .rel_dyn_start : { + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
arch/arm/cpu/arm926ejs/spear/u-boot-spl.lds +12 -3
@@ -51,14 +51,23 @@ SECTIONS . = ALIGN(4); + .rel_dyn_start : { + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
arch/arm/cpu/ixp/u-boot.lds +14 -4
@@ -60,14 +60,24 @@ SECTIONS *(.__image_copy_end); } + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -78,7 +88,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
arch/arm/cpu/u-boot-spl.lds +14 -4
@@ -51,20 +51,30 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) } _end = .; - .bss __rel_dyn_start (OVERLAY) : { + .bss __rel_dyn_base (OVERLAY) : { __bss_start = .; *(.bss*) . = ALIGN(4);
arch/arm/cpu/u-boot.lds +14 -4
@@ -62,14 +62,24 @@ SECTIONS *(.__image_copy_end); } + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -89,7 +99,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
arch/arm/lib/sections.c +3 -0
@@ -39,3 +39,6 @@ char __bss_start[0] __attribute__((used, section(".__bss_start"))); char __bss_end[0] __attribute__((used, section(".__bss_end"))); char __image_copy_start[0] __attribute__((used, section(".__image_copy_start"))); char __image_copy_end[0] __attribute__((used, section(".__image_copy_end"))); +char __rel_dyn_start[0] __attribute__((used, section(".__rel_dyn_start"))); +char __rel_dyn_end[0] __attribute__((used, section(".__rel_dyn_end"))); +char __dynsym_start[0] __attribute__((used, section(".__dynsym_start")));
board/actux1/u-boot.lds +14 -4
@@ -64,14 +64,24 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -82,7 +92,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
board/actux2/u-boot.lds +14 -4
@@ -64,14 +64,24 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -82,7 +92,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
board/actux3/u-boot.lds +15 -4
@@ -64,14 +64,25 @@ SECTIONS __image_copy_end = .; + + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -82,7 +93,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
board/ait/cam_enc_4xx/u-boot-spl.lds +13 -3
@@ -48,14 +48,24 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + + .rel_dyn_start : { + *(.__rel_dyn_start); + } >.sram + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } >.sram + + .rel_dyn_end : { + *(.__rel_dyn_end); + } >.sram + + .dynsym_start : { + *(.__dynsym_start); } >.sram .dynsym : { - __dynsym_start = .; *(.dynsym) } >.sram
board/davinci/da8xxevm/u-boot-spl-da850evm.lds +13 -3
@@ -49,14 +49,24 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + + .rel_dyn_start : { + *(.__rel_dyn_start); + } >.sram + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } >.sram + + .rel_dyn_end : { + *(.__rel_dyn_end); + } >.sram + + .dynsym_start : { + *(.__dynsym_start); } >.sram .dynsym : { - __dynsym_start = .; *(.dynsym) } >.sram
board/dvlhost/u-boot.lds +14 -4
@@ -64,14 +64,24 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -82,7 +92,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
board/freescale/mx31ads/u-boot.lds +14 -4
@@ -67,14 +67,24 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -85,7 +95,7 @@ SECTIONS * __bss_base and __bss_limit are for linker only (overlay ordering) */ - .bss_start __rel_dyn_start (OVERLAY) : { + .bss_start __rel_dyn_base (OVERLAY) : { KEEP(*(.__bss_start)); __bss_base = .; }
board/vpac270/u-boot-spl.lds +14 -4
@@ -61,14 +61,24 @@ SECTIONS __image_copy_end = .; + .rel_dyn_start : { + __rel_dyn_base = .; + *(.__rel_dyn_start); + } + .rel.dyn : { - __rel_dyn_start = .; *(.rel*) - __rel_dyn_end = .; + } + + .rel_dyn_end : { + *(.__rel_dyn_end); + } + + .dynsym_start : { + *(.__dynsym_start); } .dynsym : { - __dynsym_start = .; *(.dynsym) }
@@ -76,7 +86,7 @@ SECTIONS _end = .; - .bss __rel_dyn_start (OVERLAY) : { + .bss __rel_dyn_base (OVERLAY) : { __bss_start = .; *(.bss*) . = ALIGN(4);
Signature · 1 line
1.7.10.4
PATCH 4/4 arm: factorize relocate_code routine
--- arch/arm/cpu/arm1136/start.S | 82 -------------------------------- arch/arm/cpu/arm1176/start.S | 75 ------------------------------ arch/arm/cpu/arm720t/start.S | 82 -------------------------------- arch/arm/cpu/arm920t/start.S | 75 ------------------------------ arch/arm/cpu/arm925t/start.S | 75 ------------------------------ arch/arm/cpu/arm926ejs/start.S | 82 -------------------------------- arch/arm/cpu/arm946es/start.S | 75 ------------------------------ arch/arm/cpu/arm_intcm/start.S | 75 ------------------------------ arch/arm/cpu/armv7/start.S | 78 ------------------------------- arch/arm/cpu/ixp/start.S | 75 ------------------------------ arch/arm/cpu/pxa/start.S | 84 --------------------------------- arch/arm/cpu/s3c44b0/start.S | 75 ------------------------------ arch/arm/cpu/sa1100/start.S | 75 ------------------------------ arch/arm/lib/Makefile | 2 +- arch/arm/lib/relocate.S | 100 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 101 insertions(+), 1009 deletions(-) create mode 100644 arch/arm/lib/relocate.S
arch/arm/cpu/arm1136/start.S +0 -82
@@ -167,88 +167,6 @@ next: bl _main -/*------------------------------------------------------------------------------*/ - -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop -#endif - -relocate_done: - - bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start - -#ifndef CONFIG_SPL_BUILD - -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif - .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm1176/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm720t/start.S +0 -82
88 lines not on this page · raw message
arch/arm/cpu/arm920t/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm925t/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm926ejs/start.S +0 -82
88 lines not on this page · raw message
arch/arm/cpu/arm946es/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm_intcm/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +0 -78
84 lines not on this page · raw message
arch/arm/cpu/ixp/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/pxa/start.S +0 -84
90 lines not on this page · raw message
arch/arm/cpu/s3c44b0/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/sa1100/start.S +0 -75
81 lines not on this page · raw message
arch/arm/lib/Makefile +1 -1
@@ -36,7 +36,7 @@ GLSOBJS += _umodsi3.o GLCOBJS += div0.o -SOBJS-y += crt0.o +SOBJS-y += crt0.o relocate.o ifndef CONFIG_SPL_BUILD ifndef CONFIG_SYS_GENERIC_BOARD
arch/arm/lib/relocate.S new file +100 -0
100 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v4 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 21 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>--- arch/arm/cpu/arm1136/start.S | 82 -------------------------------- arch/arm/cpu/arm1176/start.S | 75 ------------------------------ arch/arm/cpu/arm720t/start.S | 82 -------------------------------- arch/arm/cpu/arm920t/start.S | 75 ------------------------------ arch/arm/cpu/arm925t/start.S | 75 ------------------------------ arch/arm/cpu/arm926ejs/start.S | 82 -------------------------------- arch/arm/cpu/arm946es/start.S | 75 ------------------------------ arch/arm/cpu/arm_intcm/start.S | 75 ------------------------------ arch/arm/cpu/armv7/start.S | 78 ------------------------------- arch/arm/cpu/ixp/start.S | 75 ------------------------------ arch/arm/cpu/pxa/start.S | 84 --------------------------------- arch/arm/cpu/s3c44b0/start.S | 75 ------------------------------ arch/arm/cpu/sa1100/start.S | 75 ------------------------------ arch/arm/lib/Makefile | 2 +- arch/arm/lib/relocate.S | 100 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 101 insertions(+), 1009 deletions(-) create mode 100644 arch/arm/lib/relocate.S
[...]
Quoted 15 lines
arch/arm/cpu/pxa/start.S +0
-7@@ -170,90 +170,6 @@ reset: bl _main -/*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */
arch/arm/cpu/pxa/start.S reset: · line 189
Quoted 10 lines
arch/arm/cpu/pxa/start.S +0
-10- .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - -/* Disable the Dcache RAM lock for stack now */ -#ifdef CONFIG_CPU_PXA25X - mov r12, lr - bl cpu_init_crit - mov lr, r12 -#endif
What about this thing that you silently drop?
Quoted 70 lines
arch/arm/cpu/pxa/start.S +0
-67- - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - -#ifndef CONFIG_SPL_BUILD - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop -#endif - -relocate_done: - - bx lr - -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif - .globl c_runtime_cpu_setup c_runtime_cpu_setup:
[...]
Quoted 32 lines
arch/arm/lib/relocate.S new file +26
-0@@ -0,0 +1,100 @@ +/* + * relocate - common relocation function for ARM U-Boot + * + * Copyright (c) 2013 Albert ARIBAUD <[email protected]> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * These are defined in the board-specific linker script.
arch/arm/lib/relocate.S line 36
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ * Subtracting _start from them lets the linker put their + * relative position in the executable instead of leaving + * them null. + */ + + .globl __image_copy_start + .globl __image_copy_end + .globl __rel_dyn_start + .globl __rel_dyn_end + .globl __dynsym_start
.globl is for exporting symbols to the linker, not importing, so the lines above should be removed.
arch/arm/lib/relocate.S line 46
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ +/*------------------------------------------------------------------------------*/ + +/* + * void relocate_code(addr_moni) + * + * This function relocates the monitor code. + */ + .globl relocate_code +relocate_code:
Or "ENTRY(relocate_code)" instead of the two lines above.
arch/arm/lib/relocate.S line 49
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ mov r6, r0 /* save addr of destination */ + + ldr r0, =_start
This is wrong. Here, r0 will get _start link-time address, while with 'adr' in the original code, r0 was getting _start runtime address, which is not the same for all boards. relocate_code() is and must stay position-independent code, at least for SPL.
E.g., for mx31pdk or tx25, the SPL is first loaded by the boot ROM in the NAND Flash controller buffer, then executed from there. The SPL then has to use relocate_code() to relocate itself to CONFIG_SPL_TEXT_BASE in order to free the NFC buffer to load U-Boot from NAND Flash. This means that 'ldr r0, =_start' would set r0 to CONFIG_SPL_TEXT_BASE, while 'adr r0, _start' sets r0 to the address of the NFC buffer. Since the SPL calls relocate_code() with CONFIG_SPL_TEXT_BASE, the 'ldr' choice would just result in a branch to relocate_done below, which would abort the relocation and break the boot on those boards.
The issue is that 'adr' requires that _start be defined in the same file and section. That's why my patch 31/31 was using a macro to define relocate_code() in the start.S files. Perhaps some other constructs like
'sub r0, pc, . - _start' would work, but I doubt it if _start is not in the same file and section since this is exactly how 'adr' is translated.
Quoted 6 lines
arch/arm/lib/relocate.S new file +6
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy_loop */ + ldr r2, =__image_copy_end + +copy_loop:
arch/arm/lib/relocate.S line 65
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ ldmia r0!, {r10-r11} /* copy from source address [r0] */ + stmia r1!, {r10-r11} /* copy to target address [r1] */ + cmp r0, r2 /* until source end address [r2] */ + blo copy_loop + +#ifndef CONFIG_SPL_BUILD + /* + * fix .rel.dyn relocations + */ + ldr r0, =_TEXT_BASE /* r0 <- Text base */
The value you load above into r0 then gets overwritten prior to having been used, so you can drop this line, all the more it is wrong, loading the address of _TEXT_BASE instead of its value.
arch/arm/lib/relocate.S line 68
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ ldr r10, =__dynsym_start /* r10 <- sym table ofs */ + ldr r2, =__rel_dyn_start /* r2 <- rel dyn start ofs */ + ldr r3, =__rel_dyn_end /* r3 <- rel dyn end ofs */
'ofs' should be replaced with 'in FLASH' in the comments above.
Contrary to above, this construct works here because this can't be SPL code.
Quoted 22 lines
arch/arm/lib/relocate.S new file +22
-0+fixloop: + 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 r7, r1, #0xff + cmp r7, #23 /* relative fixup? */ + beq fixrel + cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ + b fixnext +fixrel: + /* relative fix: increase location by offset */ + ldr r1, [r0] + add r1, r1, r9
arch/arm/lib/relocate.S line 100
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+fixnext: + str r1, [r0] + add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ + cmp r2, r3 + blo fixloop +#endif + +relocate_done: + + bx lr
This instruction is not supported on ARMv4, even if GCC does not complain about it (it looks like this is not even fixed by the linker, except if the instruction was issued by GCC itself), but it is required for more recent ARM versions for Thumb inter-working, which is enabled by some boards in U-Boot. Hence, shouldn't the line above be replaced with:
#ifdef __ARM_ARCH_4__
mov pc, lr
#else
bx lr
#endif
Or using CONFIG_SYS_THUMB_BUILD?
"ENDPROC(relocate_code)" should be added here if you go for ENTRY() at the beginning.
Best regards,
Beno?t
PATCH 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 24 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 21 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>arch/arm/cpu/pxa/start.S +0
-11@@ -170,90 +170,6 @@ reset: bl _main -/*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ -
Quoted 8 lines
arch/arm/cpu/pxa/start.S reset: · line 189
Quoted 6 lines
arch/arm/cpu/pxa/start.S +0
-6-/* Disable the Dcache RAM lock for stack now */ -#ifdef CONFIG_CPU_PXA25X - mov r12, lr - bl cpu_init_crit - mov lr, r12 -#endifWhat about this thing that you silently drop?
Overlook on my side, and PXA is not one of my test vehicles so I missed it while testing. Will 'undrop' in V2.
Quoted 37 lines
Quoted 37 lines
arch/arm/lib/relocate.S new file +31
-0@@ -0,0 +1,100 @@ +/* + * relocate - common relocation function for ARM U-Boot + * + * Copyright (c) 2013 Albert ARIBAUD <[email protected]> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +/* + * 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. + */ +
Quoted 8 lines
arch/arm/lib/relocate.S line 36
Quoted 5 lines
arch/arm/lib/relocate.S new file +5
-0+ .globl __image_copy_start + .globl __image_copy_end + .globl __rel_dyn_start + .globl __rel_dyn_end + .globl __dynsym_start.globl is for exporting symbols to the linker, not importing, so the lines above should be removed.
correct. Will drop in V2.
Quoted 4 lines
Quoted 4 lines
arch/arm/lib/relocate.S new file +4
-0+ +/*------------------------------------------------------------------------------*/ + +/*
Quoted 8 lines
arch/arm/lib/relocate.S line 46
Quoted 6 lines
arch/arm/lib/relocate.S new file +6
-0+ * void relocate_code(addr_moni) + * + * This function relocates the monitor code. + */ + .globl relocate_code +relocate_code:Or "
ENTRY(relocate_code)" instead of the two lines above.
I'd gone for just moving code around rather than cosmetic, but I can do the cosmetic change at the end of the patch too.
Quoted 10 lines
arch/arm/lib/relocate.S line 49
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ mov r6, r0 /* save addr of destination */ + + ldr r0, =_startThis is wrong. Here, r0 will get
_startlink-time address, while with 'adr' in the original code, r0 was getting_startruntime address, which is not the same for all boards.relocate_code()is and must stay position-independent code, at least for SPL.E.g., for mx31pdk or tx25, the SPL is first loaded by the boot ROM
in the NAND
Quoted 9 lines
Flash controller buffer, then executed from there. The SPL then has to use
relocate_code()to relocate itself toCONFIG_SPL_TEXT_BASEin order to free the NFC buffer to load U-Boot from NAND Flash. This means that 'ldr r0, =_start' would set r0 toCONFIG_SPL_TEXT_BASE, while 'adr r0,_start' sets r0 to the address of the NFC buffer. Since the SPL callsrelocate_code()withCONFIG_SPL_TEXT_BASE, the 'ldr' choice would just result in a branch torelocate_donebelow, which would abort the relocation and break the boot on those boards.
Quoted 5 lines
The issue is that 'adr' requires that
_startbe defined in the same file and section. That's why my patch 31/31 was using a macro to definerelocate_code()in thestart.Sfiles. Perhaps some other constructs like
'sub r0, pc, . -_start' would work, but I doubt it if_startis not in the same file and section since this is exactly how 'adr' is translated.
Alright, so -- formally, there is no assumption that code running before relocation must be position-independent, as far as I remember. The assumption is that it is designed to run at the link-time location, and that it is responsible for making sure that the rest of the code is properly relocated and thus will run at whatever location it was moved to.
In the case you mention, SPL does not relocate itself: it only *moves* itself, skipping the actual relocation (reference fixing part) -- it could havdoe so with a short ad hoc loop instead of relocate_code, and thus not impose a specific requirement on relocate_code that was not initially there. I'd be happier with a preprocessor conditional at the crt0.S stage to choose between relocate_code and a new, short, move_code routine depending on whether we are building SPL or not.
That being said, I am fine with trying to make the code before relocation as position-independent as possible anyway; let me see how this can be done.
Quoted 12 lines
Quoted 12 lines
arch/arm/lib/relocate.S new file +12
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy_loop */ + ldr r2, =__image_copy_end + +copy_loop: + ldmia r0!, {r10-r11} /* copy from source address [r0] */ + stmia r1!, {r10-r11} /* copy to target address [r1] */ + cmp r0, r2 /* until source end address [r2] */ + blo copy_loop + +#ifndef CONFIG_SPL_BUILD
Quoted 8 lines
arch/arm/lib/relocate.S line 65
Quoted 4 lines
arch/arm/lib/relocate.S new file +4
-0+ /* + * fix .rel.dyn relocations + */ + ldr r0, =_TEXT_BASE /* r0 <- Text base */The value you load above into r0 then gets overwritten prior to having been used, so you can drop this line, all the more it is wrong, loading the address of
_TEXT_BASEinstead of its value.
Correct. Will fix in V2.
Quoted 7 lines
arch/arm/lib/relocate.S line 68
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ ldr r10, =__dynsym_start /* r10 <- sym table ofs */ + ldr r2, =__rel_dyn_start /* r2 <- rel dyn start ofs */ + ldr r3, =__rel_dyn_end /* r3 <- rel dyn end ofs */'ofs' should be replaced with 'in FLASH' in the comments above.
Contrary to above, this construct works here because this can't be SPL code.
Actually, this would not work either if used by non-SPL code as SPL code expects to use it, e.g. by loading U-Boot at another address -- the issue is in the use scenario, not in the requirements for SPL vs. U-Boot.
Quoted 10 lines
arch/arm/lib/relocate.S line 100
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+relocate_done: + + bx lrThis instruction is not supported on ARMv4, even if GCC does not complain about it (it looks like this is not even fixed by the linker, except if the instruction was issued by GCC itself), but it is required for more recent ARM versions for Thumb inter-working, which is enabled by some boards in U-Boot. Hence, shouldn't the line above be replaced with:
Quoted 7 lines
#ifdef
__ARM_ARCH_4__
mov pc, lr
#else
bx lr
#endifOr using
CONFIG_SYS_THUMB_BUILD?
I would have preferred adding --fix-v4bx to the linker flags for ARMv4 targets, but it seems to have no effect at least with some toolchains. I'll fix the code above with the ARMv4 conditional, as it is always correct regardless of U-boot configuration options semantics.
Quoted 2 lines
"
ENDPROC(relocate_code)" should be added here if you go forENTRY()at the beginning.
Ok.
Quoted 2 lines
Best regards,
Beno?t
Thanks for your review!
Amicalement,
Signature · 1 line
Albert.
PATCH v4 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 9 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 4 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 1 line · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>
[...]
Quoted 49 lines
Quoted 12 lines
arch/arm/lib/relocate.S line 49
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ mov r6, r0 /* save addr of destination */ + + ldr r0, =_startThis is wrong. Here, r0 will get
_startlink-time address, while with 'adr' in
the original code, r0 was getting_startruntime address, which is not the same
for all boards.relocate_code()is and must stay position-independent code, at
least for SPL.Quoted 1 line
E.g., for mx31pdk or tx25, the SPL is first loaded by the boot ROM
in the NAND
Quoted 11 lines
Flash controller buffer, then executed from there. The SPL then has to use
relocate_code()to relocate itself toCONFIG_SPL_TEXT_BASEin order to free the
NFC buffer to load U-Boot from NAND Flash. This means that 'ldr r0, =_start'
would set r0 toCONFIG_SPL_TEXT_BASE, while 'adr r0,_start' sets r0 to the address of the NFC buffer. Since the SPL callsrelocate_code()withCONFIG_SPL_TEXT_BASE, the 'ldr' choice would just result in a branch torelocate_donebelow, which would abort the relocation and break the boot on those boards.Quoted 8 lines
The issue is that 'adr' requires that
_startbe defined in the same file and
section. That's why my patch 31/31 was using a macro to definerelocate_code()
in thestart.Sfiles. Perhaps some other constructs like
'sub r0, pc, . -_start' would work, but I doubt it if_startis not in the same
file and section since this is exactly how 'adr' is translated.Alright, so -- formally, there is no assumption that code running before relocation must be position-independent, as far as I remember. The assumption is that it is designed to run at the link-time location, and that it is responsible for making sure that the rest of the code is properly relocated and thus will run at whatever location it was moved to.
In the case you mention, SPL does not relocate itself: it only *moves* itself, skipping the actual relocation (reference fixing part) -- it could havdoe so with a short ad hoc loop instead of
relocate_code, and thus not impose a specific requirement onrelocate_codethat was not initially there. I'd be happier with a preprocessor conditional at thecrt0.Sstage to choose betweenrelocate_codeand a new, short,move_coderoutine depending on whether we are building SPL or not.
Quoted 3 lines
That being said, I am fine with trying to make the code before relocation as position-independent as possible anyway; let me see how this can be done.
OK, I let you try something. Otherwise, I agree with what you say above. The original code for the non-SPL part below is not position-independent, so it is safe to assume that only the beginning of relocate_code() (before '#ifndef CONFIG_SPL_BUILD') should be position-independent, and only for SPL. It is also probably true that the initial runtime address of all SPLs is known at build time, so a new CONFIG_SPL_ could be created for that purpose and used in a dedicated small SPL copy routine, which would also make the need for SPL move testable at build time, and solve the 'adr' vs. 'ldr' issue.
Quoted 30 lines
Quoted 13 lines
Quoted 13 lines
arch/arm/lib/relocate.S new file +13
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy_loop */ + ldr r2, =__image_copy_end + +copy_loop: + ldmia r0!, {r10-r11} /* copy from source address [r0] */ + stmia r1!, {r10-r11} /* copy to target address [r1] */ + cmp r0, r2 /* until source end address [r2] */ + blo copy_loop + +#ifndef CONFIG_SPL_BUILD + /*Quoted 8 lines
arch/arm/lib/relocate.S line 65
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ * fix .rel.dyn relocations + */ + ldr r0, =_TEXT_BASE /* r0 <- Text base */The value you load above into r0 then gets overwritten prior to having been used, so you can drop this line, all the more it is wrong, loading the address
of_TEXT_BASEinstead of its value.Correct. Will fix in V2.
Quoted 6 lines
arch/arm/lib/relocate.S line 68
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+ ldr r10, =__dynsym_start /* r10 <- sym table ofs */ + ldr r2, =__rel_dyn_start /* r2 <- rel dyn start ofs */ + ldr r3, =__rel_dyn_end /* r3 <- rel dyn end ofs */'ofs' should be replaced with 'in FLASH' in the comments above.
Quoted 7 lines
Quoted 2 lines
Contrary to above, this construct works here because this can't be SPL code.
Actually, this would not work either if used by non-SPL code as SPL code expects to use it, e.g. by loading U-Boot at another address -- the issue is in the use scenario, not in the requirements for SPL vs. U-Boot.
Right, but this new code behaves exactly in the same way as the original code, so it is safe to assume that there is no such use scenario. This new code just can't introduce a regression.
Quoted 19 lines
Quoted 19 lines
arch/arm/lib/relocate.S line 100
Quoted 3 lines
arch/arm/lib/relocate.S new file +3
-0+relocate_done: + + bx lrThis instruction is not supported on ARMv4, even if GCC does not complain about
it (it looks like this is not even fixed by the linker, except if the instruction was issued by GCC itself), but it is required for more recent ARM
versions for Thumb inter-working, which is enabled by some boards in U-Boot.
Hence, shouldn't the line above be replaced with:#ifdef
__ARM_ARCH_4__
mov pc, lr
#else
bx lr
#endif
Quoted 4 lines
Quoted 1 line
Or using
CONFIG_SYS_THUMB_BUILD?I would have preferred adding --fix-v4bx to the linker flags for ARMv4 targets, but it seems to have no effect at least with some toolchains.
Indeed.
Quoted 6 lines
I'll fix the code above with the ARMv4 conditional, as it is always correct regardless of U-boot configuration options semantics.
Quoted 2 lines
"
ENDPROC(relocate_code)" should be added here if you go forENTRY()at the beginning.
Quoted 6 lines
Ok.
Quoted 2 lines
Best regards,
Beno?tThanks for your review!
You're welcome.
Best regards,
Beno?t
PATCH v4 4/4 arm: factorize relocate_code routine
In reply to Albert ARIBAUDQuoted 12 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>--- arch/arm/cpu/arm1136/start.S | 82 -------------------------------- arch/arm/cpu/arm1176/start.S | 75 ------------------------------ arch/arm/cpu/arm720t/start.S | 82 -------------------------------- arch/arm/cpu/arm920t/start.S | 75 ------------------------------ arch/arm/cpu/arm925t/start.S | 75 ------------------------------ arch/arm/cpu/arm926ejs/start.S | 82 -------------------------------- arch/arm/cpu/arm946es/start.S | 75 ------------------------------ arch/arm/cpu/arm_intcm/start.S | 75 ------------------------------ arch/arm/cpu/armv7/start.S | 78 -------------------------------
Quoted 9 lines
arch/arm/cpu/ixp/start.S | 75 ------------------------------ arch/arm/cpu/pxa/start.S | 84 --------------------------------- arch/arm/cpu/s3c44b0/start.S | 75 ------------------------------ arch/arm/cpu/sa1100/start.S | 75 ------------------------------ arch/arm/lib/Makefile | 2 +- arch/arm/lib/relocate.S | 100 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 101 insertions(+), 1009 deletions(-) create mode 100644 arch/arm/lib/relocate.S
I tested this series on snow (Exynos 5250, ARMv7, with SPL) with no apparent regressions.
Regards,
Simon
PATCH v4 2/4 arm: make __image_copy_{start, end} compiler-generated
In reply to Albert ARIBAUDHi Albert,
Quoted 22 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>--- arch/arm/cpu/arm1136/start.S | 7 +++---- arch/arm/cpu/arm1136/u-boot-spl.lds | 3 ++- arch/arm/cpu/arm720t/start.S | 11 +++++++---- arch/arm/cpu/arm920t/ep93xx/u-boot.lds | 6 +++++- arch/arm/cpu/arm926ejs/start.S | 7 +++---- arch/arm/cpu/armv7/am33xx/u-boot-spl.lds | 2 -- arch/arm/cpu/armv7/omap-common/u-boot-spl.lds | 2 -- arch/arm/cpu/armv7/socfpga/u-boot-spl.lds | 1 - arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/u-boot.lds | 6 +++++- arch/arm/cpu/u-boot-spl.lds | 3 +-- arch/arm/cpu/u-boot.lds | 7 +++++-- arch/arm/lib/sections.c | 4 +++- 13 files changed, 36 insertions(+), 29 deletions(-)arch/arm/cpu/arm1136/start.S +0
-0
arch/arm/cpu/arm1136/start.S _TEXT_BASE: · line 107
Quoted 4 lines
arch/arm/cpu/arm1136/start.S +0
-1@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs
Wasn't _image_copy_end_ofs used outside of start.S? Same question for all the start.S files.
Quoted 30 lines
arch/arm/cpu/arm1136/start.S +3
-3-_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start@@ -239,6 +235,9 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start + #ifndef CONFIG_SPL_BUILD _rel_dyn_start_ofs:arch/arm/cpu/arm1136/u-boot-spl.lds +0
-1@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/arm1136/start.o (.text*) *(.text*) } >.sram
arch/arm/cpu/arm1136/u-boot-spl.lds SECTIONS · line 51
Quoted 5 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +1
-0@@ -48,7 +47,9 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + __image_copy_end = .;
Why aren't all linker scripts treated equally?
Here, start.S is still used, so '*(.__image_copy_end)' and the related stuff should be like what you did for arch/arm/cpu/u-boot.lds below. Or am I missing something?
Same question for several other linker scripts below.
Quoted 4 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +1
-0+ _end = .; .bss :
[...]
arch/arm/cpu/u-boot.lds SECTIONS · line 36
Quoted 10 lines
arch/arm/cpu/u-boot.lds +1
-1@@ -33,7 +33,7 @@ SECTIONS . = ALIGN(4); .text : { - __image_copy_start = .; + *(.__image_copy_start)
Are there any users of __image_copy_start?
Quoted 33 lines
arch/arm/cpu/u-boot.lds +4
-1CPUDIR/start.o (.text*) *(.text*) }@@ -57,7 +57,10 @@ SECTIONS . = ALIGN(4); - __image_copy_end = .; + .image_copy_end : + { + *(.__image_copy_end); + } .rel.dyn : { __rel_dyn_start = .;arch/arm/lib/sections.c +2
-1@@ -21,7 +21,7 @@*/ /** -* These two symbols are declared in a C file so that the linker +* The following symbols are declared in a C file so that the linker * uses R_ARM_RELATIVE relocation, rather than the R_ARM_ABS32 one * it would use if the symbols were defined in the linker file. * Using only R_ARM_RELATIVE relocation ensures that references to @@ -37,3 +37,5 @@ char __bss_start[0] __attribute__((used, section(".__bss_start"))); char __bss_end[0] __attribute__((used, section(".__bss_end"))); +char __image_copy_start[0] __attribute__((used,
Quoted 1 line
section(".__image_copy_start")));
Ditto.
Quoted 2 lines
+char __image_copy_end[0] __attribute__((used,
section(".__image_copy_end")));
Best regards,
Beno?t
PATCH 2/4 arm: make __image_copy_{start, end} compiler-generated
Hi Beno?t,
Quoted 10 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 8 lines
arch/arm/cpu/arm1136/start.S +0
-0@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start
Quoted 4 lines
arch/arm/cpu/arm1136/start.S _TEXT_BASE: · line 107
Quoted 1 line
arch/arm/cpu/arm1136/start.S +0
-1-.globl _image_copy_end_ofsWasn't
_image_copy_end_ofsused outside ofstart.S? Same question for all thestart.Sfiles.
No -- and the build would have failed if it was. The only user of __image_copy_end_ofs is the start.S which defines it, and only for the purpose of preventing the assembler from generating an R_ARM_ABS32 relocation to __image_copy_end.
Quoted 22 lines
Quoted 14 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +0
-1@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/arm1136/start.o (.text*) *(.text*) } >.sramarch/arm/cpu/arm1136/u-boot-spl.lds SECTIONS · line 51
Quoted 5 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +1
-0@@ -48,7 +47,9 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + __image_copy_end = .;Why aren't all linker scripts treated equally?
Quoted 5 lines
Here,
start.Sis still used, so '*(.__image_copy_end)' and the related stuff should be like what you did forarch/arm/cpu/u-boot.ldsbelow. Or am I missing something?Same question for several other linker scripts below.
Not all SPLs use relocation -- actually, most SPLs do not use relocation, and thus do not need image and relocaton section symbols.
Quoted 4 lines
Quoted 4 lines
arch/arm/cpu/u-boot.lds +0
-0
Quoted 8 lines
arch/arm/cpu/u-boot.lds SECTIONS · line 36
Quoted 6 lines
arch/arm/cpu/u-boot.lds +1
-1@@ -33,7 +33,7 @@ SECTIONS . = ALIGN(4); .text : { - __image_copy_start = .; + *(.__image_copy_start)Are there any users of
__image_copy_start?
(see below)
Quoted 5 lines
arch/arm/lib/sections.c
Quoted 3 lines
arch/arm/lib/sections.c +0
-1--- a/arch/arm/lib/sections.c+++
b/arch/arm/lib/sections.c
Quoted 8 lines
Quoted 6 lines
arch/arm/lib/sections.c +1
-0@@ -37,3 +37,5 @@ char __bss_start[0] __attribute__((used, section(".__bss_start"))); char __bss_end[0] __attribute__((used, section(".__bss_end"))); +char __image_copy_start[0] __attribute__((used,
section(".__image_copy_start")));Ditto.
The only user of __image_copy_start is the relocation routine which uses _start but should actually use __image_copy_start (will fix in V2), to match with the semantics introduced when fixing CONFIG_SPL_MAX_SIZE semantics in 6ebc3461.
Quoted 2 lines
Best regards,
Beno?t
Thanks for your review!
Amicalement,
Signature · 1 line
Albert.
PATCH v4 2/4 arm: make __image_copy_{start, end} compiler-generated
Hi Albert,
Quoted 6 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 1 line · Beno?t Th?baudeau
Hi Albert,
[...]
Quoted 28 lines
Quoted 28 lines
Quoted 14 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +0
-1@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/arm1136/start.o (.text*) *(.text*) } >.sramarch/arm/cpu/arm1136/u-boot-spl.lds SECTIONS · line 51
Quoted 5 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +1
-0@@ -48,7 +47,9 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + __image_copy_end = .;Why aren't all linker scripts treated equally?
Here,
start.Sis still used, so '*(.__image_copy_end)' and the related stuff
should be like what you did forarch/arm/cpu/u-boot.ldsbelow. Or am I missing
something?
Quoted 4 lines
Quoted 1 line
Same question for several other linker scripts below.
Not all SPLs use relocation -- actually, most SPLs do not use relocation, and thus do not need image and relocaton section symbols.
Then, why do you keep the old definition of __image_copy_end in such linker scripts? Probably because start.S can't be linked in otherwise, but this is no longer true at the end of this series with the new relocate.S that is garbage- collected for those SPLs. And in all cases, shouldn't all linker scripts requiring __image_copy_end be converted to the new definition?
[...]
Best regards,
Beno?t
PATCH 2/4 arm: make __image_copy_{start, end} compiler-generated
Hi Beno?t,
Quoted 42 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 6 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 1 line · Beno?t Th?baudeau
Hi Albert,
[...]
Quoted 30 lines
Quoted 29 lines
Quoted 14 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +0
-1@@ -37,7 +37,6 @@ SECTIONS { .text : { - __start = .; arch/arm/cpu/arm1136/start.o (.text*) *(.text*) } >.sramarch/arm/cpu/arm1136/u-boot-spl.lds SECTIONS · line 51
Quoted 5 lines
arch/arm/cpu/arm1136/u-boot-spl.lds +1
-0@@ -48,7 +47,9 @@ SECTIONS . = ALIGN(4); .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + __image_copy_end = .;Why aren't all linker scripts treated equally?
Here,
start.Sis still used, so '*(.__image_copy_end)' and the related stuff
should be like what you did forarch/arm/cpu/u-boot.ldsbelow. Or am I missing
something?Same question for several other linker scripts below.
Quoted 8 lines
Quoted 2 lines
Not all SPLs use relocation -- actually, most SPLs do not use relocation, and thus do not need image and relocaton section symbols.
Then, why do you keep the old definition of
__image_copy_endin such linker scripts? Probably becausestart.Scan't be linked in otherwise, but this is no longer true at the end of this series with the newrelocate.Sthat is garbage- collected for those SPLs. And in all cases, shouldn't all linker scripts requiring__image_copy_endbe converted to the new definition?
You are right on both accounts: all linker scripts that need __image_copy_* should be converted to the new definition, and some linker scripts probably don't need __image_copy_end even though they define it. I intend to achieve this, not by editing various linker scripts, but by factoring them into a single linker script (or two at most, one for U-boot and one for SPL). So I prefer to do as little work on the scripts as possible right now; here, only what's needed for relocation factoring to work.
Hence, if an SPL script sort-of-hardcodes image start and end (or relocation symbols as some do), then I prefer to leave it alone for now and handle in the linker script factoring series later.
(on an unrelated note, V2 will have an additional patch removing absolute relocation record type support in relocate_code, as it should be useless now too. But I'll pair this removal with a build step that makes sure the ELF u-boot and SPL binaries only have R_ARM_RELATIVE relocation records.)
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH 2/4 arm: make __image_copy_{start, end} compiler-generated
Quoted 3 lines · Albert ARIBAUD
Hence, if an SPL script sort-of-hardcodes image start and end (or relocation symbols as some do), then I prefer to leave it alone for now and handle in the linker script factoring series later.
... but I do realize in some cases I removed __image_copy_end and in others I didn't. I'll go over this again in V2 by following the rule of least change -- not doing a change unless required by the objective of the series, that is, factoring relocate code.
Amicalement,
Signature · 1 line
Albert.
v2 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDThis series replaces all instances of relocate_code in various start.S files from the ARM architecture with a single instance in arch/arm/lib/relocate.S.
This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to relocate_code
In SPL of mx31pdk, board_init_f calls relocate_code to move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.
2. Drop tx25 SPL call to relocate_code
Same as mx31pdk.
3. Prevent all SPLs from assembling relocate_code
Now that no SPL uses relocate_code any more, remove it completely from SPL builds by putting it entirely between #ifndef CONFIG_SPL_BUILD and #endif preprocessor conditional.
4. Actual factorization of relocate_code
Remove all instances of relocate_code from start.S and create a new file, arch/arm/lib/relocate.S, to provide the new single instance of relocate_code.
The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
Changes in v2:
- dropped relocate_code() call from mx31pdk SPL
- dropped relocate_code() call from tx25 SPL
- dropped all relocate_code instances from SPL builds
- use ENTRY / ENDPROC macros
- preserve PXA25X dcache unlocking
Albert ARIBAUD (4):
mx31pdk: copy SPL directly, not using relocate_code.
tx25: copy SPL directly, not using relocate_code.
arm: do not compile relocate_code() for SPL builds
arm: factorize relocate_code routine
arch/arm/cpu/arm1136/start.S | 81 --------------------------- arch/arm/cpu/arm1176/start.S | 77 ------------------------- arch/arm/cpu/arm720t/start.S | 77 ------------------------- arch/arm/cpu/arm920t/start.S | 77 ------------------------- arch/arm/cpu/arm925t/start.S | 77 ------------------------- arch/arm/cpu/arm926ejs/start.S | 81 --------------------------- arch/arm/cpu/arm946es/start.S | 77 ------------------------- arch/arm/cpu/arm_intcm/start.S | 77 ------------------------- arch/arm/cpu/armv7/start.S | 78 -------------------------- arch/arm/cpu/ixp/start.S | 77 ------------------------- arch/arm/cpu/pxa/start.S | 96 +++----------------------------- arch/arm/cpu/s3c44b0/start.S | 77 ------------------------- arch/arm/cpu/sa1100/start.S | 77 ------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 111 +++++++++++++++++++++++++++++++++++++ board/freescale/mx31pdk/mx31pdk.c | 16 +++++- board/karo/tx25/tx25.c | 16 +++++- 17 files changed, 151 insertions(+), 1022 deletions(-) create mode 100644 arch/arm/lib/relocate.S
Signature · 1 line
1.7.10.4
PATCH v2 1/4 mx31pdk: copy SPL directly, not using relocate_code.
---
Changes in v2:
- dropped relocate_code() call from mx31pdk SPL
board/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/freescale/mx31pdk/mx31pdk.c +15 -1
@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v2 2/4 tx25: copy SPL directly, not using relocate_code.
---
Changes in v2:
- dropped relocate_code() call from tx25 SPL
board/karo/tx25/tx25.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/karo/tx25/tx25.c +15 -1
@@ -35,7 +35,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v2 3/4 arm: do not compile relocate_code() for SPL builds
---
Changes in v2:
- dropped all relocate_code instances from SPL builds
arch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)
arch/arm/cpu/arm1136/start.S +3 -8
@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -173,6 +169,7 @@ next: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -195,7 +192,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -233,14 +229,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm1176/start.S +5 -6
@@ -112,10 +112,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -225,6 +221,7 @@ skip_tcmdisable: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -247,7 +244,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -285,12 +281,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -298,6 +295,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm720t/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm920t/start.S +5 -7
@@ -89,10 +89,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -194,6 +190,7 @@ copyex: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -216,7 +213,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -254,12 +250,12 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif - relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -267,6 +263,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm925t/start.S +5 -6
@@ -95,10 +95,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -184,6 +180,7 @@ poll1: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -206,7 +203,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -244,12 +240,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -257,6 +254,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm926ejs/start.S +3 -8
@@ -136,10 +136,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -190,6 +186,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -212,7 +209,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -250,14 +246,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm946es/start.S +5 -6
@@ -105,10 +105,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -159,6 +155,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -181,7 +178,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -219,12 +215,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -232,6 +229,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm_intcm/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/armv7/start.S +2 -4
@@ -94,10 +94,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -231,6 +227,8 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/ixp/start.S +5 -6
@@ -114,10 +114,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -257,6 +253,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -279,7 +276,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -317,12 +313,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -330,6 +327,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/pxa/start.S +2 -6
@@ -118,10 +118,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -201,7 +197,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -239,12 +234,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/s3c44b0/start.S +5 -6
@@ -80,10 +80,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -140,6 +136,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -162,7 +159,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -200,12 +196,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -213,6 +210,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/sa1100/start.S +5 -6
@@ -90,10 +90,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -144,6 +140,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -166,7 +163,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -204,12 +200,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -217,6 +214,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
Signature · 1 line
1.7.10.4
PATCH v2 4/4 arm: factorize relocate_code routine
Replace all relocate_code routines from ARM start.S files with a single instance in file arch/arm/lib/relocate.S. For PXA, this requires moving the dcache unlocking code from within relocate_code into c_runtime_cpu_setup.
---
Changes in v2:
- use ENTRY / ENDPROC macros
- preserve PXA25X dcache unlocking
arch/arm/cpu/arm1136/start.S | 76 --------------------------- arch/arm/cpu/arm1176/start.S | 76 --------------------------- arch/arm/cpu/arm720t/start.S | 76 --------------------------- arch/arm/cpu/arm920t/start.S | 75 --------------------------- arch/arm/cpu/arm925t/start.S | 76 --------------------------- arch/arm/cpu/arm926ejs/start.S | 76 --------------------------- arch/arm/cpu/arm946es/start.S | 76 --------------------------- arch/arm/cpu/arm_intcm/start.S | 76 --------------------------- arch/arm/cpu/armv7/start.S | 76 --------------------------- arch/arm/cpu/ixp/start.S | 76 --------------------------- arch/arm/cpu/pxa/start.S | 92 ++++----------------------------- arch/arm/cpu/s3c44b0/start.S | 76 --------------------------- arch/arm/cpu/sa1100/start.S | 76 --------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 111 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 121 insertions(+), 994 deletions(-) create mode 100644 arch/arm/lib/relocate.S
arch/arm/cpu/arm1136/start.S +0 -76
@@ -169,82 +169,6 @@ next: /*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop - -relocate_done: - - bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif - .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm1176/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm720t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm920t/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm925t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm926ejs/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm946es/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm_intcm/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/ixp/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/pxa/start.S +9 -83
102 lines not on this page · raw message
arch/arm/cpu/s3c44b0/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/sa1100/start.S +0 -76
82 lines not on this page · raw message
arch/arm/lib/Makefile +1 -0
@@ -39,6 +39,7 @@ GLCOBJS += div0.o SOBJS-y += crt0.o ifndef CONFIG_SPL_BUILD +SOBJS-y += relocate.o ifndef CONFIG_SYS_GENERIC_BOARD COBJS-y += board.o endif
arch/arm/lib/relocate.S new file +111 -0
111 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 6 lines · Albert ARIBAUD
Replace all
relocate_coderoutines from ARMstart.Sfiles with a single instance in filearch/arm/lib/relocate.S. For PXA, this requires moving the dcache unlocking code from withinrelocate_codeintoc_runtime_cpu_setup.Signed-off-by Albert ARIBAUD <[email protected]>
[...]
Quoted 94 lines
arch/arm/cpu/pxa/start.S +0
-82@@ -167,93 +167,19 @@ reset: bl _main /*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - -/* Disable the Dcache RAM lock for stack now */ -#ifdef CONFIG_CPU_PXA25X - mov r12, lr - bl cpu_init_crit - mov lr, r12 -#endif - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop - -relocate_done: - - bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/pxa/start.S reset: · line 182
Quoted 10 lines
arch/arm/cpu/pxa/start.S +9
-1- bx lr + /* + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. + */ + b cpu_init_crit
Shouldn't the "#ifdef CONFIG_CPU_PXA25X" from the original code be kept here?
Quoted 3 lines
arch/arm/cpu/pxa/start.S +0
-0/* *************************************************************************
[...]
Quoted 28 lines
arch/arm/lib/relocate.S new file +22
-0@@ -0,0 +1,111 @@ +/* + * relocate - common relocation function for ARM U-Boot + * + * Copyright (c) 2013 Albert ARIBAUD <[email protected]> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA
arch/arm/lib/relocate.S line 32
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ */ + +#include <linux/linkage.h> + +/* + * 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. + */
This comment is obsolete. It should either be removed or updated.
arch/arm/lib/relocate.S line 42
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ +/* + * void relocate_code(addr_moni) + * + * This function relocates the monitor code. + */ +ENTRY(relocate_code) + mov r6, r0 /* save addr of destination */ + + ldr r0, =_start
If you are avoiding the "ldr =" construct below, why do you use it here? You could "ldr r0, _TEXT_BASE".
arch/arm/lib/relocate.S line 47
Quoted 5 lines
arch/arm/lib/relocate.S new file +5
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy loop */ + ldr r3, _image_copy_end_ofs + add r2, r0, r3 /* r2 <- source end address */
Adding _start to a relocate_code-relative _image_copy_end_ofs?!
Quoted 6 lines
arch/arm/lib/relocate.S new file +6
-0+ +copy_loop: + ldmia r0!, {r10-r11} /* copy from source address [r0] */ + stmia r1!, {r10-r11} /* copy to target address [r1] */ + cmp r0, r2 /* until source end address [r2] */ + blo copy_loop
arch/arm/lib/relocate.S line 63
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ + /* + * fix .rel.dyn relocations + */ + ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ + add r10, r10, r9 /* r10 <- sym table in FLASH */ + ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ + add r2, r2, r9 /* r2 <- rel dyn start in FLASH */ + ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ + add r3, r3, r9 /* r3 <- rel dyn end in FLASH */
This is mixing relocate_code-relative offsets with the relocation offset!
Quoted 49 lines
arch/arm/lib/relocate.S new file +48
-1+fixloop: + ldr r0, [r2] /* r0 <- SRC location to fix up */ + add r0, r0, r9 /* r0 <- DST location to fix up */ + ldr r1, [r2, #4] + and r7, r1, #0xff + cmp r7, #23 /* relative fixup? */ + beq fixrel + cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ + 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 + blo fixloop + +relocate_done: + + /* ARMv4- don't know bx lr but the assembler fails to see that */ + +#ifdef __ARM_ARCH_4__ + mov pc, lr +#else + bx lr +#endif + +_image_copy_end_ofs: + .word __image_copy_end - relocate_code +_rel_dyn_start_ofs: + .word __rel_dyn_start - relocate_code +_rel_dyn_end_ofs: + .word __rel_dyn_end - relocate_code +_dynsym_start_ofs: + .word __dynsym_start - relocate_code + +ENDPROC(relocate_code) --
Quoted 1 line
1.7.10.4
Best regards,
Beno?t
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 5 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 3 lines
.globl
c_runtime_cpu_setup
c_runtime_cpu_setup:
Quoted 12 lines
arch/arm/cpu/pxa/start.S reset: · line 182
Quoted 10 lines
arch/arm/cpu/pxa/start.S +9
-1- bx lr + /* + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. + */ + b cpu_init_critShouldn't the "#ifdef
CONFIG_CPU_PXA25X" from the original code be kept here?
Yes, it should indeed. Thanks for spotting this!
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 24 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 5 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 3 lines
.globl
c_runtime_cpu_setup
c_runtime_cpu_setup:Quoted 13 lines
arch/arm/cpu/pxa/start.S reset: · line 182
Quoted 10 lines
arch/arm/cpu/pxa/start.S +9
-1- bx lr + /* + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. + */ + b cpu_init_critShouldn't the "#ifdef
CONFIG_CPU_PXA25X" from the original code be kept here?
Quoted 1 line
Yes, it should indeed. Thanks for spotting this!
Have you seen the end of my notes for relocate.S? After all, keeping for later your patches moving to compiler-generated symbols seems to complicate things and to be more error-prone.
Best regards,
Beno?t
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 27 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 24 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 18 lines · Beno?t Th?baudeau
Hi Albert,
arch/arm/cpu/pxa/start.S reset: · line 182
Quoted 13 lines
arch/arm/cpu/pxa/start.S +9
-1.globl c_runtime_cpu_setup c_runtime_cpu_setup: - bx lr + /* + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. + */ + b cpu_init_critShouldn't the "#ifdef
CONFIG_CPU_PXA25X" from the original code be kept here?
Quoted 5 lines
Quoted 1 line
Yes, it should indeed. Thanks for spotting this!
Have you seen the end of my notes for
relocate.S? After all, keeping for later your patches moving to compiler-generated symbols seems to complicate things and to be more error-prone.
(that's unrelated to the PXA25X stuff above, right?)
I don't think deferring the compiler-generated symbols patches complicates things, as anyway, they would only apply after this patch (so as to apply only on a single instance of relocate_code) so there's no way they could simplify things occurring before them.
OTOH, they do simplify the code of relocate_code. That's why I put them in a separate series dealing with optimizing relocate_code. I'll post this second series right away, and let people decide whether both series should be merged in a single one.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 34 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 29 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 25 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 5 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 3 lines
.globl
c_runtime_cpu_setup
c_runtime_cpu_setup:Quoted 13 lines
arch/arm/cpu/pxa/start.S reset: · line 182
Quoted 10 lines
arch/arm/cpu/pxa/start.S +9
-1- bx lr + /* + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. + */ + b cpu_init_critShouldn't the "#ifdef
CONFIG_CPU_PXA25X" from the original code be kept here?Yes, it should indeed. Thanks for spotting this!
Quoted 7 lines
Quoted 5 lines
Have you seen the end of my notes for
relocate.S? After all, keeping for later
your patches moving to compiler-generated symbols seems to complicate things and
to be more error-prone.(that's unrelated to the PXA25X stuff above, right?)
Yes.
Quoted 9 lines
I don't think deferring the compiler-generated symbols patches complicates things, as anyway, they would only apply after this patch (so as to apply only on a single instance of
relocate_code) so there's no way they could simplify things occurring before them.OTOH, they do simplify the code of
relocate_code. That's why I put them in a separate series dealing with optimizingrelocate_code. I'll post this second series right away, and let people decide whether both series should be merged in a single one.
Yes, this is what I meant.
Best regards,
Beno?t
PATCH v2 4/4 arm: factorize relocate_code routine
In reply to Benoît ThébaudeauHi Beno?t,
(I had indeed missed remarks in your reply; apologies for this)
Quoted 10 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 6 lines
+/*
+ * These are defined in the board-specific linker script.
+ * Subtracting_startfrom them lets the linker put their
+ * relative position in the executable instead of leaving
+ * them null.
+ */This comment is obsolete. It should either be removed or updated.
Correct.
Quoted 5 lines
Quoted 5 lines
arch/arm/lib/relocate.S new file +5
-0+ +/* + * void relocate_code(addr_moni) + * + * This function relocates the monitor code.
Quoted 8 lines
arch/arm/lib/relocate.S line 42
Quoted 5 lines
+ */
arch/arm/lib/relocate.S new file +4
-0+ENTRY(relocate_code) + mov r6, r0 /* save addr of destination */ + + ldr r0, =_startIf you are avoiding the "ldr =" construct below, why do you use it here? You could "ldr r0,
_TEXT_BASE".
_start is defined in a compilation unit, not in the linker file. References to _start such as the one above are therefore correct before as well as after relocation.
Quoted 7 lines
arch/arm/lib/relocate.S line 47
Quoted 5 lines
arch/arm/lib/relocate.S new file +5
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy loop */ + ldr r3, _image_copy_end_ofs + add r2, r0, r3 /* r2 <- source end address */Adding
_startto a relocate_code-relative_image_copy_end_ofs?!
You're correct. For some reason I did not complete the rewrite here. :(
I'd made the offsets relative to relocate_code in order to avoid the linker issues with subtracting symbols not defined in the current compilation unit.
Then I should add =relocate_code to r3, not =_start, and also -- as r9 is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-time relocate_code (r7 becomes useless once R10, r2 and r3 are fixed).
I'd run-tested tested each commit but apparently this bug did not cause any immediately visible issue. This time I'll step-test it.
Quoted 11 lines
arch/arm/lib/relocate.S line 63
Quoted 9 lines
arch/arm/lib/relocate.S new file +9
-0+ /* + * fix .rel.dyn relocations + */ + ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */ + add r10, r10, r9 /* r10 <- sym table in FLASH */ + ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */ + add r2, r2, r9 /* r2 <- rel dyn start in FLASH */ + ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */ + add r3, r3, r9 /* r3 <- rel dyn end in FLASH */This is mixing relocate_code-relative offsets with the relocation offset!
Correct, that's where r7 kicks in to replace r9.
Again, apologies for missing this.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Quoted 4 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9 is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-time
relocate_code(r7 becomes useless once R10, r2 and r3 are fixed).
I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 10 lines · Albert ARIBAUD
Quoted 4 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9 is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-time
relocate_code(r7 becomes useless once R10, r2 and r3 are fixed).I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7, relocate_code" for the same result in order to avoid using the literal pool when useless.
Best regards,
Beno?t
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 11 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 8 lines · Albert ARIBAUD
Quoted 4 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9 is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-time
relocate_code(r7 becomes useless once R10, r2 and r3 are fixed).
Quoted 5 lines
Quoted 2 lines
I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7,
relocate_code" for the same result in order to avoid using the literal pool when useless.
Correct. That'll be in v3.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 16 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 11 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 8 lines · Albert ARIBAUD
Quoted 4 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9 is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-time
relocate_code(r7 becomes useless once R10, r2 and r3 are fixed).
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7,
relocate_code" for the same result in order to avoid using the literal pool when useless.Correct. That'll be in v3.
Sorry, I missed this change in V3 and left the ldr. Functionally it does not have any impact, since as already mentioned, this code always runs at the link-time location. You may want Want me to fix it anyway?
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 29 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 24 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 18 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 11 lines · Albert ARIBAUD
Quoted 5 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9
is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-timerelocate_code(r7 becomes useless once R10, r2 and r3 are fixed).I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7,
relocate_code" for the same result in order to avoid using the
literal pool when useless.
Quoted 5 lines
Quoted 1 line
Correct. That'll be in v3.
Sorry, I missed this change in V3 and left the ldr. Functionally it does not have any impact, since as already mentioned, this code always runs at the link-time location. You may want Want me to fix it anyway?
I have not yet looked at your V3, but yes, I'd prefer.
Best regards,
Beno?t
PATCH v2 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 32 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 29 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 24 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 18 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 11 lines · Albert ARIBAUD
Quoted 5 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9
is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-timerelocate_code(r7 becomes useless once R10, r2 and r3 are fixed).I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7,
relocate_code" for the same result in order to avoid using the
literal pool when useless.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Correct. That'll be in v3.
Sorry, I missed this change in V3 and left the ldr. Functionally it does not have any impact, since as already mentioned, this code always runs at the link-time location. You may want Want me to fix it anyway?
I have not yet looked at your V3, but yes, I'd prefer.
Alright, then, V4 it is.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 4/4 arm: factorize relocate_code routine
Quoted 39 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 34 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 31 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 25 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 12 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 9 lines · Albert ARIBAUD
Quoted 5 lines · Albert ARIBAUD
Then I should add =relocate_code to r3, not =_start, and also -- as r9
is not the right offset here -- compute r7 as the delta between the link-time =_start and the run-timerelocate_code(r7 becomes useless once R10, r2 and r3 are fixed).Quoted 6 lines
Quoted 2 lines
I badly need a coffee break... Make this "r7 equal to =relocate_code", simply.
Or "adr r7,
relocate_code" for the same result in order to avoid using the
literal pool when useless.Correct. That'll be in v3.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Sorry, I missed this change in V3 and left the ldr. Functionally it does not have any impact, since as already mentioned, this code always runs at the link-time location. You may want Want me to fix it anyway?
I have not yet looked at your V3, but yes, I'd prefer.
Alright, then, V4 it is.
Hmm -- I'd actually made the ldr to adr fix in V3, so no V4 for now, V3 is fine.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 3/4 arm: do not compile relocate_code() for SPL builds
In reply to Albert ARIBAUDHi Albert,
Quoted 25 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- dropped allrelocate_codeinstances from SPL buildsarch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)arch/arm/cpu/arm1136/start.S +0
-0
arch/arm/cpu/arm1136/start.S _TEXT_BASE: · line 110
Quoted 7 lines
arch/arm/cpu/arm1136/start.S +0
-4@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start -
This change should be mentioned in the commit message, or moved to a separate patch.
[...]
Best regards,
Beno?t
PATCH v2 3/4 arm: do not compile relocate_code() for SPL builds
Hi Beno?t,
Quoted 31 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 28 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- dropped allrelocate_codeinstances from SPL buildsarch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)arch/arm/cpu/arm1136/start.S +0
-0@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start
Quoted 7 lines
arch/arm/cpu/arm1136/start.S _TEXT_BASE: · line 110
Quoted 4 lines
arch/arm/cpu/arm1136/start.S +0
-4-.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start -This change should be mentioned in the commit message, or moved to a separate patch.
This is not a separate change; __image_copy_end_ofs is one of the offset words used by relocate_code, only for some reason it was not initially placed with the others at the end of the routine; so instead of putting a second pair of conditionals around it, I move it where it should have been in the first place, which also places it within the already added pair of conditionals.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
PATCH v2 3/4 arm: do not compile relocate_code() for SPL builds
Hi Albert,
Quoted 45 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 31 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 28 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- dropped allrelocate_codeinstances from SPL buildsarch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)arch/arm/cpu/arm1136/start.S +0
-0@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _startQuoted 8 lines
arch/arm/cpu/arm1136/start.S _TEXT_BASE: · line 110
Quoted 4 lines
arch/arm/cpu/arm1136/start.S +0
-4-.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start -This change should be mentioned in the commit message, or moved to a separate
patch.
Quoted 6 lines
This is not a separate change;
__image_copy_end_ofsis one of the offset words used byrelocate_code, only for some reason it was not initially placed with the others at the end of the routine; so instead of putting a second pair of conditionals around it, I move it where it should have been in the first place, which also places it within the already added pair of conditionals.
OK.
Best regards,
Beno?t
PATCH v2 2/4 tx25: copy SPL directly, not using relocate_code.
In reply to Albert ARIBAUDHi Albert,
Quoted 15 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- droppedrelocate_code()call from tx25 SPLboard/karo/tx25/tx25.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/karo/tx25/tx25.c +0
-0@@ -35,7 +35,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag)
board/karo/tx25/tx25.c DECLARE_GLOBAL_DATA_PTR; · line 45
Quoted 10 lines
board/karo/tx25/tx25.c +8
-1{ -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr));
Same question as for mx31pdk.
Quoted 11 lines
board/karo/tx25/tx25.c +7
-1+ asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asm volatile("ldr pc, =nand_boot"); }#endif --
Quoted 1 line
1.7.10.4
Best regards,
Beno?t
PATCH v2 1/4 mx31pdk: copy SPL directly, not using relocate_code.
In reply to Albert ARIBAUDHi Albert,
Quoted 16 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- droppedrelocate_code()call from mx31pdk SPLboard/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/freescale/mx31pdk/mx31pdk.c +0
-0@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag)
board/freescale/mx31pdk/mx31pdk.c DECLARE_GLOBAL_DATA_PTR; · line 49
Quoted 10 lines
board/freescale/mx31pdk/mx31pdk.c +8
-1{ -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr));
Why not __image_copy_start/end instead? I know that the result will be the same here, but the naming would be more appropriate. The existing u-boot-spl.lds still gives access to __image_copy_*.
Quoted 11 lines
board/freescale/mx31pdk/mx31pdk.c +7
-1+ asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asm volatile("ldr pc, =nand_boot"); }#endif --
Quoted 1 line
1.7.10.4
Best regards,
Beno?t
PATCH v2 1/4 mx31pdk: copy SPL directly, not using relocate_code.
Hi Beno?t,
Quoted 25 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 22 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- droppedrelocate_code()call from mx31pdk SPLboard/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/freescale/mx31pdk/mx31pdk.c +4
-1@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned.
Quoted 8 lines
board/freescale/mx31pdk/mx31pdk.c DECLARE_GLOBAL_DATA_PTR; · line 49
Quoted 4 lines
board/freescale/mx31pdk/mx31pdk.c +4
-0+*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr));Why not __image_copy_start/end instead? I know that the result will be the same here, but the naming would be more appropriate. The existing
u-boot-spl.ldsstill gives access to __image_copy_*.
Well, yes, the naming seems appropriate, and I thought and said so myself some time ago. But then, I realize that __image_copy_start and __image_copy_end are tightly coupled with relocation, and I want to avoid creating any additional ties between relocation and SPL just when I am severing them. IOW, I want to keep the option of having a reduced SPL linker file, distinct from the u-boot one, and where none of __image_copy_*, __rel_dyn_* or __dynsym_start exist.
Amicalement,
Signature · 1 line
Albert.
PATCH v2 1/4 mx31pdk: copy SPL directly, not using relocate_code.
Hi Albert,
Quoted 40 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 26 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 23 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- droppedrelocate_code()call from mx31pdk SPLboard/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/freescale/mx31pdk/mx31pdk.c +5
-1@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ Quoted 8 lines
board/freescale/mx31pdk/mx31pdk.c DECLARE_GLOBAL_DATA_PTR; · line 49
Quoted 3 lines
board/freescale/mx31pdk/mx31pdk.c +3
-0+ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr));Why not __image_copy_start/end instead? I know that the result will be the same
here, but the naming would be more appropriate. The existingu-boot-spl.ldsstill gives access to __image_copy_*.
Quoted 7 lines
Well, yes, the naming seems appropriate, and I thought and said so myself some time ago. But then, I realize that
__image_copy_startand__image_copy_endare tightly coupled with relocation, and I want to avoid creating any additional ties between relocation and SPL just when I am severing them. IOW, I want to keep the option of having a reduced SPL linker file, distinct from the u-boot one, and where none of __image_copy_*, __rel_dyn_* or__dynsym_startexist.
OK, that's fine.
Since _end is linker-generated contrary to the other symbols that you use in those asm lines, have you checked that no R_ARM_ABS32 relocation data is generated here? OTOH, -pie is not used with SPL, so there should be no relocation data at all generated here, and the true final addresses should be in the binary image.
Best regards,
Beno?t
PATCH v2 1/4 mx31pdk: copy SPL directly, not using relocate_code.
Hi Beno?t,
Quoted 51 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 40 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 26 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 23 lines · Albert ARIBAUD
Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v2:
- droppedrelocate_code()call from mx31pdk SPLboard/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)board/freescale/mx31pdk/mx31pdk.c +5
-1@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ Quoted 8 lines
board/freescale/mx31pdk/mx31pdk.c DECLARE_GLOBAL_DATA_PTR; · line 49
Quoted 3 lines
board/freescale/mx31pdk/mx31pdk.c +3
-0+ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr));Why not __image_copy_start/end instead? I know that the result will be the same
here, but the naming would be more appropriate. The existingu-boot-spl.ldsstill gives access to __image_copy_*.Quoted 7 lines
Well, yes, the naming seems appropriate, and I thought and said so myself some time ago. But then, I realize that
__image_copy_startand__image_copy_endare tightly coupled with relocation, and I want to avoid creating any additional ties between relocation and SPL just when I am severing them. IOW, I want to keep the option of having a reduced SPL linker file, distinct from the u-boot one, and where none of __image_copy_*, __rel_dyn_* or__dynsym_startexist.
Quoted 7 lines
OK, that's fine.
Since
_endis linker-generated contrary to the other symbols that you use in those asm lines, have you checked that noR_ARM_ABS32relocation data is generated here? OTOH, -pie is not used with SPL, so there should be no relocation data at all generated here, and the true final addresses should be in the binary image.
Indeed, SPL is meant to be loaded at its link-time address -- or, in the case of mx31pdk and tx25, loaded in a read buffer then moved by itself to its link-time address. In no case is SPL supposed to be relocated. You can verify with readelf -r that no relocation records are generated for SPL builds.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
v2 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDQuoted 3 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.
Additional (read: late) note: I have dropped the 'make some symbols compiler-generated' part of the series, as this is not needed to factorize relocation_code per se and I want to keep things simple.
I'll reintroduce the compiler-generated symbols stuff as part of a later patch series about optimizing relocate_code -- that will go to [NEXT] since we're outside the merge window now.
Amicalement,
Signature · 1 line
Albert.
v3 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDThis series replaces all instances of relocate_code in various start.S files from the ARM architecture with a single instance in arch/arm/lib/relocate.S.
This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to relocate_code
In SPL of mx31pdk, board_init_f calls relocate_code to move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.
2. Drop tx25 SPL call to relocate_code
Same as mx31pdk.
3. Prevent all SPLs from assembling relocate_code
Now that no SPL uses relocate_code any more, remove it completely from SPL builds by putting it entirely between #ifndef CONFIG_SPL_BUILD and #endif preprocessor conditional.
4. Actual factorization of relocate_code
Remove all instances of relocate_code from start.S and create a new file, arch/arm/lib/relocate.S, to provide the new single instance of relocate_code.
The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from _start to addr_moni and local offsets (from relocate_code to several linker script symbols) have been verified.
Changes in v3:
- fixed bugs in relocation offset computations
- moved and fixed comment regarding linker symbols
- fix missing conditionals on PXA25X dcache code
- replaced FLASH/RAM mentions with SRC/DST ones
Changes in v2:
- dropped relocate_code() call from mx31pdk SPL
- dropped relocate_code() call from tx25 SPL
- dropped all relocate_code instances from SPL builds
Albert ARIBAUD (4):
mx31pdk: copy SPL directly, not using relocate_code.
tx25: copy SPL directly, not using relocate_code.
arm: do not compile relocate_code() for SPL builds
arm: factorize relocate_code routine
arch/arm/cpu/arm1136/start.S | 81 ---------------------------- arch/arm/cpu/arm1176/start.S | 77 --------------------------- arch/arm/cpu/arm720t/start.S | 77 --------------------------- arch/arm/cpu/arm920t/start.S | 77 --------------------------- arch/arm/cpu/arm925t/start.S | 77 --------------------------- arch/arm/cpu/arm926ejs/start.S | 81 ---------------------------- arch/arm/cpu/arm946es/start.S | 77 --------------------------- arch/arm/cpu/arm_intcm/start.S | 77 --------------------------- arch/arm/cpu/armv7/start.S | 78 --------------------------- arch/arm/cpu/ixp/start.S | 77 --------------------------- arch/arm/cpu/pxa/start.S | 97 ++++----------------------------- arch/arm/cpu/s3c44b0/start.S | 77 --------------------------- arch/arm/cpu/sa1100/start.S | 77 --------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 106 +++++++++++++++++++++++++++++++++++++ board/freescale/mx31pdk/mx31pdk.c | 16 +++++- board/karo/tx25/tx25.c | 16 +++++- 17 files changed, 148 insertions(+), 1021 deletions(-) create mode 100644 arch/arm/lib/relocate.S
Signature · 1 line
1.7.10.4
PATCH v3 1/4 mx31pdk: copy SPL directly, not using relocate_code.
---
Changes in v3:
- none
Changes in v2:
- drop relocate_code() call from mx31pdk SPL
board/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/freescale/mx31pdk/mx31pdk.c +15 -1
@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v3 2/4 tx25: copy SPL directly, not using relocate_code.
---
Changes in v3:
- none
Changes in v2:
- drop relocate_code() call from tx25 SPL
board/karo/tx25/tx25.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/karo/tx25/tx25.c +15 -1
@@ -35,7 +35,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v3 3/4 arm: do not compile relocate_code() for SPL builds
---
Changes in v3:
- none
Changes in v2:
- drop all relocate_code instances from SPL builds
arch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)
arch/arm/cpu/arm1136/start.S +3 -8
@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -173,6 +169,7 @@ next: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -195,7 +192,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -233,14 +229,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm1176/start.S +5 -6
@@ -112,10 +112,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -225,6 +221,7 @@ skip_tcmdisable: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -247,7 +244,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -285,12 +281,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -298,6 +295,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm720t/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm920t/start.S +5 -7
@@ -89,10 +89,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -194,6 +190,7 @@ copyex: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -216,7 +213,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -254,12 +250,12 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif - relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -267,6 +263,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm925t/start.S +5 -6
@@ -95,10 +95,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -184,6 +180,7 @@ poll1: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -206,7 +203,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -244,12 +240,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -257,6 +254,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm926ejs/start.S +3 -8
@@ -136,10 +136,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -190,6 +186,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -212,7 +209,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -250,14 +246,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm946es/start.S +5 -6
@@ -105,10 +105,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -159,6 +155,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -181,7 +178,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -219,12 +215,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -232,6 +229,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm_intcm/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/armv7/start.S +2 -4
@@ -94,10 +94,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -231,6 +227,8 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/ixp/start.S +5 -6
@@ -114,10 +114,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -257,6 +253,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -279,7 +276,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -317,12 +313,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -330,6 +327,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/pxa/start.S +2 -6
@@ -118,10 +118,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -201,7 +197,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -239,12 +234,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/s3c44b0/start.S +5 -6
@@ -80,10 +80,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -140,6 +136,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -162,7 +159,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -200,12 +196,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -213,6 +210,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/sa1100/start.S +5 -6
@@ -90,10 +90,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -144,6 +140,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -166,7 +163,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -204,12 +200,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -217,6 +214,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
Signature · 1 line
1.7.10.4
PATCH v3 4/4 arm: factorize relocate_code routine
Replace all relocate_code routines from ARM start.S files with a single instance in file arch/arm/lib/relocate.S. For PXA, this requires moving the dcache unlocking code from within relocate_code into c_runtime_cpu_setup.
---
Changes in v3:
- fix bugs in relocation offset computations
- move and fix comment regarding linker symbols
- fix missing conditionals on PXA25X dcache code
- replace FLASH/RAM mentions with SRC/DST ones
Changes in v2:
- use ENTRY / ENDPROC macros
- preserve PXA25X dcache unlocking
arch/arm/cpu/arm1136/start.S | 76 ---------------------------- arch/arm/cpu/arm1176/start.S | 76 ---------------------------- arch/arm/cpu/arm720t/start.S | 76 ---------------------------- arch/arm/cpu/arm920t/start.S | 75 ---------------------------- arch/arm/cpu/arm925t/start.S | 76 ---------------------------- arch/arm/cpu/arm926ejs/start.S | 76 ---------------------------- arch/arm/cpu/arm946es/start.S | 76 ---------------------------- arch/arm/cpu/arm_intcm/start.S | 76 ---------------------------- arch/arm/cpu/armv7/start.S | 76 ---------------------------- arch/arm/cpu/ixp/start.S | 76 ---------------------------- arch/arm/cpu/pxa/start.S | 93 +++++------------------------------ arch/arm/cpu/s3c44b0/start.S | 76 ---------------------------- arch/arm/cpu/sa1100/start.S | 76 ---------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 106 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 118 insertions(+), 993 deletions(-) create mode 100644 arch/arm/lib/relocate.S
arch/arm/cpu/arm1136/start.S +0 -76
@@ -169,82 +169,6 @@ next: /*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop - -relocate_done: - - bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif - .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm1176/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm720t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm920t/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm925t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm926ejs/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm946es/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm_intcm/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/ixp/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/pxa/start.S +11 -82
105 lines not on this page · raw message
arch/arm/cpu/s3c44b0/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/sa1100/start.S +0 -76
82 lines not on this page · raw message
arch/arm/lib/Makefile +1 -0
@@ -39,6 +39,7 @@ GLCOBJS += div0.o SOBJS-y += crt0.o ifndef CONFIG_SPL_BUILD +SOBJS-y += relocate.o ifndef CONFIG_SYS_GENERIC_BOARD COBJS-y += board.o endif
arch/arm/lib/relocate.S new file +106 -0
106 lines not on this page · raw message
Signature · 1 line
1.7.10.4
PATCH v3 4/4 arm: factorize relocate_code routine
Hi Albert,
Quoted 16 lines · Albert ARIBAUD
Replace all
relocate_coderoutines from ARMstart.Sfiles with a single instance in filearch/arm/lib/relocate.S. For PXA, this requires moving the dcache unlocking code from withinrelocate_codeintoc_runtime_cpu_setup.Signed-off-by Albert ARIBAUD <[email protected]>---
Changes in v3:
- fix bugs in relocation offset computations
- move and fix comment regarding linker symbols
- fix missing conditionals on PXA25X dcache code
- replace FLASH/RAM mentions with SRC/DST onesChanges in v2:
- use ENTRY / ENDPROC macros
- preserve PXA25X dcache unlocking
[...]
Quoted 97 lines
arch/arm/cpu/pxa/start.S +11
-73@@ -167,94 +167,23 @@ reset: bl _main /*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ -/* Disable the Dcache RAM lock for stack now */ -#ifdef CONFIG_CPU_PXA25X - mov r12, lr - bl cpu_init_crit - mov lr, r12 -#endif - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop + .globl c_runtime_cpu_setup +c_runtime_cpu_setup: +#ifdef CONFIG_CPU_PXA25X /* - * fix .rel.dyn relocations + * Unlock (actually, disable) the cache now that board_init_f + * is done. We could do this earlier but we would need to add + * a new C runtime hook, whereas c_runtime_cpu_setup already + * exists. + * As this routine is just a call to cpu_init_crit, let us + * tail-optimize and do a simple branch here. */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop - -relocate_done: - + b cpu_init_crit +#else bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start
arch/arm/cpu/pxa/start.S reset: · line 257
Quoted 10 lines
arch/arm/cpu/pxa/start.S +0
-9-_dynsym_start_ofs: - .word __dynsym_start - _start - #endif - - .globl c_runtime_cpu_setup -c_runtime_cpu_setup: - - bx lr -
Keeping an empty line here would be good for code clarity.
Quoted 3 lines
arch/arm/cpu/pxa/start.S +0
-0/* ************************************************************************* *
[...]
Quoted 45 lines
arch/arm/lib/relocate.S new file +34
-0@@ -0,0 +1,106 @@ +/* + * relocate - common relocation function for ARM U-Boot + * + * Copyright (c) 2013 Albert ARIBAUD <[email protected]> + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <linux/linkage.h> + +/* + * void relocate_code(addr_moni) + * + * This function relocates the monitor code. + * + * NOTE: + * To prevent the code below from containing references with an R_ARM_ABS32 + * relocation record type, we never refer to linker-defined symbolsdirectly.
+ * Instead, we declare literals which contain their relative location with
+ * respect torelocate_code, and at run time, addrelocate_codeback to them.
+ */
arch/arm/lib/relocate.S line 42
Quoted 5 lines
arch/arm/lib/relocate.S new file +5
-0+ +ENTRY(relocate_code) + mov r6, r0 /* save addr of destination */ + + ldr r0, =_start /* r0 <- SRC _start */
Or "&_start" in the comment above to be more consistent with the comments below.
Quoted 12 lines
arch/arm/lib/relocate.S new file +12
-0+ subs r9, r6, r0 /* r9 <- relocation offset */ + beq relocate_done /* skip relocation */ + mov r1, r6 /* r1 <- scratch for copy loop */ + adr r7, relocate_code /* r7 <- SRC &relocate_code */ + ldr r3, _image_copy_end_ofs /* r3 <- __image_copy_end local ofs */ + add r2, r7, r3 /* r2 <- SRC &__image_copy_end */ + +copy_loop: + ldmia r0!, {r10-r11} /* copy from source address [r0] */ + stmia r1!, {r10-r11} /* copy to target address [r1] */ + cmp r0, r2 /* until source end address [r2] */ + blo copy_loop
arch/arm/lib/relocate.S line 64
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ + /* + * fix .rel.dyn relocations + */ + ldr r10, _dynsym_start_ofs /* r10 <- __dynsym_start local ofs */ + add r10, r10, r7 /* r10 <- SRC &__dynsym_start */ + ldr r2, _rel_dyn_start_ofs /* r2 <- _rel_dyn_start local ofs */ + add r2, r2, r7 /* r2 <- SRC &_rel_dyn_start */ + ldr r3, _rel_dyn_end_ofs /* r3 <- _rel_dyn_end local ofs */ + add r3, r3, r7 /* r3 <- SRC &_rel_dyn_end */
It's __rel_dyn_start and __rel_dyn_end with 2 leading underscores in the 4 comments above.
Quoted 21 lines
arch/arm/lib/relocate.S new file +21
-0+fixloop: + ldr r0, [r2] /* r0 <- SRC location to fix up */ + add r0, r0, r9 /* r0 <- DST location to fix up */ + ldr r1, [r2, #4] + and r7, r1, #0xff + cmp r7, #23 /* relative fixup? */ + beq fixrel + cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ + b fixnext +fixrel: + /* relative fix: increase location by offset */ + ldr r1, [r0]
arch/arm/lib/relocate.S line 95
Quoted 10 lines
arch/arm/lib/relocate.S new file +10
-0+ add r1, r1, r9 +fixnext: + str r1, [r0] + add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ + cmp r2, r3 + blo fixloop + +relocate_done: + + bx lr
Argh! The "bx lr" issue is back. That was correct in v2.
Quoted 12 lines
arch/arm/lib/relocate.S new file +11
-1+ +_image_copy_end_ofs: + .word __image_copy_end - relocate_code +_rel_dyn_start_ofs: + .word __rel_dyn_start - relocate_code +_rel_dyn_end_ofs: + .word __rel_dyn_end - relocate_code +_dynsym_start_ofs: + .word __dynsym_start - relocate_code + +ENDPROC(relocate_code) --
Quoted 1 line
1.7.10.4
The rest of the v3 series is fine.
Best regards,
Beno?t
PATCH v3 4/4 arm: factorize relocate_code routine
Hi Beno?t,
Quoted 8 lines · Beno?t Th?baudeau
Hi Albert,
Keeping an empty line here would be good for code clarity.
Or "
&_start" in the comment above to be more consistent with the comments below.It's
__rel_dyn_startand__rel_dyn_endwith 2 leading underscores in the 4 comments above.
Will fix all three, thanks.
Quoted 1 line
Argh! The "bx lr" issue is back. That was correct in v2.
As you say: argh! Will fix, and apologies.
Quoted 1 line
The rest of the v3 series is fine.
Thanks for your review!
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
v3 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDQuoted 3 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.
Please ignore. Will post V4 in a few minutes.
Amicalement,
Signature · 1 line
Albert.
v3 cover Factorize ARM relocate_code instances
Hi Albert,
Quoted 8 lines · Albert ARIBAUD
Quoted 3 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.Please ignore. Will post V4 in a few minutes.
Correction, V3 is correct and can be reviewed.
Quoted 1 line
Amicalement,
Amicalement,
Signature · 1 line
Albert.
v4 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDThis series replaces all instances of relocate_code in various start.S files from the ARM architecture with a single instance in arch/arm/lib/relocate.S.
This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to relocate_code
In SPL of mx31pdk, board_init_f calls relocate_code to move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.
2. Drop tx25 SPL call to relocate_code
Same as mx31pdk.
3. Prevent all SPLs from assembling relocate_code
Now that no SPL uses relocate_code any more, remove it completely from SPL builds by putting it entirely between #ifndef CONFIG_SPL_BUILD and #endif preprocessor conditional.
4. Actual factorization of relocate_code
Remove all instances of relocate_code from start.S and create a new file, arch/arm/lib/relocate.S, to provide the new single instance of relocate_code.
The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from _start to addr_moni and local offsets (from relocate_code to several linker script symbols) have been verified.
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos in relocate_code comments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4
Changes in v3:
- fixed bugs in relocation offset computations
- moved and fixed comment regarding linker symbols
- fix missing conditionals on PXA25X dcache code
- replaced FLASH/RAM mentions with SRC/DST ones
Changes in v2:
- dropped relocate_code() call from mx31pdk SPL
- dropped relocate_code() call from tx25 SPL
- dropped all relocate_code instances from SPL builds
Albert ARIBAUD (4):
mx31pdk: copy SPL directly, not using relocate_code.
tx25: copy SPL directly, not using relocate_code.
arm: do not compile relocate_code() for SPL builds
arm: factorize relocate_code routine
arch/arm/cpu/arm1136/start.S | 81 --------------------------- arch/arm/cpu/arm1176/start.S | 77 ------------------------- arch/arm/cpu/arm720t/start.S | 77 ------------------------- arch/arm/cpu/arm920t/start.S | 77 ------------------------- arch/arm/cpu/arm925t/start.S | 77 ------------------------- arch/arm/cpu/arm926ejs/start.S | 81 --------------------------- arch/arm/cpu/arm946es/start.S | 77 ------------------------- arch/arm/cpu/arm_intcm/start.S | 77 ------------------------- arch/arm/cpu/armv7/start.S | 78 -------------------------- arch/arm/cpu/ixp/start.S | 77 ------------------------- arch/arm/cpu/pxa/start.S | 96 ++++--------------------------- arch/arm/cpu/s3c44b0/start.S | 77 ------------------------- arch/arm/cpu/sa1100/start.S | 77 ------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 112 +++++++++++++++++++++++++++++++++++++ board/freescale/mx31pdk/mx31pdk.c | 16 +++++- board/karo/tx25/tx25.c | 16 +++++- 17 files changed, 154 insertions(+), 1020 deletions(-) create mode 100644 arch/arm/lib/relocate.S
Signature · 1 line
1.7.10.4
PATCH v4 1/4 mx31pdk: copy SPL directly, not using relocate_code.
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- dropped relocate_code() call from mx31pdk SPL
board/freescale/mx31pdk/mx31pdk.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/freescale/mx31pdk/mx31pdk.c +15 -1
@@ -39,7 +39,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v4 2/4 tx25: copy SPL directly, not using relocate_code.
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- dropped relocate_code() call from tx25 SPL
board/karo/tx25/tx25.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
board/karo/tx25/tx25.c +15 -1
@@ -35,7 +35,21 @@ DECLARE_GLOBAL_DATA_PTR;#ifdef CONFIG_SPL_BUILD void board_init_f (ulong bootflag) { -relocate_code (CONFIG_SPL_TEXT_BASE ); +/* +* copy ourselves from where we are running to where we were +* linked at. Use ulong pointers as all addresses involved +* are 4-byte-aligned. +*/ +ulong *start_ptr, *end_ptr, *link_ptr, *run_ptr, *dst; + asmvolatile ("ldr %0, =_start" :"=r" (start_ptr)); + asmvolatile ("ldr %0, =_end" :"=r" (end_ptr)); + asmvolatile ("ldr %0, =board_init_f" :"=r" (link_ptr)); + asmvolatile ("adr %0, board_init_f" :"=r" (run_ptr)); +for (dst = start_ptr; dst < end_ptr; dst++) + *dst = *(dst+(run_ptr-link_ptr)); +/* +* branch to nand_boot's link-time address. +*/ asmvolatile ("ldr pc, =nand_boot" ); }#endif
Signature · 1 line
1.7.10.4
PATCH v4 3/4 arm: do not compile relocate_code() for SPL builds
---
Changes in v4: None
Changes in v3: None
Changes in v2:
- dropped all relocate_code instances from SPL builds
arch/arm/cpu/arm1136/start.S | 11 +++-------- arch/arm/cpu/arm1176/start.S | 11 +++++------ arch/arm/cpu/arm720t/start.S | 11 +++++------ arch/arm/cpu/arm920t/start.S | 12 +++++------- arch/arm/cpu/arm925t/start.S | 11 +++++------ arch/arm/cpu/arm926ejs/start.S | 11 +++-------- arch/arm/cpu/arm946es/start.S | 11 +++++------ arch/arm/cpu/arm_intcm/start.S | 11 +++++------ arch/arm/cpu/armv7/start.S | 6 ++---- arch/arm/cpu/ixp/start.S | 11 +++++------ arch/arm/cpu/pxa/start.S | 8 ++------ arch/arm/cpu/s3c44b0/start.S | 11 +++++------ arch/arm/cpu/sa1100/start.S | 11 +++++------ 13 files changed, 55 insertions(+), 81 deletions(-)
arch/arm/cpu/arm1136/start.S +3 -8
@@ -104,10 +104,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -173,6 +169,7 @@ next: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -195,7 +192,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -233,14 +229,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm1176/start.S +5 -6
@@ -112,10 +112,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -225,6 +221,7 @@ skip_tcmdisable: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -247,7 +244,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -285,12 +281,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -298,6 +295,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm720t/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm920t/start.S +5 -7
@@ -89,10 +89,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -194,6 +190,7 @@ copyex: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -216,7 +213,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -254,12 +250,12 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif - relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -267,6 +263,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm925t/start.S +5 -6
@@ -95,10 +95,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -184,6 +180,7 @@ poll1: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -206,7 +203,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -244,12 +240,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -257,6 +254,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm926ejs/start.S +3 -8
@@ -136,10 +136,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -190,6 +186,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -212,7 +209,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -250,14 +246,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr -#ifndef CONFIG_SPL_BUILD - +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/arm946es/start.S +5 -6
@@ -105,10 +105,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -159,6 +155,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -181,7 +178,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -219,12 +215,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -232,6 +229,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm_intcm/start.S +5 -6
@@ -101,10 +101,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -155,6 +151,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -177,7 +174,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -215,12 +211,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -228,6 +225,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/armv7/start.S +2 -4
@@ -94,10 +94,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -231,6 +227,8 @@ relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/ixp/start.S +5 -6
@@ -114,10 +114,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -257,6 +253,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -279,7 +276,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -317,12 +313,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -330,6 +327,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/pxa/start.S +2 -6
@@ -118,10 +118,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -201,7 +197,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -239,12 +234,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
arch/arm/cpu/s3c44b0/start.S +5 -6
@@ -80,10 +80,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -140,6 +136,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -162,7 +159,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -200,12 +196,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: bx lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -213,6 +210,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/sa1100/start.S +5 -6
@@ -90,10 +90,6 @@ _TEXT_BASE: _bss_start_ofs: .word __bss_start - _start -.globl _image_copy_end_ofs -_image_copy_end_ofs: - .word __image_copy_end - _start - .globl _bss_end_ofs _bss_end_ofs: .word __bss_end - _start
@@ -144,6 +140,7 @@ reset: /*------------------------------------------------------------------------------*/ +#ifndef CONFIG_SPL_BUILD /* * void relocate_code(addr_moni) *
@@ -166,7 +163,6 @@ copy_loop: cmp r0, r2 /* until source end address [r2] */ blo copy_loop -#ifndef CONFIG_SPL_BUILD /* * fix .rel.dyn relocations */
@@ -204,12 +200,13 @@ fixnext: add r2, r2, #8 /* each rel.dyn entry is 8 bytes */ cmp r2, r3 blo fixloop -#endif relocate_done: mov pc, lr +_image_copy_end_ofs: + .word __image_copy_end - _start _rel_dyn_start_ofs: .word __rel_dyn_start - _start _rel_dyn_end_ofs:
@@ -217,6 +214,8 @@ _rel_dyn_end_ofs: _dynsym_start_ofs: .word __dynsym_start - _start +#endif + .globl c_runtime_cpu_setup c_runtime_cpu_setup:
Signature · 1 line
1.7.10.4
PATCH v4 4/4 arm: factorize relocate_code routine
Replace all relocate_code routines from ARM start.S files with a single instance in file arch/arm/lib/relocate.S. For PXA, this requires moving the dcache unlocking code from within relocate_code into c_runtime_cpu_setup.
---
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos in relocate_code comments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4
Changes in v3:
- fixed bugs in relocation offset computations
- moved and fixed comment regarding linker symbols
- fix missing conditionals on PXA25X dcache code
- replaced FLASH/RAM mentions with SRC/DST ones
Changes in v2: None
arch/arm/cpu/arm1136/start.S | 76 --------------------------- arch/arm/cpu/arm1176/start.S | 76 --------------------------- arch/arm/cpu/arm720t/start.S | 76 --------------------------- arch/arm/cpu/arm920t/start.S | 75 --------------------------- arch/arm/cpu/arm925t/start.S | 76 --------------------------- arch/arm/cpu/arm926ejs/start.S | 76 --------------------------- arch/arm/cpu/arm946es/start.S | 76 --------------------------- arch/arm/cpu/arm_intcm/start.S | 76 --------------------------- arch/arm/cpu/armv7/start.S | 76 --------------------------- arch/arm/cpu/ixp/start.S | 76 --------------------------- arch/arm/cpu/pxa/start.S | 92 ++++----------------------------- arch/arm/cpu/s3c44b0/start.S | 76 --------------------------- arch/arm/cpu/sa1100/start.S | 76 --------------------------- arch/arm/lib/Makefile | 1 + arch/arm/lib/relocate.S | 112 ++++++++++++++++++++++++++++++++++++++++ 15 files changed, 124 insertions(+), 992 deletions(-) create mode 100644 arch/arm/lib/relocate.S
arch/arm/cpu/arm1136/start.S +0 -76
@@ -169,82 +169,6 @@ next: /*------------------------------------------------------------------------------*/ -#ifndef CONFIG_SPL_BUILD -/* - * void relocate_code(addr_moni) - * - * This function relocates the monitor code. - */ - .globl relocate_code -relocate_code: - mov r6, r0 /* save addr of destination */ - - adr r0, _start - subs r9, r6, r0 /* r9 <- relocation offset */ - beq relocate_done /* skip relocation */ - mov r1, r6 /* r1 <- scratch for copy_loop */ - ldr r3, _image_copy_end_ofs - add r2, r0, r3 /* r2 <- source end address */ - -copy_loop: - ldmia r0!, {r10-r11} /* copy from source address [r0] */ - stmia r1!, {r10-r11} /* copy to target address [r1] */ - cmp r0, r2 /* until source end address [r2] */ - blo copy_loop - - /* - * fix .rel.dyn relocations - */ - ldr r0, _TEXT_BASE /* r0 <- Text base */ - 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 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 r7, r1, #0xff - cmp r7, #23 /* relative fixup? */ - beq fixrel - cmp r7, #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, r1, r9 /* r1 <- relocated sym addr */ - 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 - blo fixloop - -relocate_done: - - bx lr - -_image_copy_end_ofs: - .word __image_copy_end - _start -_rel_dyn_start_ofs: - .word __rel_dyn_start - _start -_rel_dyn_end_ofs: - .word __rel_dyn_end - _start -_dynsym_start_ofs: - .word __dynsym_start - _start - -#endif - .globl c_runtime_cpu_setup c_runtime_cpu_setup:
arch/arm/cpu/arm1176/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm720t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm920t/start.S +0 -75
81 lines not on this page · raw message
arch/arm/cpu/arm925t/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm926ejs/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm946es/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/arm_intcm/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/armv7/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/ixp/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/pxa/start.S +11 -81
105 lines not on this page · raw message
arch/arm/cpu/s3c44b0/start.S +0 -76
82 lines not on this page · raw message
arch/arm/cpu/sa1100/start.S +0 -76
82 lines not on this page · raw message
arch/arm/lib/Makefile +1 -0
@@ -39,6 +39,7 @@ GLCOBJS += div0.o SOBJS-y += crt0.o ifndef CONFIG_SPL_BUILD +SOBJS-y += relocate.o ifndef CONFIG_SYS_GENERIC_BOARD COBJS-y += board.o endif
arch/arm/lib/relocate.S new file +112 -0
112 lines not on this page · raw message
Signature · 1 line
1.7.10.4
v4 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDHi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.
Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4
[...]
Perfect!
For this v4 series:
Best regards,
Beno?t
v4 cover Factorize ARM relocate_code instances
Hi Beno?t,
Quoted 52 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4
Quoted 6 lines
[...]
Perfect!
For this v4 series:
Reviewed-by Beno?t Th?baudeau <[email protected]>
Thanks Beno?t!
Now I need some people to regression-test it on their HW, both ARM and non-ARM just in case.
Quoted 2 lines
Best regards,
Beno?t
Amicalement,
Signature · 1 line
Albert.
v4 cover Factorize ARM relocate_code instances
Hi Fabio, Stefano,
Quoted 61 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 56 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4[...]
Perfect!
Quoted 7 lines
Quoted 2 lines
For this v4 series:
Reviewed-by Beno?t Th?baudeau <[email protected]>Thanks Beno?t!
Now I need some people to regression-test it on their HW, both ARM and non-ARM just in case.
Can you test this series on mx31pdk (directly changed by this series), and some other i.MX EVK (e.g. ARMv7, so mx51evk or mx53*) board please? That should be enough for ARM.
Best regards,
Beno?t
Fabio Estevam
reviewerv4 cover Factorize ARM relocate_code instances
Hi Beno?t,
Quoted 3 lines · Beno?t Th?baudeau
Can you test this series on mx31pdk (directly changed by this series), and some other i.MX EVK (e.g. ARMv7, so mx51evk or mx53*) board please? That should be enough for ARM.
I don't have access to my mx31pdk currently, but I will try to get access to it later this week.
Then I can test this series on mx31pdk and also on mx53loco.
Regards,
Fabio Estevam
v4 cover Factorize ARM relocate_code instances
Hi Fabio,
Quoted 5 lines · Fabio Estevam
Hi Beno?t,
On Mon, May 20, 2013 at 12:39 PM, Beno?t Th?baudeau <[email protected]> wrote:
Quoted 8 lines
Quoted 3 lines
Can you test this series on mx31pdk (directly changed by this series), and some other i.MX EVK (e.g. ARMv7, so mx51evk or mx53*) board please? That should be enough for ARM.
I don't have access to my mx31pdk currently, but I will try to get access to it later this week.
Then I can test this series on mx31pdk and also on mx53loco.
Did you manage this test? If you did and it succeeded, then I'll merge the series into u-boot-arm.
Quoted 3 lines
Regards,
Fabio Estevam
Amicalement,
Signature · 1 line
Albert.
Fabio Estevam
reviewerv4 cover Factorize ARM relocate_code instances
Hi Albert,
Quoted 2 lines · Albert ARIBAUD
Did you manage this test? If you did and it succeeded, then I'll merge the series into u-boot-arm.
Unfortunately I did not manage to find some spare time to test this, sorry.
Please go ahead and apply them.
Hopefully I will be able to test next week and then I will report in case of any issue.
Thanks,
Fabio Estevam
v4 cover Factorize ARM relocate_code instances
In reply to Albert ARIBAUDHi Albert,
Quoted 61 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 56 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4[...]
Perfect!
Quoted 8 lines
Quoted 2 lines
For this v4 series:
Reviewed-by Beno?t Th?baudeau <[email protected]>Thanks Beno?t!
Now I need some people to regression-test it on their HW, both ARM and non-ARM just in case.
Tested on snow (ARMv7) and link (x86), seems fine.
The series:
Re your second series containing 'arm: optimize relocate_code routine<http://patchwork.ozlabs.org/patch/243817/>',
I ended up with conflicts here - perhaps because the first series was updated. I would like to test that also, as it should make it possible to remove CONFIG_SYS_TEXT_BASE which is currently of interest.
Regards,
Simon
Quoted 12 lines
Quoted 3 lines
Best regards,
Beno?tAmicalement,
--
Albert.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
v4 cover Factorize ARM relocate_code instances
Hi Simon,
Quoted 75 lines · Simon Glass
Hi Albert,
Quoted 61 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 56 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4[...]
Perfect!
Quoted 8 lines
Quoted 2 lines
For this v4 series:
Reviewed-by Beno?t Th?baudeau <[email protected]>Thanks Beno?t!
Now I need some people to regression-test it on their HW, both ARM and non-ARM just in case.
Quoted 5 lines
Tested on snow (ARMv7) and link (x86), seems fine.
The series:
Tested-by Simon Glass <[email protected]>
thanks a lot!
Quoted 5 lines
Re your second series containing 'arm: optimize
relocate_coderoutine<http://patchwork.ozlabs.org/patch/243817/>',
I ended up with conflicts here - perhaps because the first series was updated. I would like to test that also, as it should make it possible to removeCONFIG_SYS_TEXT_BASEwhich is currently of interest.
Thanks Simon. I have to rebase and repost the second series indeed; will do this tonight. Note that it was first posted after merge window closure, so if you need it for things planned in 2013.07, then I'll have to ask for Tom's agreement to put the second series in 2013.07.
Quoted 2 lines
Regards,
Simon
Amicalement,
Signature · 1 line
Albert.
v4 cover Factorize ARM relocate_code instances
Hi Albert,
Quoted 94 lines · Albert ARIBAUD
Hi Simon,
Quoted 75 lines · Simon Glass
Hi Albert,
Quoted 61 lines · Albert ARIBAUD
Hi Beno?t,
Quoted 56 lines · Beno?t Th?baudeau
Hi Albert,
Quoted 44 lines · Albert ARIBAUD
This series replaces all instances of
relocate_codein variousstart.Sfiles from the ARM architecture with a single instance inarch/arm/lib/relocate.S.This is done in steps, each step keeping the whole of ARM U-Boot buildable and runnable and touching as little code as necessary.
1. Drop mx31pdk SPL call to
relocate_codeIn SPL of mx31pdk,
board_init_fcallsrelocate_codeto move SPL from the NAND read buffer to SRAM. This move is not a relocation and is thus better implemented as a simple ad hoc copy loop.2. Drop tx25 SPL call to
relocate_codeSame as mx31pdk.
3. Prevent all SPLs from assembling
relocate_codeNow that no SPL uses
relocate_codeany more, remove it completely from SPL builds by putting it entirely between #ifndefCONFIG_SPL_BUILDand #endif preprocessor conditional.4. Actual factorization of
relocate_codeRemove all instances of
relocate_codefromstart.Sand create a new file,arch/arm/lib/relocate.S, to provide the new single instance ofrelocate_code.The only non-trivial change is that for PXA25X, a call to unlock (actually disable) dcache is moved from before relocating to after relocating. As this cache is either locked-as-RAM or disabled, but never used as actual DDR cache, this move has no performance effect on relocation and no functional impact either.
The relocation routine was step-tested on versatileqemu under gdb. Especially, both relocation offset (from
_starttoaddr_moniand local offsets (fromrelocate_codeto several linker script symbols) have been verified.Quoted 4 lines
Changes in v4:
- added blank line after PXA25X conditional code
- fixed typos inrelocate_codecomments
- brought back 'mov pc,lr' instead of 'bx lr' for ARMv4[...]
Perfect!
Quoted 8 lines
Quoted 2 lines
For this v4 series:
Reviewed-by Beno?t Th?baudeau <[email protected]>Thanks Beno?t!
Now I need some people to regression-test it on their HW, both ARM and non-ARM just in case.
Quoted 5 lines
Tested on snow (ARMv7) and link (x86), seems fine.
The series:
Tested-by Simon Glass <[email protected]>thanks a lot!
Quoted 5 lines
Re your second series containing 'arm: optimize
relocate_coderoutine<http://patchwork.ozlabs.org/patch/243817/>',
I ended up with conflicts here - perhaps because the first series was updated. I would like to test that also, as it should make it possible to removeCONFIG_SYS_TEXT_BASEwhich is currently of interest.
Quoted 5 lines
Thanks Simon. I have to rebase and repost the second series indeed; will do this tonight. Note that it was first posted after merge window closure, so if you need it for things planned in 2013.07, then I'll have to ask for Tom's agreement to put the second series in 2013.07.
Sounds good. I think it would be really nice to clean all this up, not sure about timeframe though. I don't have anything yet posted that depends on it, but I will once I get it running (reprise the generic relocation idea).
Regards,
Simon
Quoted 8 lines
Quoted 3 lines
Regards,
SimonAmicalement,
--
Albert.