Using the PLT for vtables (or not)

Brian Ryner bryner@brianryner.com
Fri Dec 5 07:05:00 GMT 2003


Ian Lance Taylor wrote:
> action, you're going to get the address of the PLT.  So if it is OK to
> take that special action, then you might as well take it when you
> initialize the vtable at program start-up time.
> 

What sort of vtable initialization happens at startup time?  The vtables 
currently reside in a read-only section of memory, don't they?


> The real question is whether it is OK to skip the PLT for vtable
> entries.  Normally it is desirable to use the PLT because it permits
> the main program to override calls made from within a shared library.
> A vtable may be an exception to this, but that is not immediately
> obvious to me.
> 

Well, consider that if I were to build up a struct or array of function 
pointers from a class's constructor, I would be getting the real 
function address, not a PLT stub.  This seems like the same thing 
conceptually as a vtable, and yet it would not have the PLT overhead.

At the least, I'd like to see an attribute or compiler flag which could 
specify this behavior.

-- 
-Brian Ryner
bryner@brianryner.com



More information about the Gcc mailing list