Home > Backend Development > C++ > body text

Why Does the Itanium C ABI Emit Dual Constructor Symbols?

Barbara Streisand
Release: 2024-11-21 17:26:12
Original
652 people have browsed it

Why Does the Itanium C   ABI Emit Dual Constructor Symbols?

Dual Emission of Constructor Symbols

Explanation: Itanium C ABI

The Itanium C ABI specifies the mangling of function names to include information about their parameters and functionality. Constructor names follow a specific pattern:

_Z     | N      | <class_name>  | <ctor-type>          | E          | <parameters>
prefix | nested | `Thing` | Constructor | end nested | parameters: `int`
Copy after login

The Dual Symbols

The constructor symbols in the library appear twice due to the different types of constructors emitted by GCC:

  • C1: Complete object constructor - Constructs the complete object, including virtual base classes.
  • C2: Base object constructor - Creates the object itself and initializes data members and non-virtual base classes.

Polymorphism and Base Constructors

Even though the class in question has no virtual base classes, GCC still emits both constructors as a byproduct of supporting polymorphism. If polymorphism is not involved, GCC could optimize by emitting only one constructor.

Symbol Name Differences

The two constructors have different names because of the C1 and C2 designators in their mangled names, which indicate the different types of construction they perform.

Conclusion

The dual emission of constructor symbols is a consequence of the Itanium C ABI and support for polymorphism, but it can be optimized away by GCC when polymorphism is not used.

The above is the detailed content of Why Does the Itanium C ABI Emit Dual Constructor Symbols?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template