ld --gc-sections for libraries, gcc generating movsl

Etienne Lorrain etienne@masroudeau.com
Tue Jan 9 01:54:00 GMT 2001


On Mon, 8 Jan 2001, Geoff Keating wrote:

> > Date: Mon, 8 Jan 2001 01:09:33 -0800 (PST)
> > From: Etienne Lorrain <etienne@masroudeau.com>
>
> >  The question is why only some unused functions are removed using
> >  "gcc -ffunction-sections" and "ld --gc-sections". It seems that
> >  all function not called and not removed are in the two libraries
> >  (ext2fs and zlib) I am using.
> >  To show the problem, you need to build the complete Gujin with or
> >  without the Makefile variable "GC_SECTION".
>
> Did you build ext2fs and zlib with -ffunction-sections?

  Yes, I rebuild libraries and the linker file depending on GC_SECTION,
 so I have my linker file "boot.lnk" (produced using CPP on "boot.ld")
 including segments ".text.*":

        .extra 0 : AT(SIZEOF(.text) + SIZEOF(.text_extra)) {
                _sextra = . ;
                *(.extra)
                __sizeof_gujin_code_in_extra = . - _sextra ;


                _sextrae2fs = . ;
                libext2fs.a(.text .text.* )
                __sizeof_e2fs_code_in_extra = . - _sextrae2fs ;

                _sextrazlib = . ;
                libz.a(.text .text.* )
                __sizeof_zlib_code_in_extra = . - _sextrazlib ;


                . = ALIGN (4) ;
                } > ram = 0



  A short extract of the boot.map file (start of section "extra"):

 libext2fs.a(.text)
 libext2fs.a(.text.*)
 .text.ext2fs_new_inode   <<<<<----- segment name
                0x00004960      0x154 libext2fs.a(alloc.o)
                0x00004960                ext2fs_new_inode
 .text.ext2fs_new_block
                0x00004ab4       0xd2 libext2fs.a(alloc.o)
                0x00004ab4                ext2fs_new_block

  Note that I am _not_ sure that is a library problem, once
 I tried to include manually each .o file of each library, and
 it did not solve the problem as far as I remember.
  What I am sure of, is that those functions are not referenced,
 ld --trace-symbol SYMBOL do not display anything.

  I am ready to test anything you can think of,
  Thanks,
  Etienne.



More information about the Binutils mailing list