Function descriptors in vtable
Noam Lampert
noaml at mainsoft.com
Tue Jan 21 16:25:11 UTC 2003
We are currently trying to port our application to HP-Itanium. Our
application contains (among other things) an implementation for COM,
which is heavily dependent on the virtual table format. The current
virtual table format is very hard for us to work with. Specifically the
issue that is bothering us is 'B-4 Function descriptors in vtable' as
detailed in http://www.codesourcery.com/cxx-abi/cxx-open.html
The problem we have is that design of COM relies heavily on the 'fact'
that virtual tables contain pointers to functions. I am attaching a
simple C/C++ sample that shows the kind of usage COM tends to do. This
sample works for HP on PA-RISC (using the aCC compiler). If you want, I
can provide a working sample for Linux on IA32 (using gcc 3.2).
The kind of applications in which COM makes this assumption are:
1. Declaring, as a C literal, a structure that has the same binary
layout as a C++ virtual table.
2. Calling a C++ virtual method from within C code.
Specifically the second problem is more troubling. It is very common in
COM code to see code like
hr = pObject->lpVtable->method(pObject);
With the current vtable layout, every function call like this has to be
modified to
( (int (*) (IObject)) & pObject->lpVtable->method ) (pObject);
This modification is very hard to do, and is also unique to this
specific ABI. The result is that this specific ABI is designed such that
it is very hard to get COM to work on this ABI.
I have seen that this issue has been raised before, without a real
solution offered, at
http://www.codesourcery.com/cxx-abi/cxx-closed.html#B4
On possible way to extend the ABI (in order to limit binary
compatibility issues) is to define that the function descriptor can
either contain a <function address/GP> or a <function pointer/-1>. Code
that calls a virtual function will know how to deal with both formats.
The compiler can create either one (maybe dependent on a flag).
Thanks,
Noam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20030121/07d90a46/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.tar
Type: application/x-tar
Size: 10240 bytes
Desc: not available
URL: <http://sourcerytools.com/pipermail/cxx-abi-dev/attachments/20030121/07d90a46/attachment.tar>
More information about the cxx-abi-dev
mailing list