gpt4 book ai didi

c++ - ZTV、ZTS、ZTI 在 gdb x/nfu "vtable_address"的结果中意味着什么?

转载 作者:搜寻专家 更新时间:2023-10-31 00:08:20 24 4
gpt4 key购买 nike

1。代码

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;
}

2。 gdb命令

(gdb) x/300xb 0x400b30

0x400b30是d的vtable的首地址。

3。 gdb结果

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

4。问题

_ZTV_ZTS_ZTI<_ZTV7Derived>中是什么意思| , <_ZTS7Derived> , <_ZTI6Parent>

最佳答案

这是您的开发平台破坏 C++ 符号名称的方式。您可以使用 GNU Binutils 中的 c++filt 命令行工具找出:

$ c++filt _ZTV7Derived
vtable for Derived
$ c++filt _ZTS7Derived
typeinfo name for Derived
$ c++filt _ZTI6Parent
typeinfo for Parent

更具体地说,它是由 Itanium 或 IA-64 C++ ABI 定义的 mangling,它也在 x86_64 上使用(因为 System V Application Binary Interface - AMD64 Architecture Processor Supplement 在标题为“C++”的第 9.1 节中如此说明)。参见 section on "Virtual Tables and RTTI"在 Itanium C++ ABI 中获取确切的处理细节。

关于c++ - ZTV、ZTS、ZTI 在 gdb x/nfu "vtable_address"的结果中意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49381011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com