[U-Boot-Users] [Patch 2/2] U-Boot-V2: ARM: enable function cleanup by gcc

Menon, Nishanth x0nishan at ti.com
Mon May 12 14:23:48 CEST 2008


Does the following:
* Add cleanup flags which will allow gcc to delete function sections which are unused.
* mark the initcall sections and uboot cmds, symbols as being retained (else gcc will kill those too).

Signed-off-by: Nishanth Menon <x0nishan at ti.com>

Index: u-boot-v2.git/arch/arm/Makefile
===================================================================
--- u-boot-v2.git.orig/arch/arm/Makefile	2008-05-12 07:21:57.000000000 -0500
+++ u-boot-v2.git/arch/arm/Makefile	2008-05-12 07:22:19.000000000 -0500
@@ -23,6 +23,10 @@
 CFLAGS += -msoft-float -Os
 AFLAGS += -msoft-float -Os
 
+# Add cleanup flags
+CPPFLAGS += -fdata-sections -ffunction-sections
+LDFLAGS_uboot += -static --gc-sections
+
 ifeq ($(incdir-y),)
 incdir-y := $(machine-y)
 endif
Index: u-boot-v2.git/include/asm-generic/u-boot.lds.h
===================================================================
--- u-boot-v2.git.orig/include/asm-generic/u-boot.lds.h	2008-05-12 07:21:41.000000000 -0500
+++ u-boot-v2.git/include/asm-generic/u-boot.lds.h	2008-05-12 07:22:02.000000000 -0500
@@ -1,14 +1,14 @@
 
 #define INITCALLS			\
-  	*(.initcall.0)			\
-  	*(.initcall.1)			\
-  	*(.initcall.2)			\
-  	*(.initcall.3)			\
-  	*(.initcall.4)			\
-  	*(.initcall.5)			\
-  	*(.initcall.6)			\
-  	*(.initcall.7)
+  	KEEP(*(.initcall.0))			\
+  	KEEP(*(.initcall.1))			\
+  	KEEP(*(.initcall.2))			\
+  	KEEP(*(.initcall.3))			\
+  	KEEP(*(.initcall.4))			\
+  	KEEP(*(.initcall.5))			\
+  	KEEP(*(.initcall.6))			\
+  	KEEP(*(.initcall.7))
 
-#define U_BOOT_CMDS	*(SORT_BY_NAME(.u_boot_cmd*))
+#define U_BOOT_CMDS	KEEP(*(SORT_BY_NAME(.u_boot_cmd*)))
 
-#define U_BOOT_SYMS	*(__usymtab)
+#define U_BOOT_SYMS	KEEP(*(__usymtab))




More information about the U-Boot mailing list