static lib drops objects with side-effects

Richard Earnshaw rearnsha@arm.com
Tue Feb 11 13:48:00 GMT 2003


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.



More information about the Binutils mailing list