How does GCC implement dynamic binding?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 dispatch, 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.

Is there any information available which documents, or can it be
otherwise officially confirmed, that GCC uses static v-tables?


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@xxxxxxxxxxxxx


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux