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]

FW: How does GCC implement dynamic binding?


 
Hello,

We are using GCC 3.3.1 and have a requirement imposed upon us by our
customer to "...establish that the C++ compiler implements dynamic
binding by utilizing static lookup tables..."

This implies the need for documentation on GCC's implementation of
dynamic binding, which is typically achieved in "most compilers" through
static vtables.  At the GCC site
(http://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Vague-Linkage.html#Vague-Li
nkage), the manual for our compiler states:

===========
Vtables
C++ virtual functions are implemented in most compilers using a lookup
table, known as a vtable. The vtable contains pointers to the virtual
functions provided by a class, and each object of the class contains a
pointer to its vtable (or vtables, in some multiple-inheritance
situations). If the class declares any non-inline, non-pure virtual
functions, the first one is chosen as the "key method" for the class,
and the vtable is only emitted in the translation unit where the key
method is defined.

Note: If the chosen key method is later defined as inline, the vtable
will still be emitted in every translation unit which defines it. Make
sure that any inline virtuals are declared inline in the class body,
even if they are not defined there.
===========

The best we have here is an inference that the 3.3.1 compiler uses
lookup tables (note the term "most compilers"), and no indication at all
re whether they are static in size and content.

The C++ FAQ site
(http://www.parashift.com/c++-faq-lite/virtual-functions.html#faq-20.4)
implies that "most C++ compilers" use a scheme similar to the one
presented on that page, i.e., that the v-tables are created at compile
time, and are static in size and content.  The only run-time (dynamic)
aspect is the initialization of the v-pointer in the class constructor.

Given all this, I posed this question to the gcc mailing list and
received a reply that directed me to the C++ ABI
(http://codesourcery.com/cxx-abi/), which is more detailed and has the
information I'm looking for.  However, I need to confirm, in the case of
an FAA audit, that GCC 3.3.1 implements dynamic binding in this fashion.
Can anyone on the steering committee "officially" confirm that GCC uses
static v-tables as described in the ABI?

Thank you for your time.  I look forward to your response.

Regards,

Greg Lacefield
Principal Software Engineer
Honeywell
CommNav Engineering
Aerospace -- Redmond
15001 NE 36th Street, M/S B13E
Redmond, Washington  98052
(425) 376-2353  office
(425) 647-5281  mobile
(425) 885-8319  fax
mailto:greg.lacefield@honeywell.com


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