1 |
|
1 | Base::f |
1 |
|
部分汇编代码显示了vtable的布局1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23Base::Base() [base object constructor]:
push rbp
mov rbp, rsp
mov QWORD PTR [rbp-8], rdi
mov edx, OFFSET FLAT:vtable for Base+16 # vptr指向了base::f()
mov rax, QWORD PTR [rbp-8]
mov QWORD PTR [rax], rdx
nop
pop rbp
ret
vtable for Base:
.quad 0
.quad typeinfo for Base
.quad Base::f()
.quad Base::g()
.quad Base::h()
typeinfo for Base:
.quad vtable for __cxxabiv1::__class_type_info+16
.quad typeinfo name for Base
typeinfo name for Base:
.string "4Base" # 4代表类型名字的长度
...