Dual Definition of Constructor Symbols in C Libraries
In C , constructor definitions appear twice in libraries when examined with nm. This is due to the Itanium C ABI, which requires multiple constructor entries for polymorphism support.
The mangled names for the constructors indicate their purpose:
Even though a class may not have virtual base classes, GCC emits both constructors as a result of the ABI's support for polymorphism. This behavior is considered a known issue in GCC, where the compiler could potentially optimize this behavior away when polymorphism is not involved.
The different types of constructors have the following meanings:
While this dual emission of constructor symbols does not typically cause problems, it can lead to confusion when examining library symbols with tools like nm.
The above is the detailed content of Why Are There Two Constructor Symbols in C Libraries?. For more information, please follow other related articles on the PHP Chinese website!