Linux Standard Base C++ Specification 4.1 | ||
---|---|---|
<<< Previous | Next >>> |
Support for the C++ language shall be as specified in Itanium™ C++ ABI.
Note: This document, although containing a few architecture specific matters, is written as a generic specification, to be usable by C++ implementations on a variety of architectures.
An object file generated by the compilation process for a C++ program shall contain several closely related internal objects, or Class Components, to represent each C++ Class. Such objects are not a visible part of the source code. Table 6-1 describes these Class Components at a high level.
Table 6-1. Class Components
Object | Contains |
---|---|
Class Data | All non-static Class members |
Virtual Table | Information needed to dispatch virtual functions, access virtual base class subobjects and to access the RTTI information |
RTTI | Run-Time Type Information used by the typeid and dynamic_cast operators, and exception handlers |
Typeinfo Name | String representation of Class name |
Construction Virtual Table | Information needed during construction and destruction of Classes with non-trivial inheritance relationships. |
VTT | A table of virtual table pointers which holds the addresses of construction and non-construction virtual tables. |
Virtual tables are specified in Section 2.5.3 of Itanium™ C++ ABI.
Of the various categories of virtual table described in that specification, Category 1 (Leaf) is further described in Figure 6-1 and Category 2 (Non-virtual bases only) is further described in Figure 6-2. LSB conforming systems shall support these categories.
struct { ptrdiff_t baseobject; const char *typeinfo; fptr virtfuncs[0]; }; |
Figure 6-1. Category 1 Virtual Table
struct { unsigned long vcalloffset; ptrdiff_t baseobject; const char *typeinfo; fptr virtfuncs[0]; }; |
Figure 6-2. Category 2 Virtual Table
This specification describes requirements for virtual tables of C++ classes using tables of the following form:
Table 6-2. Primary vtable for K (example)
Base Offset | 0 |
Virtual Base Offset | 0 |
RTTI | typeinfo for K |
vfunc[0]: | K::~K() |
vfunc[1]: | K::~K() |
vfunc[2]: | K::m1(int*) |
vfunc[3]: | X::m2() |
vfunc[4]: | __cxa_pure_virtual() |
vfunc[5]: | NULL or X::m4(int) |
Each row starting from 'vfunc[i]:' refers to a vtable entry 'vfunc[i]' of a class K, which is an entry for a virtual function A::m, where A is a base class of the class K as described in the Itanium™ C++ ABI. This specification requires implementations to interpret the vtable entry information in the following way:
A conforming implementation shall contain a vtable of the class K in the specified shared library;
The corresponding entry of this vtable 'vfunc[i]' shall be an entry for the virtual function A::m;
If the second column of the row contains __cxa_pure_virtual() the corresponding vtable entry of a LSB-conforming implementation shall contain __cxa_pure_virtual() or 'Y::m', where Y is the class K, the class A or a base class of the class K derived from the class A. [1]
If the second column of the row contains 'X::m' the corresponding vtable entry of a LSB-conforming implementation shall contain 'Y::m', where Y is the class K, the class X or a base class of the class K derived from the class X.
If the second column of the row contains 'NULL or X::m' the corresponding vtable entry of a LSB-conforming implementation shall contain NULL or 'Y::m', where Y is the class K, the class X or a base class of the class K derived from the class X. [2]
An application may use any non-pure virtual function
specified in this specification, and can expect the
specified behavior irrespective of which particular
method implements this functionality.
An application may not use inline virtual functions at the
binary level since its vtable entry may be NULL
.
Each type used in a C++ program has a data structure associated with it that provide information about the type which is used at runtime. This Run Time Type Information (RTTI) is defined in section 2.9.5 in Itanium™ C++ ABI. Additional details about the layout of this data is provided here.
struct { void *basevtable; char *name; void *basetypeinfo[0]; }; |
Figure 6-4. Run-Time Type Information For Classes with no base class
struct { void *basevtable; char *name; void *basetype; void *basetypeinfo[0]; }; |
Figure 6-5. Run-Time Type Information for Classes with a single base class
struct base_type_info { char *base_type; unsigned long offset_flags; }; struct { void *basevtable; char *name; unsigned int flags; unsigned int base_count; struct base_type_info base_info[0]; }; |
Figure 6-6. Run-Time Type Information for classes with multiple inheritance
[1] | In this case virtual function A::m in class K is considered to be specified as pure virtual by this specification. |
[2] | In this case virtual function A::m in class K is considered to be specified as inline by this specification. |
<<< Previous | Home | Next >>> |
Low Level System Information | Up | Symbol Mapping |