Robert Corbett wrote: > Are there rules for when symbols in archives should be weak symbols? > I checked libc.a in Solaris 8. I could not detect a pattern. While > many symbols in the user namespace are weak, many are not. It appears > that symbols added recently are not weak.
The use of weak symbols has never had any rules (at least not that I can recall), just a lot of cut-and-past from past practice. The original Solaris sources maintained a convention of weak symbol aliases for most library code. ie, #pragma weak foo = _foo This allowed libraries to bind to the "_" variant (if they used suitable synonyms.h definitions) in an attempt to protect themselves from external interposition. It also enabled interposing objects who could define they own non-"_" variant, perform some extensions, and then call through to the original "_" variant. But none of this weak alias practice has been continued in a consistent manner. Plus there are better ways of achieving what this aliasing seemed to provide - libraries can bind to themselves internally much more efficiently with versioning and scoping. Specific interfaces can be bound to directly or through various dlsym() modes. Personally, I think the whole weak alias symbol technique is a mess, and no new code should propagate its use. -- Rod
