class Parent {
public:
virtual void Foo() {}
virtual void FooNotOverridden() {}
};
class Derived : public Parent {
public:
void Foo() override {}
};
int main() {
Parent p1, p2;
Derived d1, d2;
}
(gdb) x/300xb 0x400b30
0x400b30
is the first address of d's vtable.
0x400b30 <_ZTV7Derived>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x400b38 <_ZTV7Derived+8>: 0x80 0x0b 0x40 0x00 0x00 0x00 0x00 0x00
0x400b40 <_ZTV7Derived+16>: 0x60 0x0a 0x40 0x00 0x00 0x00 0x00 0x00
0x400b48 <_ZTV7Derived+24>: 0x70 0x0a 0x40 0x00 0x00 0x00 0x00 0x00
0x400b50 <_ZTS7Derived>: 0x37 0x44 0x65 0x72 0x69 0x76 0x65 0x64
0x400b58 <_ZTS7Derived+8>: 0x00 0x36 0x50 0x61 0x72 0x65 0x6e 0x74
0x400b60 <_ZTS6Parent+7>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x400b68 <_ZTI6Parent>: 0x70 0x20 0x60 0x00 0x00 0x00 0x00 0x00
What does _ZTV, _ZTS, _ZTI mean in <_ZTV7Derived>
, <_ZTS7Derived>
, <_ZTI6Parent>
?
It is the way the C++ symbol names are mangled by your development platform. You can use the c++filt
command line tool from GNU Binutils to find out:
$ c++filt _ZTV7Derived
vtable for Derived
$ c++filt _ZTS7Derived
typeinfo name for Derived
$ c++filt _ZTI6Parent
typeinfo for Parent
More specifically, it is the mangling defined by the Itanium or IA-64 C++ ABI which is also used on x86_64 (because the System V Application Binary Interface - AMD64 Architecture Processor Supplement says so in section 9.1 titled "C++"). See section on "Virtual Tables and RTTI" in the Itanium C++ ABI for the exact mangling details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With