This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: static lib drops objects with side-effects
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: terpstra at bagofholding dot com
- Cc: Richard dot Earnshaw at arm dot com, binutils at sources dot redhat dot com
- Date: Tue, 11 Feb 2003 13:47:22 +0000
- Subject: Re: static lib drops objects with side-effects
- Organization: ARM Ltd.
- Reply-to: Richard dot Earnshaw at arm dot com
terpstra@bagofholding.com said:
> How do you suggest one make the typical Singleton registry design
> pattern work portably? Clearly one can simply stick with shared
> libraries instead, but for systems without, how should it work?
While I'm not familiar with the particular requirements you might have
there are several possibilities:
1) Pre-link all the relevant modules together "ld -R" to produce a single
object file that can then be linked in as normal
2) Pass --whole-archive to the linker before specifying the library that
you want everything from
3) Arrange for the linker to be passed a series of "-u <symbol>" options
for each object you want to force in
4) Create a container object that somehow references all the modules you
want to force in, then ensure that this contains a symbol that is
referenced from elsewhere.
R.