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: repost: why doesn't i686-pc-mingw32-ld offer gc-sections?


Adam Megacz <adam@megacz.com> writes:

> Hey, does anybody have any idea about this? Short form of the question
> is: if BFD abstracts the internal structure of binary files, why will
> gc-sections work on ELF but not on PE (win32)? How much effort would
> be required to make it work (if it's only a few days, I might be able
> to do it).

It's not really true that BFD abstracts the internal structure of
binary files.  It was once true, but the resulting linker was too slow
and too memory intensive.  So we rewrote the linker portion to be
object file format specific.  The gc-section work was only done in the
ELF version of the linker.  You can see the code in elflink.h.  I
don't know how much work it would be to copy over to the COFF linker
used for PE.

> > One other idea -- I noticed this in objcopy's man page:
> > 
> >   objcopy uses the GNU BFD Library to read and write the object files.
> >   It can write the destination object file in a format different from
> >   that of the source object file.... Note that objcopy should be able
> >   to copy a fully linked file between any two formats.
> > 
> > This sounds pretty amazing -- does it mean that I could generate ELF
> > .o's, link them into an ELF executable (performing section-gc along
> > the way), and then use objcopy to turn that into a PE executable?
> > Somehow that sounds like it should be impossible...

No, it's possible.  But it probably doesn't work for dynamically
linked executables, so it probably won't help you for Windows.  Plus
you'd have to have ELF versions of any libraries you use.

Ian


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