]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
85xx: Use gc-sections to reduce image size
authorPeter Tyser <ptyser@xes-inc.com>
Wed, 29 Sep 2010 19:05:56 +0000 (14:05 -0500)
committerKumar Gala <galak@kernel.crashing.org>
Wed, 20 Oct 2010 07:38:41 +0000 (02:38 -0500)
On an XPedite5370 over 11KBytes were saved:
  Before:
       text    data     bss     dec     hex filename
   332456   33364   33476  399296   617c0 ./u-boot

  After:
      text    data     bss     dec     hex filename
   321075   33836   33476  388387   5ed23 ./u-boot

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/cpu/mpc85xx/config.mk
arch/powerpc/cpu/mpc85xx/u-boot.lds

index f07d9209a7be46879f1620c432bb316595ef7e36..ce4376b1004049d7850a10e0994f9215546f23a5 100644 (file)
@@ -25,6 +25,10 @@ PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -Wa,-me500 -msoft-float -mno-string
 
+# Enable gc-sections to enable generation of smaller images.
+PLATFORM_LDFLAGS += --gc-sections
+PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
+
 # -mspe=yes is needed to have -mno-spe accepted by a buggy GCC;
 # see "[PATCH,rs6000] make -mno-spe work as expected" on
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
index c88b1f35b9e41fdac88090c7c44f69057b9dcca6..85042c5254b3fca805ba199f55ae9d5bfee4b7c5 100644 (file)
@@ -25,8 +25,7 @@
 #endif
 
 OUTPUT_ARCH(powerpc)
-/* Do we need any of these for elf?
-   __DYNAMIC = 0;    */
+
 PHDRS
 {
   text PT_LOAD;
@@ -38,42 +37,16 @@ SECTIONS
   /* Read-only sections, merged into text segment: */
   . = + SIZEOF_HEADERS;
   .interp : { *(.interp) }
-  .hash          : { *(.hash)          }
-  .dynsym        : { *(.dynsym)                }
-  .dynstr        : { *(.dynstr)                }
-  .rel.text      : { *(.rel.text)              }
-  .rela.text     : { *(.rela.text)     }
-  .rel.data      : { *(.rel.data)              }
-  .rela.data     : { *(.rela.data)     }
-  .rel.rodata    : { *(.rel.rodata)    }
-  .rela.rodata   : { *(.rela.rodata)   }
-  .rel.got       : { *(.rel.got)               }
-  .rela.got      : { *(.rela.got)              }
-  .rel.ctors     : { *(.rel.ctors)     }
-  .rela.ctors    : { *(.rela.ctors)    }
-  .rel.dtors     : { *(.rel.dtors)     }
-  .rela.dtors    : { *(.rela.dtors)    }
-  .rel.bss       : { *(.rel.bss)               }
-  .rela.bss      : { *(.rela.bss)              }
-  .rel.plt       : { *(.rel.plt)               }
-  .rela.plt      : { *(.rela.plt)              }
-  .init          : { *(.init)  }
-  .plt : { *(.plt) }
   .text      :
   {
-    *(.text)
-    *(.got1)
+    *(.text*)
    } :text
     _etext = .;
     PROVIDE (etext = .);
     .rodata    :
    {
-    *(.eh_frame)
     *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
   } :text
-  .fini      : { *(.fini)    } =0
-  .ctors     : { *(.ctors)   }
-  .dtors     : { *(.dtors)   }
 
   /* Read-write section, merged into data segment: */
   . = (. + 0x00FF) & 0xFFFFFF00;
@@ -81,23 +54,19 @@ SECTIONS
   PROVIDE (erotext = .);
   .reloc   :
   {
-    *(.got)
+    KEEP(*(.got))
     _GOT2_TABLE_ = .;
-    *(.got2)
+    KEEP(*(.got2))
     _FIXUP_TABLE_ = .;
-    *(.fixup)
+    KEEP(*(.fixup))
   }
   __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >> 2;
   __fixup_entries = (. - _FIXUP_TABLE_) >> 2;
 
   .data    :
   {
-    *(.data)
-    *(.data1)
-    *(.sdata)
-    *(.sdata2)
-    *(.dynamic)
-    CONSTRUCTORS
+    *(.data*)
+    *(.sdata*)
   }
   _edata  =  .;
   PROVIDE (edata = .);
@@ -126,7 +95,7 @@ SECTIONS
 
   .resetvec RESET_VECTOR_ADDRESS :
   {
-    *(.resetvec)
+    KEEP(*(.resetvec))
   } :text = 0xffff
 
   . = RESET_VECTOR_ADDRESS + 0x4;
@@ -145,9 +114,8 @@ SECTIONS
   __bss_start = .;
   .bss (NOLOAD)       :
   {
-   *(.sbss) *(.scommon)
-   *(.dynbss)
-   *(.bss)
+   *(.sbss*)
+   *(.bss*)
    *(COMMON)
   } :bss