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: static lib drops objects with side-effects


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.


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