This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld --gc-sections on PE COFF


"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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]