On Wed, Jul 20, 2011 at 4:53 PM, Mike Stump <mikest...@comcast.net> wrote: > On Jul 20, 2011, at 1:25 PM, Ian Lance Taylor wrote: >> Interesting. I don't know why this doesn't happen on GNU/Linux. > > It doesn't happen as the symbols in question are local on linux. collect2 > runs nm on public symbols looking for symbols of a particular form, it then > builds two lists, one for constructors of global objects (simplistic view) > and one for destructors. a.out systems liked doing this sort of things as > well. On more modern OSes, the constructors and destructors hook into crt > code that can run per translation unit initializations, for example on elf, > one might use .init to achieve this. When one uses one of these more > advanced features to hook into the OS, then the symbols no longer need to be > public and the port is changed to make them non-public.
This is not the global constructor/destructor issue with names generated by collect2. But ELF or SVR4 is able to provide a unique name without resorting to random numbers. - David