ld --gc-sections on PE COFF

Ian Lance Taylor ian@wasabisystems.com
Mon Aug 9 20:14:00 GMT 2004


"Aaron W. LaFramboise" <aaron98wiridge9@aaronwl.com> writes:

> What would it take to get --gc-sections working on COFF, in particular,
> on PE?  I understand it presently only works on some ELF targets.

Define coff_bfd_gc_sections() in coffcode.h to do something along the
lines of bfd_elf_gc_sections() in elflink.c.

When doing this, skip the vtable stuff--my impression is that that is
no longer supported by the compiler.  Basically, walk the relocations
and mark the sections holding symbols to which they refer.  You will
need CPU specific code to handle specific relocation types.  Then
sweep through the files, as in elf_gc_sweep(), and discard the
unmarked sections.  You can probably lift much of the code directly
from the ELF implementation.  The COFF case should be simpler, since
you don't have to worry about the dynamic linking information.  There
are doubtless numerous irritating dependencies which will have to be
addressed along the way.

Ian



More information about the Binutils mailing list