GNU constructor priority implementation

Jason Merrill jason at cygnus.com
Thu Jul 15 10:06:59 UTC 1999


g++ uses an attribute to assign a numeric priority to the initialization of
a particular object; something like

A a (42) __attribute__ ((init_priority (420)));

The normal g++ handling of static constructors is to generate a function
for the translation unit which runs all of the constructors in order.  In
the presence of priorities, there is a function for each priority.
The non-prioritized function goes into .ctors, and the prioritized
functions go into .ctors.%.5u.  The .ctors* sections are sorted by the
linker into a single .ctors section for the executable.

Jason




More information about the cxx-abi-dev mailing list