This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: ld --gc-sections on PE COFF
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: "Aaron W. LaFramboise" <aaron98wiridge9 at aaronwl dot com>
- Cc: binutils at sources dot redhat dot com
- Date: 09 Aug 2004 16:14:13 -0400
- Subject: Re: ld --gc-sections on PE COFF
- References: <4117D21F.6050307@aaronwl.com>
"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