ordering of constructors

Neal Becker ndbecker2@verizon.net
Sat Apr 10 21:49:00 GMT 2004


Thanks for all the interesting responses to my question.  Am I correct to
summarize that there is currently no simple way to guarantee ordering of
global constructors?  (A couple of methods were suggested, but if I
understand correctly, none are guaranteed to work?)

If this is true, I'd like to consider a couple of solutions.  I'm thinking
of 3 approaches.

1) Doesn't ld have all the info needed to correctly order constructors
already?

2) A seperate tool can read depenencies and use tsort or similar to produce
an ordering, then annotate the source with __attribute__((init_priority)). 
Or perhaps __attribute__((init_priority)) can be written to a separate
file?  (That would be easier).  In this scenario, the dependencies have to
be specified manually by the user.

3) ld modified to read dependencies and then proceed similar to 2).




More information about the Gcc mailing list