[U-Boot] [PATCH] Strip dead code on omap3 devices
Charles Manning
manningc2 at actrix.gen.nz
Wed Apr 20 05:51:56 CEST 2011
Garbage collect code that isn't used.
Saves a good few kbytes.
Signed-off-by: Charles Manning <cdhmanning at gmail.com>
---
Makefile | 2 +-
arch/arm/config.mk | 6 ++++++
arch/arm/cpu/armv7/u-boot.lds | 6 +++---
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 713dba1..1ba3e3a 100644
--- a/Makefile
+++ b/Makefile
@@ -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 \
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index fcc26a2..02cc9b2 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -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
diff --git a/arch/arm/cpu/armv7/u-boot.lds b/arch/arm/cpu/armv7/u-boot.lds
index dbae54d..f1267b5 100644
--- a/arch/arm/cpu/armv7/u-boot.lds
+++ b/arch/arm/cpu/armv7/u-boot.lds
@@ -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__ = .;
}
--
1.7.1
More information about the U-Boot
mailing list