static data member problem

Jason Merrill
Sun Oct 4 01:36:00 GMT 1998

>>>>> Alexandre Oliva <> writes:

 > My idea was more on the line of emulating weak definitions by
 > generating code for them as if they were members of anonymous
 > namespaces.  Then, at link time, collect2 could extract the required
 > pieces of code from the object file, rename the symbols so as to match 
 > their original names, then link everything together.

This is actually what IBM does in xlC, more or less, though they don't
extract any code, they just choose one of the definitions and rename it.
Since their linker does garbage collection, the other definitions are
discarded.  Unfortunately, a.out can't support garbage collection any more
than it can support the current ELF model.

 > I'm not sure it is possible to extract information like that from
 > object files, though.  Another solution would be to write the assembly
 > code (text) of the ``weak'' definitions into the object file, in a way
 > that collect2 could extract it, generate a single assembly file
 > containing all the weak definitions, assemble it and link it together
 > with the other object files.

I suppose it might be possible to stick that stuff into the symbol table
along with the debugging info, but that sounds like a nightmare.

In any case, a.out is becoming less and less relevant.


More information about the Gcc-bugs mailing list