patch to bring java vtables closer to g++ abi conformance

Per Bothner
Wed Jan 23 09:55:00 GMT 2002

The g++ v3 abi ( specifies
that each vtable contains an offset-to-top and a type_info pointer.
These words are *before* the word pointed to by each object's vtable
pointer.  Thus if we add the extra header words it does not actually
break binary compatibility, unless you look at these new fields - or the
object's file symbols.   I.e the vtable pointer to class foo is now
_ZTVN3fooE+8 (assuming a 32-bit target) instead of ZTVN3fooE.

This patch does not actually implement the type_info pointer, but leaves
a slot for a pointer which we can fill in later.  If we do that then
C++ code that uses rtti might actually work instead of crashing.  If we
do this, perhaps we can embed the type_info object *inside* a Class
object, as if Class inherits from *both* Object and type_info.  But
I left this for another day.

So this change doesn't at this point have much effect, except adding two
words for each Java class.  However, it brings us closer to abi
compliance, making it less likely to confuse various tools such as
debuggers.  I looked at this issue in the context of gdb crashing.  Now
I'm not totally sure this patch is needed for gdb, since I also fixed
some things in gdb itself.  In any case it seems like a good idea.

Comments?  Anyone think I shouldn't check it in?
	--Per Bothner
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: vtable.patch
URL: <>

More information about the Java mailing list