Patchwork [U-Boot,v7,11/19] arm: relocate_code(): Use __image_copy_end for end of relocation

login
register
mail settings
Submitter Benoît Thébaudeau
Date Feb. 15, 2013, 8:54 p.m.
Message ID <1360961665-10693-11-git-send-email-benoit.thebaudeau@advansee.com>
Download mbox | patch
Permalink /patch/220865/
State Superseded
Delegated to: Stefano Babic
Headers show

Comments

Benoît Thébaudeau - Feb. 15, 2013, 8:54 p.m.
Use __image_copy_end instead of __bss_start for the end of the image to
relocate. This is the same as commit 033ca72, but applied to all ARM start.S.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
---
Changes in v7: None
Changes in v6:
 - New patch.

Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/arm/cpu/arm1176/start.S               |    6 +++++-
 arch/arm/cpu/arm720t/start.S               |    6 +++++-
 arch/arm/cpu/arm920t/ep93xx/u-boot.lds     |    3 +++
 arch/arm/cpu/arm920t/start.S               |    6 +++++-
 arch/arm/cpu/arm925t/start.S               |    6 +++++-
 arch/arm/cpu/arm926ejs/start.S             |    6 +++++-
 arch/arm/cpu/arm946es/start.S              |    6 +++++-
 arch/arm/cpu/arm_intcm/start.S             |    6 +++++-
 arch/arm/cpu/ixp/start.S                   |    6 +++++-
 arch/arm/cpu/ixp/u-boot.lds                |    2 ++
 arch/arm/cpu/pxa/start.S                   |    6 +++++-
 arch/arm/cpu/s3c44b0/start.S               |    6 +++++-
 arch/arm/cpu/sa1100/start.S                |    6 +++++-
 board/actux1/u-boot.lds                    |    3 +++
 board/actux2/u-boot.lds                    |    3 +++
 board/actux3/u-boot.lds                    |    3 +++
 board/davinci/da8xxevm/u-boot-spl-hawk.lds |    1 +
 board/dvlhost/u-boot.lds                   |    3 +++
 board/samsung/smdk6400/u-boot-nand.lds     |    4 ++++
 board/vpac270/u-boot-spl.lds               |    2 ++
 nand_spl/board/karo/tx25/u-boot.lds        |    2 ++
 nand_spl/board/samsung/smdk6400/u-boot.lds |    2 ++
 22 files changed, 83 insertions(+), 11 deletions(-)
Albert ARIBAUD - Feb. 16, 2013, 6:47 p.m.
Hi Benoît,

On Fri, 15 Feb 2013 21:54:17 +0100, Benoît Thébaudeau
<benoit.thebaudeau@advansee.com> wrote:

> Use __image_copy_end instead of __bss_start for the end of the image to
> relocate. This is the same as commit 033ca72, but applied to all ARM start.S.

What is the benefit of this? I find it more logical for BSS-related
code to use a BSS-related symbol than an image-copy related symbol.

Amicalement,
Benoît Thébaudeau - Feb. 16, 2013, 7:54 p.m.
Hi Albert,

On Saturday, February 16, 2013 7:47:13 PM, Albert ARIBAUD wrote:
> Hi Benoît,
> 
> On Fri, 15 Feb 2013 21:54:17 +0100, Benoît Thébaudeau
> <benoit.thebaudeau@advansee.com> wrote:
> 
> > Use __image_copy_end instead of __bss_start for the end of the image to
> > relocate. This is the same as commit 033ca72, but applied to all ARM
> > start.S.
> 
> What is the benefit of this? I find it more logical for BSS-related
> code to use a BSS-related symbol than an image-copy related symbol.

I don't see why you are talking about BSS-related code. This piece of code is
just supposed to copy the text and rodata from the source image to its
destination location, before optionally relocating its symbols. BSS has nothing
to do with this, so I find this image-copy symbol more appropriate here.

But besides the naming, the benefit is also that some linker scripts put some
stuff (e.g. MMU tables used early before jumping to relocated code, or
relocation info) between this __image_copy_end and __bss_start, that does not
have to be copied or relocated, so this patch saves a useless data copy in that
case.

Best regards,
Benoît
Albert ARIBAUD - Feb. 17, 2013, 2:30 p.m.
Hi Benoît,

On Sat, 16 Feb 2013 20:54:01 +0100 (CET), Benoît Thébaudeau
<benoit.thebaudeau@advansee.com> wrote:

> Hi Albert,
> 
> On Saturday, February 16, 2013 7:47:13 PM, Albert ARIBAUD wrote:
> > Hi Benoît,
> > 
> > On Fri, 15 Feb 2013 21:54:17 +0100, Benoît Thébaudeau
> > <benoit.thebaudeau@advansee.com> wrote:
> > 
> > > Use __image_copy_end instead of __bss_start for the end of the image to
> > > relocate. This is the same as commit 033ca72, but applied to all ARM
> > > start.S.
> > 
> > What is the benefit of this? I find it more logical for BSS-related
> > code to use a BSS-related symbol than an image-copy related symbol.
> 
> I don't see why you are talking about BSS-related code. This piece of code is
> just supposed to copy the text and rodata from the source image to its
> destination location, before optionally relocating its symbols. BSS has nothing
> to do with this, so I find this image-copy symbol more appropriate here.
> 
> But besides the naming, the benefit is also that some linker scripts put some
> stuff (e.g. MMU tables used early before jumping to relocated code, or
> relocation info) between this __image_copy_end and __bss_start, that does not
> have to be copied or relocated, so this patch saves a useless data copy in that
> case.

Apologies -- this is indeed copy-related, not BSS-related, code, and
thus the image-copy related symbol is apt, and your additional note
makes it all the more valid.

> Best regards,
> Benoît

Amicalement,

Patch

diff --git a/arch/arm/cpu/arm1176/start.S b/arch/arm/cpu/arm1176/start.S
index 9617249..e7d2737 100644
--- a/arch/arm/cpu/arm1176/start.S
+++ b/arch/arm/cpu/arm1176/start.S
@@ -127,6 +127,10 @@  _TEXT_PHY_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -253,7 +257,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm720t/start.S b/arch/arm/cpu/arm720t/start.S
index d2d8b53..440aff5 100644
--- a/arch/arm/cpu/arm720t/start.S
+++ b/arch/arm/cpu/arm720t/start.S
@@ -101,6 +101,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -168,7 +172,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm920t/ep93xx/u-boot.lds b/arch/arm/cpu/arm920t/ep93xx/u-boot.lds
index 008ae89..62315de 100644
--- a/arch/arm/cpu/arm920t/ep93xx/u-boot.lds
+++ b/arch/arm/cpu/arm920t/ep93xx/u-boot.lds
@@ -55,6 +55,9 @@  SECTIONS
 	}
 
 	. = ALIGN(4);
+
+	__image_copy_end = .;
+
 	__bss_start = .;
 	.bss : { *(.bss) }
 	__bss_end__ = .;
diff --git a/arch/arm/cpu/arm920t/start.S b/arch/arm/cpu/arm920t/start.S
index 683cf55..60b6a80 100644
--- a/arch/arm/cpu/arm920t/start.S
+++ b/arch/arm/cpu/arm920t/start.S
@@ -89,6 +89,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -207,7 +211,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm925t/start.S b/arch/arm/cpu/arm925t/start.S
index 5e81bdf..6d5c9de 100644
--- a/arch/arm/cpu/arm925t/start.S
+++ b/arch/arm/cpu/arm925t/start.S
@@ -95,6 +95,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -197,7 +201,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 93916af..70551ec 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -140,6 +140,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -214,7 +218,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm946es/start.S b/arch/arm/cpu/arm946es/start.S
index 6ecf7ec..8a245e0 100644
--- a/arch/arm/cpu/arm946es/start.S
+++ b/arch/arm/cpu/arm946es/start.S
@@ -105,6 +105,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -172,7 +176,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/arm_intcm/start.S b/arch/arm/cpu/arm_intcm/start.S
index fcfd367..9e1a34e 100644
--- a/arch/arm/cpu/arm_intcm/start.S
+++ b/arch/arm/cpu/arm_intcm/start.S
@@ -101,6 +101,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -168,7 +172,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/ixp/start.S b/arch/arm/cpu/ixp/start.S
index be8fcac..96cc014 100644
--- a/arch/arm/cpu/ixp/start.S
+++ b/arch/arm/cpu/ixp/start.S
@@ -114,6 +114,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -270,7 +274,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/ixp/u-boot.lds b/arch/arm/cpu/ixp/u-boot.lds
index 81d954f..d9bb5da 100644
--- a/arch/arm/cpu/ixp/u-boot.lds
+++ b/arch/arm/cpu/ixp/u-boot.lds
@@ -54,6 +54,8 @@  SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index fa7d4ab..f555851 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -118,6 +118,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -192,7 +196,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/s3c44b0/start.S b/arch/arm/cpu/s3c44b0/start.S
index 757eadc..e34e387 100644
--- a/arch/arm/cpu/s3c44b0/start.S
+++ b/arch/arm/cpu/s3c44b0/start.S
@@ -80,6 +80,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -153,7 +157,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/arch/arm/cpu/sa1100/start.S b/arch/arm/cpu/sa1100/start.S
index 6480ac4..fb58977 100644
--- a/arch/arm/cpu/sa1100/start.S
+++ b/arch/arm/cpu/sa1100/start.S
@@ -90,6 +90,10 @@  _TEXT_BASE:
 _bss_start_ofs:
 	.word __bss_start - _start
 
+.global	_image_copy_end_ofs
+_image_copy_end_ofs:
+	.word 	__image_copy_end - _start
+
 .globl _bss_end_ofs
 _bss_end_ofs:
 	.word __bss_end__ - _start
@@ -157,7 +161,7 @@  relocate_code:
 	cmp	r0, r6
 	beq	relocate_done		/* skip relocation */
 	mov	r1, r6			/* r1 <- scratch for copy_loop */
-	ldr	r3, _bss_start_ofs
+	ldr	r3, _image_copy_end_ofs
 	add	r2, r0, r3		/* r2 <- source end address	    */
 
 copy_loop:
diff --git a/board/actux1/u-boot.lds b/board/actux1/u-boot.lds
index c41eed0..34ed90d 100644
--- a/board/actux1/u-boot.lds
+++ b/board/actux1/u-boot.lds
@@ -61,6 +61,9 @@  SECTIONS
 	}
 
 	. = ALIGN (4);
+
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/board/actux2/u-boot.lds b/board/actux2/u-boot.lds
index 8409984..8337457 100644
--- a/board/actux2/u-boot.lds
+++ b/board/actux2/u-boot.lds
@@ -61,6 +61,9 @@  SECTIONS
 	}
 
 	. = ALIGN (4);
+
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/board/actux3/u-boot.lds b/board/actux3/u-boot.lds
index a3bd02b..a72a666 100644
--- a/board/actux3/u-boot.lds
+++ b/board/actux3/u-boot.lds
@@ -61,6 +61,9 @@  SECTIONS
 	}
 
 	. = ALIGN (4);
+
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/board/davinci/da8xxevm/u-boot-spl-hawk.lds b/board/davinci/da8xxevm/u-boot-spl-hawk.lds
index 86dc172..174955e 100644
--- a/board/davinci/da8xxevm/u-boot-spl-hawk.lds
+++ b/board/davinci/da8xxevm/u-boot-spl-hawk.lds
@@ -63,6 +63,7 @@  SECTIONS
 	}
 
 	. = ALIGN(4);
+	__image_copy_end = .;
 	__rel_dyn_start = .;
 	__rel_dyn_end = .;
 	__dynsym_start = .;
diff --git a/board/dvlhost/u-boot.lds b/board/dvlhost/u-boot.lds
index 1bd1700..9c14daa 100644
--- a/board/dvlhost/u-boot.lds
+++ b/board/dvlhost/u-boot.lds
@@ -61,6 +61,9 @@  SECTIONS
 	}
 
 	. = ALIGN (4);
+
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/board/samsung/smdk6400/u-boot-nand.lds b/board/samsung/smdk6400/u-boot-nand.lds
index fbb442a..2c3a60b 100644
--- a/board/samsung/smdk6400/u-boot-nand.lds
+++ b/board/samsung/smdk6400/u-boot-nand.lds
@@ -53,6 +53,10 @@  SECTIONS
 		#include <u-boot.lst>
 	}
 
+	. = ALIGN(4);
+
+	__image_copy_end = .;
+
 	. = align(4);
 	.mmudata : { *(.mmudata) }
 
diff --git a/board/vpac270/u-boot-spl.lds b/board/vpac270/u-boot-spl.lds
index 20161a4..e344436 100644
--- a/board/vpac270/u-boot-spl.lds
+++ b/board/vpac270/u-boot-spl.lds
@@ -63,6 +63,8 @@  SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/nand_spl/board/karo/tx25/u-boot.lds b/nand_spl/board/karo/tx25/u-boot.lds
index ee36131..95ea8ac 100644
--- a/nand_spl/board/karo/tx25/u-boot.lds
+++ b/nand_spl/board/karo/tx25/u-boot.lds
@@ -54,6 +54,8 @@  SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 		__rel_dyn_start = .;
 		*(.rel*)
diff --git a/nand_spl/board/samsung/smdk6400/u-boot.lds b/nand_spl/board/samsung/smdk6400/u-boot.lds
index 2ed6466..293ae02 100644
--- a/nand_spl/board/samsung/smdk6400/u-boot.lds
+++ b/nand_spl/board/samsung/smdk6400/u-boot.lds
@@ -58,6 +58,8 @@  SECTIONS
 
 	. = ALIGN(4);
 
+	__image_copy_end = .;
+
 	.rel.dyn : {
 	__rel_dyn_start = .;
 	*(.rel*)