Skip to contentSkip to conversation

MIPS: Introduce --gc-sections for MIPS

PATCH New daniel.schwierzeck at googlemail.com 3 participants 4 messages Apr 15, 2011 – May 9, 2011 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Introduce --gc-sections for MIPS

All architectures but MIPS are using --gc-sections on final linking. This patch introduces that feature for MIPS to reduce the memory and flash footprint.

Cc Shinya Kuribayashi <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Thomas Lange <[email protected]>
Cc Vlad Lungu <[email protected]>

---
Tested with ELDK-4.1 and self-built gcc-4.3.3/binutils-2.19.1 on my boards. I could not test the other boards so I would appreciate it if the maintainers in CC could do a quick test on their boards.

 arch/mips/config.mk           |    2 ++
 board/dbau1x00/u-boot.lds     |   10 +++++-----
 board/gth2/u-boot.lds         |   10 +++++-----
 board/incaip/u-boot.lds       |   10 +++++-----
 board/micronas/vct/u-boot.lds |   10 +++++-----
 board/pb1x00/u-boot.lds       |   10 +++++-----
 board/qemu-mips/u-boot.lds    |   10 +++++-----
 board/tb0229/u-boot.lds       |   10 +++++-----
 examples/standalone/mips.lds  |   10 +++++-----
 9 files changed, 42 insertions(+), 40 deletions(-)
arch/mips/config.mk +2 -0
index 318d34b..6ab8acd 100644
@@ -50,3 +50,5 @@ PLATFORM_CPPFLAGS += -DCONFIG_MIPS -D__MIPS__
 PLATFORM_CPPFLAGS		+= -G 0 -mabicalls -fpic
 PLATFORM_CPPFLAGS		+= -msoft-float
 PLATFORM_LDFLAGS		+= -G 0 -static -n -nostdlib
+PLATFORM_RELFLAGS		+= -ffunction-sections -fdata-sections
+LDFLAGS_FINAL			+= --gc-sections
board/dbau1x00/u-boot.lds +5 -5
index 3c4fbe3..4a59cea 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -52,7 +52,7 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	.u_boot_cmd : {
 	  __u_boot_cmd_start = .;
@@ -64,7 +64,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD)  : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
board/gth2/u-boot.lds +5 -5
index aeb0fcc..9fc417f 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -52,7 +52,7 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	.u_boot_cmd : {
 	  __u_boot_cmd_start = .;
@@ -64,7 +64,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD)  : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
board/incaip/u-boot.lds +5 -5
index 3c4fbe3..4a59cea 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -52,7 +52,7 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	.u_boot_cmd : {
 	  __u_boot_cmd_start = .;
@@ -64,7 +64,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD)  : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
board/micronas/vct/u-boot.lds +5 -5
index b90b186..3a05ef9 100644
@@ -31,14 +31,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -50,7 +50,7 @@ SECTIONS
 	}
 
 	. = ALIGN(4);
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	. = ALIGN(4);
 	.u_boot_cmd : {
@@ -64,8 +64,8 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
+	.sbss (NOLOAD)  : { *(.sbss*) }
 	. = ALIGN(4);
-	.bss (NOLOAD)  : { *(.bss) }
+	.bss (NOLOAD)  : { *(.bss*) }
 	uboot_end = .;
 }
board/pb1x00/u-boot.lds +5 -5
index 358cc54..bd0dee1 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -52,7 +52,7 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	.u_boot_cmd : {
 	  __u_boot_cmd_start = .;
@@ -64,7 +64,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD)  : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
board/qemu-mips/u-boot.lds +5 -5
index bd16786..9460b20 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) +0x7ff0;
@@ -53,7 +53,7 @@ SECTIONS
 	}
 
 	. = ALIGN(4);
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	. = .;
 	.u_boot_cmd : {
@@ -66,7 +66,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss  : { *(.sbss) }
-	.bss  : { *(.bss) . = ALIGN(4); }
+	.sbss  : { *(.sbss*) }
+	.bss  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
board/tb0229/u-boot.lds +5 -5
index 56d7c25..5ea1094 100644
@@ -34,14 +34,14 @@ SECTIONS
 	. = ALIGN(4);
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -52,7 +52,7 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	.u_boot_cmd : {
 	  __u_boot_cmd_start = .;
@@ -64,7 +64,7 @@ SECTIONS
 	num_got_entries = (__got_end - __got_start) >> 2;
 
 	. = ALIGN(4);
-	.sbss (NOLOAD)  : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD)  : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 	uboot_end = .;
 }
examples/standalone/mips.lds +5 -5
index 63a1c92..5f766ed 100644
@@ -30,14 +30,14 @@ SECTIONS
 {
 	.text       :
 	{
-	  *(.text)
+	  *(.text*)
 	}
 
 	. = ALIGN(4);
 	.rodata  : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
 	. = ALIGN(4);
-	.data  : { *(.data) }
+	.data  : { *(.data*) }
 
 	. = .;
 	_gp = ALIGN(16) + 0x7ff0;
@@ -48,12 +48,12 @@ SECTIONS
 	  __got_end = .;
 	}
 
-	.sdata  : { *(.sdata) }
+	.sdata  : { *(.sdata*) }
 
 	. = ALIGN(4);
 	__bss_start = .;
-	.sbss (NOLOAD) : { *(.sbss) }
-	.bss (NOLOAD)  : { *(.bss) . = ALIGN(4); }
+	.sbss (NOLOAD) : { *(.sbss*) }
+	.bss (NOLOAD)  : { *(.bss*) . = ALIGN(4); }
 
 	_end = .;
 }

--
1.7.4.3

#1 lore raw

PATCH 1/1 MIPS: Introduce --gc-sections for MIPS

Quoted 15 lines · daniel.schwierzeck at googlemail.com

All architectures but MIPS are using --gc-sections on final linking. This patch introduces that feature for MIPS to reduce the memory and flash footprint.

Cc Shinya Kuribayashi <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Thomas Lange <[email protected]>
Cc Vlad Lungu <[email protected]>

---
Tested with ELDK-4.1 and self-built gcc-4.3.3/binutils-2.19.1 on my boards. I could not test the other boards so I would appreciate it if the maintainers in CC could do a quick test on their boards.

Quoted 10 lines
 arch/mips/config.mk           |    2 ++
 board/dbau1x00/u-boot.lds     |   10 +++++-----
 board/gth2/u-boot.lds         |   10 +++++-----
 board/incaip/u-boot.lds       |   10 +++++-----
 board/micronas/vct/u-boot.lds |   10 +++++-----
 board/pb1x00/u-boot.lds       |   10 +++++-----
 board/qemu-mips/u-boot.lds    |   10 +++++-----
 board/tb0229/u-boot.lds       |   10 +++++-----
 examples/standalone/mips.lds  |   10 +++++-----
 9 files changed, 42 insertions(+), 40 deletions(-)

Basically, changes made look good. I'm going to apply after a couple of weeks (or a month) of interval, even without reports from the maintainers. As the patch has been proposed in the last minutes during the merge window, we'll make it in the v2011.06 release, thanks.

#2 lore raw

PATCH 1/1 MIPS: Introduce --gc-sections for MIPS

I just tried it for our Octeon boards and saw a noticeable reduction in size. Our bootloader shrank from 1107840 to 941600 bytes. Size isn't too big of an issue for us, though it's nice to see it shrink to under 1MB again.

-Aaron

Quoted 32 lines · Shinya Kuribayashi
Quoted 15 lines · daniel.schwierzeck at googlemail.com

All architectures but MIPS are using --gc-sections on final linking. This patch introduces that feature for MIPS to reduce the memory and flash footprint.

Cc Shinya Kuribayashi <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Thomas Lange <[email protected]>
Cc Vlad Lungu <[email protected]>

---
Tested with ELDK-4.1 and self-built gcc-4.3.3/binutils-2.19.1 on my boards. I could not test the other boards so I would appreciate it if the maintainers in CC could do a quick test on their boards.

Quoted 10 lines
 arch/mips/config.mk           |    2 ++
 board/dbau1x00/u-boot.lds     |   10 +++++-----
 board/gth2/u-boot.lds         |   10 +++++-----
 board/incaip/u-boot.lds       |   10 +++++-----
 board/micronas/vct/u-boot.lds |   10 +++++-----
 board/pb1x00/u-boot.lds       |   10 +++++-----
 board/qemu-mips/u-boot.lds    |   10 +++++-----
 board/tb0229/u-boot.lds       |   10 +++++-----
 examples/standalone/mips.lds  |   10 +++++-----
 9 files changed, 42 insertions(+), 40 deletions(-)

Basically, changes made look good. I'm going to apply after a couple of weeks (or a month) of interval, even without reports from the maintainers. As the patch has been proposed in the last minutes during the merge window, we'll make it in the v2011.06 release, thanks.

#3 lore raw

PATCH 1/1 MIPS: Introduce --gc-sections for MIPS

In reply to daniel.schwierzeck at googlemail.com

Hi Daniel,

Quoted 15 lines · daniel.schwierzeck at googlemail.com

All architectures but MIPS are using --gc-sections on final linking. This patch introduces that feature for MIPS to reduce the memory and flash footprint.

Cc Shinya Kuribayashi <[email protected]>
Cc Wolfgang Denk <[email protected]>
Cc Stefan Roese <[email protected]>
Cc Thomas Lange <[email protected]>
Cc Vlad Lungu <[email protected]>

---
Tested with ELDK-4.1 and self-built gcc-4.3.3/binutils-2.19.1 on my boards. I could not test the other boards so I would appreciate it if the maintainers in CC could do a quick test on their boards.

Quoted 10 lines
 arch/mips/config.mk           |    2 ++
 board/dbau1x00/u-boot.lds     |   10 +++++-----
 board/gth2/u-boot.lds         |   10 +++++-----
 board/incaip/u-boot.lds       |   10 +++++-----
 board/micronas/vct/u-boot.lds |   10 +++++-----
 board/pb1x00/u-boot.lds       |   10 +++++-----
 board/qemu-mips/u-boot.lds    |   10 +++++-----
 board/tb0229/u-boot.lds       |   10 +++++-----
 examples/standalone/mips.lds  |   10 +++++-----
 9 files changed, 42 insertions(+), 40 deletions(-)

Thanks for the work, now pushed to u-boot-mips/master.

By the way, would you do me a favor. In your mail header,

Quoted 1 line

From: daniel.schwierzeck at googlemail.com

Please provide this in the form of, From: Your Name <your@address>

This helps patch maintainer(s) to avoid manually fixing Author: field, which is wrongly set when importing patches from E-mails using git-am. I noticed this when we got patches from you for the first time around this February or March and fixed manually at that time, but forgot to tell about that.