This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using the PLT for vtables (or not)


Jakub Jelinek wrote:
Actually this is not completely true.
Pointers in vtables normally resolve to:
a) the actual method in the binary if it has been linked into the binary
b) to the PLT slot in the binary if it was not linked into the binary
   but is referenced from the binary

Just trying to clarify a bit -- by "referenced from the binary", do you mean:


class A { virtual void Foo(); };
A a;
a.Foo();

or do you mean calling through the vtable:

A *a;
a->Foo();


Until my very recent binutils patch (which has been for IA-32 only so far),
b) means if a method address is taken (e.g. its address stored into some
vtable in the binary or its address taken in some other way) or if it
has been called from the binary.  With my patch calling from the binary
doesn't count, so b) happens only if method address is in a vtable or
stored somewhere, but not if just called from the binary.

Can you give an example of a case where the method address is stored into a vtable in the binary? Would this happen if the binary subclasses the class in the DSO with the virtual method (and does not override all of the virtual methods)? Are there other examples?


Or were you talking about vtables in the binary going through PLT
if a method they are referencing is not linked into the binary?

Is this the same sort of scenario I mentioned above with a subclass in the binary?


One more question -- does any of this change if the "binary" is a DSO which links against the original DSO?

Thanks for your detailed reply.

--
-Brian Ryner
bryner@brianryner.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]