Skip to contentSkip to conversation

Strip dead code on omap3 devices

PATCH New Charles Manning 1 participant 2 messages Apr 20, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Strip dead code on omap3 devices

Garbage collect code that isn't used.

Saves a good few kbytes.

---
 Makefile                      |    2 +-
 arch/arm/config.mk            |    6 ++++++
 arch/arm/cpu/armv7/u-boot.lds |    6 +++---
 3 files changed, 10 insertions(+), 4 deletions(-)
Makefile +1 -1
index 713dba1..1ba3e3a 100644
@@ -368,7 +368,7 @@ $(obj)u-boot.dis:	$(obj)u-boot
 GEN_UBOOT = \
 		UNDEF_SYM=`$(OBJDUMP) -x $(LIBBOARD) $(LIBS) | \
 		sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
-		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM $(__OBJS) \
+		cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGSFINAL) $(LDFLAGS_$(@F)) 

$$UNDEF_SYM $(__OBJS) \
--start-group $(__LIBS) --end-group $(PLATFORM_LIBS) \
-Map u-boot.map -o u-boot
$(obj)u-boot: depend \

arch/arm/config.mk +6 -0
index fcc26a2..02cc9b2 100644
@@ -67,3 +67,9 @@ LDSCRIPT := $(SRCTREE)/$(CPUDIR)/u-boot.lds
 ifndef CONFIG_NAND_SPL
 LDFLAGS_u-boot += -pie
 endif
+
+# Dead code stripping
+CFLAGS += -ffunction-sections
+CFLAGS += -fdata-sections
+LDFLAGS += --cref
+LDFLAGSFINAL += --cref --gc-sections
arch/arm/cpu/armv7/u-boot.lds +3 -3
index dbae54d..f1267b5 100644
@@ -34,8 +34,8 @@ SECTIONS
 	. = ALIGN(4);
 	.text	:
 	{
-		arch/arm/cpu/armv7/start.o	(.text)
-		*(.text)
+		KEEP(arch/arm/cpu/armv7/start.o	(.text*))
+		*(.text*)
 	}
 
 	. = ALIGN(4);
@@ -70,7 +70,7 @@ SECTIONS
 
 	.bss __rel_dyn_start (OVERLAY) : {
 		__bss_start = .;
-		*(.bss)
+		*(.bss*)
 		 . = ALIGN(4);
 		__bss_end__ = .;
 	}
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 Strip dead code on omap3 devices

Quoted 3 lines · On Wednesday 20 April 2011 15:51:56 Charles Manning wrote:

Garbage collect code that isn't used.

Saves a good few kbytes.

Sorry folks. THis patch is broken.

I'll submit another.

Charles