Skip to contentSkip to conversation

nios2: use gc sections to reduce image size

PATCH New Thomas Chou 3 participants 6 messages May 28, 2010 – Jun 16, 2010 NIOS2 architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Configuring for nios2-generic board...
Before,
text data bss dec hex filename
123979 3724 22892 150595 24c43 /tmp/u-boot/u-boot
After,
text data bss dec hex filename
115983 3800 22732 142515 22cb3 /tmp/u-boot/u-boot

---
 arch/nios2/config.mk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/nios2/config.mk +3 -0
index 793cc43..aba96b3 100644
@@ -31,2 +31,5 @@ PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+LDFLAGS += --gc-sections
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
Signature · 1 line
1.7.1.86.g0e460
#1 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

Quoted 21 lines · Thomas Chou

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Configuring for nios2-generic board...
Before,
text data bss dec hex filename
123979 3724 22892 150595 24c43 /tmp/u-boot/u-boot
After,
text data bss dec hex filename
115983 3800 22732 142515 22cb3 /tmp/u-boot/u-boot

---
 arch/nios2/config.mk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/nios2/config.mk +0 -0
index 793cc43..aba96b3 100644

arch/nios2/config.mk PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__ · line 35

Quoted 5 lines
arch/nios2/config.mk +3 -0
@@ -31,2 +31,5 @@ PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+LDFLAGS += --gc-sections
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections

Hi Thomas,

Will that stop it working with the gcc3-based nios2 nommu toolchain? The version of 'ld' in that toolchain doesn't support the --gc-sections option.

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>             )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587              )=-
#2 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

Quoted 9 lines · Ian Abbott
Quoted 2 lines · Thomas Chou

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Hi Thomas,

Will that stop it working with the gcc3-based nios2 nommu toolchain? The version of 'ld' in that toolchain doesn't support the --gc-sections option.

Hi Ian,

I have tested with the gcc3-based nios2 nommu toolchain and gc-sections works.

The error that we met when building busybox might be caused by the elf2flt process. There is no such problem generating elf.

Best regards,
Thomas

#3 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

Quoted 6 lines
Quoted 5 lines · Ian Abbott
Quoted 2 lines · Thomas Chou

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Hi Thomas,

Quoted 7 lines
Quoted 4 lines

Will that stop it working with the gcc3-based nios2 nommu toolchain? The version of 'ld' in that toolchain doesn't support the --gc-sections option.

I have tested with the gcc3-based nios2 nommu toolchain and gc-sections works.

Same here -- no problems.

--Scott

#4 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

In reply to Thomas Chou
Quoted 11 lines · Thomas Chou
Quoted 9 lines · Ian Abbott
Quoted 2 lines · Thomas Chou

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Hi Thomas,

Will that stop it working with the gcc3-based nios2 nommu toolchain? The version of 'ld' in that toolchain doesn't support the --gc-sections option.

Quoted 7 lines

Hi Ian,

I have tested with the gcc3-based nios2 nommu toolchain and gc-sections works.

The error that we met when building busybox might be caused by the elf2flt process. There is no such problem generating elf.

Hi Thomas,

That was probably it then. I *knew* we had some problem building BusyBox with --gc-sections!

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
#5 lore raw

PATCH 1/1 nios2: use gc sections to reduce image size

In reply to Thomas Chou

Applied to: git://git.denx.de/u-boot-nios.git next Thanks,
--Scott

Quoted 26 lines · Thomas Chou

Follow the discussion of Charles Manning and Mike Frysinger. Using gc_sections helps reduce image size.

Configuring for nios2-generic board...
Before,
text data bss dec hex filename
123979 3724 22892 150595 24c43 /tmp/u-boot/u-boot
After,
text data bss dec hex filename
115983 3800 22732 142515 22cb3 /tmp/u-boot/u-boot

---
 arch/nios2/config.mk |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
arch/nios2/config.mk +3 -0
index 793cc43..aba96b3 100644
@@ -31,2 +31,5 @@ PLATFORM_CPPFLAGS += -DCONFIG_NIOS2 -D__NIOS2__
 
 LDSCRIPT ?= $(SRCTREE)/$(CPUDIR)/u-boot.lds
+
+LDFLAGS += --gc-sections
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections