This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: simulating section-gc with ar-archives?
- From: Ian Lance Taylor <ian at airs dot com>
- To: Adam Megacz <adam at megacz dot com>
- Cc: binutils at sources dot redhat dot com
- Date: 16 Jan 2002 21:45:54 -0800
- Subject: Re: simulating section-gc with ar-archives?
- References: <86advexfv7.fsf@megacz.com>
Adam Megacz <adam@megacz.com> writes:
> If I understand correctly, ld will ignore any unreferenced .o's in an
> ar-archive when linking. So if foo.a contains bar.o and baz.o, and
> baz.o is never referenced, baz.o will not be included in the final
> executable.
Correct.
> Does this mean that you could simulate section-gc by breaking all your
> .o's up so that each file contained exactly one section, wrapping it
> all up in a .a, and linking that?
Yes, if you can break up the .o files, then this will accomplish what
you want.
However, breaking up a .o after the fact is not necessarily trivial,
and is in the general case impossible, because there is no way to
correctly handle references to file static variables and functions.
Ian