RE: differences of memory layout of virtual function table.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jacob,

>-----Original Message-----
>From: Jacob Smith [mailto:jnsmith@xxxxxxxx]
>Sent: Wednesday, November 19, 2003 11:07 PM
>To: Susantha Kumara
>Subject: Re: differences of memory layout of virtual function table.
>
>
>Virtual tables are never guaranteed for C++; specifically, GCC has been
>known to deliberately break v-table hacks across implementations (you've
>given examples yourself).

Is there any documentation on HOW and WHY gcc does this ?.
Please point me to any such documentation

> There are a number of solutions for converting
>an object to a basic C-type. I'd suggest one of those. If you need more
>help, just post to the list.

Please let me know what they are. But this mechanisms should not have any
runtime overhead
and could be used with most compilers.

>
>-j.
>
>btw, I believe the pointer order for the first offset into the function
>table is dependent upon the number of virtual base classes the class
>has, not some arbitrary number.
>
In our case we dont have any virtual base classes. Anyway knowing how
exactly GCC does this
is very important to me. please give me any links

>Susantha Kumara wrote:
>
>>Hi all,
>>
>>I am writing a C Wrapper mechanism for C++ objects. Here the memory layout
>>of the virtual table is very important. I am searching for the differences
>>of memory layouts of the object/virtual pointer table(vtable) with various
>>compilers (GCC, BC, VC++ etc).
>>
>>I found that there is a difference of the virtual tables between the GCC
>>versions 2.96 and 3.2. The difference I found is in the offset for first
>>virtual function pointer,
>>	* in GCC 2.96 4th pointer (12-16th bytes) is the pointer to the first
>>virtual function, whereas
>>	* in GCC 3.2 3rd pointer (8-12th bytes) is the pointer to the first
virtual
>>function
>>
>>And in both GCC version I found that the pointer to the virtual destructor
>>is placed just before the first virtual function pointer. Is this
guarenteed
>>always ?.
>>
>>Any help for me to figure out how GCC synthesizes an object is greatly
>>appreciated.
>>
>>Thanks,
>>
>>Susantha.
>>
>>
>>
>>
>>
>>
>

Thanks in advance,

Susantha.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux