c++ - What are those two long in vtable assembly code emitted by GCC? -
this question has answer here:
i checked assembly code generated gcc following c++ code snippet.
class interface { public: virtual int f() = 0; virtual int g() = 0; }; class concrete : public interface { public: virtual int f(); virtual int g(); };
seams there 2 long in each vtable, , assembly code seams doesn't use it, purpose of 2 viable?
.globl __ztv8concrete .const_data .align 3 __ztv8concrete: .long 0 <<<< thos 2 long doesn"t used. .long 0 .long __zn8concrete1gev .long __zn8concrete1fev .globl __ztv9interface .weak_definition __ztv9interface .section __data,__const_coal,coalesced .align 3 __ztv9interface: .long 0 <<<< thos 2 long doesn"t used also. .long 0 .long ___cxa_pure_virtual .long ___cxa_pure_virtual .section __text,__textcoal_nt,coalesced,pure_instructions .weak_definition ___x86.get_pc_thunk.cx .private_extern ___x86.get_pc_thunk.
the constructor:
__zn8concretec1ev: lfb8: pushl %ebp lcfi9: movl %esp, %ebp lcfi10: pushl %ebx subl $20, %esp lcfi11: call ___x86.get_pc_thunk.bx l2$pb: movl 8(%ebp), %eax movl %eax, (%esp) call __zn9interfacec2ev movl 8(%ebp), %edx 2> leal __ztv8concrete-l2$pb(%ebx), %eax leal 8(%eax), %eax <<<< skip 2 two long vtable movl %eax, (%edx) addl $20, %esp popl %ebx
one of 2 "spaces" should rtti (the second one), other multiple inheritance (the first one). see example http://tinydrblog.appspot.com/?p=89001, or better https://stackoverflow.com/a/5712953/613130
Comments
Post a Comment