--gc-sections and C library linkage issues (?)
Geoff Keating
geoffk@cygnus.com
Fri Aug 25 01:05:00 GMT 2000
> Date: Fri, 25 Aug 2000 12:09:29 +1000 (EST)
> From: Alan Modra <alan@linuxcare.com.au>
> --gc-sections discards a section which isn't referenced via any of
> it's symbols. That seems quite a proper implementation. The problem
> really is that glibc doesn't make such a symbol reference. You should be
> able to do this with a reference to the section symbol from any section
> that you know will escape garbage collection.
>
> Hmm, I suppose it would be nice if you could tell the assembler to keep
> a section via a section attribute. If you would like to suggest
> semantics, I'll implement it.
The usual way this is done is with a special reloc, like
BFD_RELOC_PPC_EMB_MRKREF, which doesn't actually relocate anything.
You can attach the reloc to, say, the global data item which is
constructed, so that if the data item is included so will the
constructor be. It would be helpful if the assembler had a way to ask
for such a reloc to be emitted...
If you always wanted a section included, you could just add such a
reloc to the text section, or some section that you knew would be
included in the final link (I think).
--
- Geoffrey Keating <geoffk@cygnus.com>
More information about the Binutils
mailing list