arc: Eliminate unused code and data with GCC's garbage collector
authorAlexey Brodkin <abrodkin@synopsys.com>
Wed, 24 Jan 2018 21:25:12 +0000 (00:25 +0300)
committerAlexey Brodkin <abrodkin@synopsys.com>
Wed, 21 Mar 2018 13:21:34 +0000 (16:21 +0300)
Finally GCC's garbage collector works on ARC so let's use it.
That's what I may see for HSDK:

Before:
   text    data     bss     dec     hex filename
 290153   10068  222616  522837   7fa55 u-boot

After:
   text    data     bss     dec     hex filename
 261999    9460  222360  493819   788fb u-boot

Overall ~5% of memory footprint saved.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
arch/arc/config.mk

index 3ed0c282bae0b42689d5baf9c1ae9c26981f0681..d040454d1aa96fb229efab339757b7b266b6a544 100644 (file)
@@ -51,9 +51,10 @@ PLATFORM_CPPFLAGS += -mcpu=archs
 endif
 
 PLATFORM_CPPFLAGS += -ffixed-r25 -D__ARC__ -gdwarf-2 -mno-sdata
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 
 # Needed for relocation
-LDFLAGS_FINAL += -pie
+LDFLAGS_FINAL += -pie --gc-sections
 
 # Load address for standalone apps
 CONFIG_STANDALONE_LOAD_ADDR ?= 0x82000000