public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with -msingle-pic-base
Date: Thu, 23 Sep 2010 09:12:10 +0200	[thread overview]
Message-ID: <4C9AFDCA.9090903@denx.de> (raw)
In-Reply-To: <1285163872-20910-2-git-send-email-albert.aribaud@free.fr>

Hello Albert,

Albert Aribaud wrote:
> Add -msingle-pic-base to the relocation flags, and compute the pic base
> in start.S twice and for all -- once before relocation to run board_init_f,
> and once after relocation to run board_init_r and the rest of u-boot.
> This further reduces code size by 2.5% compared to -fPIE alone.
> 
> Signed-off-by: Albert Aribaud <albert.aribaud@free.fr>
> ---
>  arch/arm/cpu/arm926ejs/config.mk  |    5 ++++
>  arch/arm/cpu/arm926ejs/start.S    |   40 ++++++++++++++++++++++++++++++++++--
>  arch/arm/cpu/arm926ejs/u-boot.lds |    1 +
>  3 files changed, 43 insertions(+), 3 deletions(-)

I get with your 2 patches for the tx25 board:

[hs at pollux u-boot]$ ./MAKEALL tx25
Configuring for tx25 board...
/home/hs/celf/u-boot/arch/arm/cpu/arm926ejs/start.S: Assembler messages:
/home/hs/celf/u-boot/arch/arm/cpu/arm926ejs/start.S:212: Error: internal_relocation (type: OFFSET_IMM) not fixed up
/home/hs/celf/u-boot/arch/arm/cpu/arm926ejs/start.S:308: Error: internal_relocation (type: OFFSET_IMM) not fixed up
make[1]: *** [start.o] Fehler 1
make: *** [nand_spl] Fehler 2
make: *** Warte auf noch nicht beendete Prozesse...
make: INTERNAL: Exiting with 4 jobserver tokens available; should be 3!
arm-linux-size: './u-boot': No such file

--------------------- SUMMARY ----------------------------
Boards compiled: 1
Boards with warnings or errors: 1 ( tx25 )
----------------------------------------------------------
[hs at pollux u-boot]$

below fix fixes this issue :-)

I had to define _got_base and _relocate_got_base_r also for
the NAND_SPL case, and don;t need to fix up the "pic base
register", if we are at the right position.

I think we(you ;-) should add my below fix to your

[U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with	-msingle-pic-base

and send a second version of it, so we are bisect compatible.

you can add my

Signed-off-by: Heiko Schocher <hs@denx.de>

to it.

Can you test this also on your board? Thanks!

actual next build for the tx25 board:

[hs at pollux u-boot]$ ./MAKEALL tx25
Configuring for tx25 board...
   text    data     bss     dec     hex filename
 149540    9368   36980  195888   2fd30 ./u-boot

with your 2 patches, and my below fix:

[U-Boot] [PATCH 1/2] [NEXT] arm: change relocation flag from -fPIC	to -fPIE
[U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with	-msingle-pic-base

[hs at pollux u-boot]$ ./MAKEALL tx25
Configuring for tx25 board...
   text    data     bss     dec     hex filename
 146172    9172   36980  192324   2ef44 ./u-boot

So, this saves for this board 0xdec bytes!

-----------------------------------------------------------------------

here now the fix for the tx25 board:

diff --git a/arch/arm/cpu/arm926ejs/start.S b/arch/arm/cpu/arm926ejs/start.S
index 739fa06..0f0a503 100644
--- a/arch/arm/cpu/arm926ejs/start.S
+++ b/arch/arm/cpu/arm926ejs/start.S
@@ -277,6 +277,18 @@ fixloop:
 #endif
 #endif	/* #ifndef CONFIG_SKIP_RELOCATE_UBOOT */

+	/*
+	 * Set pic base register to the current GOT position. Since we are
+	 * now running from RAM, we need to offset it from its link-time to
+	 *  its run-time position.
+	 */
+	ldr	r9, relocate_got_base_r
+	sub	r9, pc, r9
+	ldr	r10, _got_base
+relocate_got_base_r:
+	add	r10, r9, r10
+	mov	r9, r10
+
 clear_bss:
 #ifndef CONFIG_PRELOADER
 	ldr	r0, _bss_start
@@ -298,18 +310,6 @@ clbss_l:str	r2, [r0]		/* clear loop...		    */
 	bl red_LED_on
 #endif

-	/*
-	 * Set pic base register to the current GOT position. Since we are
-	 * now running from RAM, we need to offset it from its link-time to
-	 *  its run-time position.
-	 */
-	ldr	r9, relocate_got_base_r
-	sub	r9, pc, r9
-	ldr	r10, _got_base
-relocate_got_base_r:
-	add	r10, r9, r10
-	mov	r9, r10
-
 /*
  * We are done. Do not return, instead branch to second part of board
  * initialization, now running from RAM.
@@ -331,14 +331,13 @@ _nand_boot: .word nand_boot
 	mov	pc, lr

 _board_init_r: .word board_init_r
+#endif

 _got_base:
 	.word __got_base
 _relocate_got_base_r:
 	.word relocate_got_base_r

-#endif
-
 #else /* #if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) */
 /*
  * the actual reset code
diff --git a/board/karo/tx25/config.mk b/board/karo/tx25/config.mk
index 51ca1ab..1a32c87 100644
--- a/board/karo/tx25/config.mk
+++ b/board/karo/tx25/config.mk
@@ -1,5 +1,5 @@
 ifdef CONFIG_NAND_SPL
 TEXT_BASE = 0x810c0000
 else
-TEXT_BASE = 0x81fc0000
+TEXT_BASE = 0x81fc1000
 endif
diff --git a/include/configs/tx25.h b/include/configs/tx25.h
index 7faa453..dfe8eab 100644
--- a/include/configs/tx25.h
+++ b/include/configs/tx25.h
@@ -41,7 +41,7 @@
 #define CONFIG_SYS_NAND_U_BOOT_OFFS	0x800
 #define CONFIG_SYS_NAND_U_BOOT_SIZE	0x30000

-#define CONFIG_SYS_NAND_U_BOOT_DST      (0x81fc0000)
+#define CONFIG_SYS_NAND_U_BOOT_DST      (0x81fc1000)
 #define CONFIG_SYS_NAND_U_BOOT_START    CONFIG_SYS_NAND_U_BOOT_DST

 #define CONFIG_SYS_NAND_PAGE_SIZE	2048
diff --git a/nand_spl/board/karo/tx25/u-boot.lds b/nand_spl/board/karo/tx25/u-boot.lds
index c572557..b60c0df 100644
--- a/nand_spl/board/karo/tx25/u-boot.lds
+++ b/nand_spl/board/karo/tx25/u-boot.lds
@@ -55,6 +55,7 @@ SECTIONS

 	__got_start = .;
 	. = ALIGN(4);
+	__got_base = .;
 	.got : { *(.got) }

 	__got_end = .;

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

  parent reply	other threads:[~2010-09-23  7:12 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-22 13:57 [U-Boot] [PATCH 1/2] [NEXT] arm: change relocation flag from -fPIC to -fPIE Albert Aribaud
2010-09-22 13:57 ` [U-Boot] [PATCH 2/2] [NEXT] arm926ejs: reduce code size with -msingle-pic-base Albert Aribaud
2010-09-22 18:05   ` Ben Gardiner
2010-09-22 19:07     ` Albert ARIBAUD
2010-09-22 20:51       ` Ben Gardiner
2010-09-22 21:36         ` Albert ARIBAUD
2010-09-22 22:07           ` Albert ARIBAUD
2010-09-23 14:44           ` Ben Gardiner
2010-09-23 15:13             ` Albert ARIBAUD
2010-09-23 15:35               ` Ben Gardiner
2010-09-23 16:53             ` Ben Gardiner
2010-09-23 16:37       ` Ben Gardiner
2010-09-23 17:04         ` Albert ARIBAUD
2010-09-23 21:13           ` Ben Gardiner
2010-09-23 21:30             ` Albert ARIBAUD
2010-09-24 13:38               ` Ben Gardiner
2010-09-24 16:08                 ` Albert ARIBAUD
2010-09-22 20:30     ` Wolfgang Denk
2010-09-22 20:55       ` Ben Gardiner
2010-09-22 21:11         ` Wolfgang Denk
2010-09-22 21:33           ` Ben Gardiner
2010-09-23  7:12   ` Heiko Schocher [this message]
2010-09-23  8:05     ` Albert ARIBAUD
2010-09-23 10:08       ` Heiko Schocher
2010-09-23 12:45         ` Albert ARIBAUD
2010-09-24  5:11           ` Heiko Schocher
2010-09-24  5:47             ` Albert ARIBAUD
2010-09-24 16:45               ` Rogan Dawes
2010-09-24 16:58                 ` Rogan Dawes
2010-09-24 17:13                   ` Albert ARIBAUD
2010-09-22 18:05 ` [U-Boot] [PATCH 1/2] [NEXT] arm: change relocation flag from -fPIC to -fPIE Ben Gardiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C9AFDCA.9090903@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox