Skip to contentSkip to conversation

U-Boot-V2: ARM: enable function cleanup by gcc

PATCH New Menon 2 participants 2 messages May 12, 2008

Subsystems (2)
lore
Share & tools
lore

Menon

#0 lore raw

PATCH 2/2 U-Boot-V2: ARM: enable function cleanup by gcc

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).

arch/arm/Makefile +4 -0
Index: u-boot-v2.git/arch/arm/Makefile
===================================================================
@@ -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
include/asm-generic/u-boot.lds.h +10 -10
Index: u-boot-v2.git/include/asm-generic/u-boot.lds.h
===================================================================
@@ -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))
Applied
#1 lore raw

PATCH 2/2 U-Boot-V2: ARM: enable function cleanup by gcc

Quoted 5 lines · Nishanth

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).

applied, thanks

Sascha

Signature · 4 lines
Pengutronix e.K. - Linux Solutions for Science and Industry
-----------------------------------------------------------
Kontakt-Informationen finden Sie im Header dieser Mail oder
auf der Webseite -> http://www.pengutronix.de/impressum/ <-