From the perspective of assembly, the analysis structure of c ++ containing virtual base class objects

Source: Internet
Author: User

 flag = ; = ;= ;    

 top =  ~   Left :   left =  ~   Right :   right =  ~   Bottom :  Left,  bottom =  ~  


          ecx,[b]          :`vbase destructor

         dword ptr [ebp-],ecx            ecx,dword ptr [this]           ecx,1Ch          :~Bottom (1281055h)            ecx,dword ptr [this]           ecx,1Ch          :~Top (1281096h) 


         dword ptr [ebp-14h],ecx             eax,dword ptr [ebp-14h]           dword ptr [eax-1Ch],offset :`vftable (0C1674Ch)           eax,dword ptr [ebp-14h]           ecx,dword ptr [eax-18h]           edx,dword ptr [ecx+]           eax,dword ptr [ebp-14h]           dword ptr [eax+edx-18h],offset :`vftable (1286874h)           eax,dword ptr [this]           ecx,dword ptr [eax-]            edx,dword ptr [ecx+]           eax,dword ptr [this]            dword ptr [eax+edx-],offset :`vftable

Figure 1 Figure 2 Figure 3

01281C23 mov eax, dword ptr [this]; give this pointer to register eax
01281C26 mov dword ptr [eax-0Ch], offset Right: 'vftable' (1286874 h); the first address of the virtual table to the up offset this pointer 12byte memory, set the first virtual table
01281C2D mov eax, dword ptr [this]; give this pointer to register eax
01281C30 mov ecx, dword ptr [eax-8]
01281C33 mov edx, dword ptr [ecx + 4]; offset the memory content at the 4byte position of the first vbtable address (that is, the vbtable pointer offset from the first address of the Top virtual base class) to the Register edx
01281C36 mov eax, dword ptr [this]; give this pointer to register eax
01281C39 mov dword ptr [eax + edx-8], offset Right: 'vftable' (1286814 h); eax is this pointer, edx is offset, so eax + edx-8 even if the first address of the Top sub-object of the virtual base class
Here, the first address of the virtual table is given to the memory and the second virtual table is set.


           dword ptr [ebp-],ecx           eax,dword ptr [this]           dword ptr [eax-0Ch],offset :`vftable (1286788h)                                                                               


           dword ptr [ebp-],ecx           eax,dword ptr [this]           dword ptr [eax],offset :`vftable

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.