[Python-Dev] Problems with Python's default dlopen flags
Martin v. Loewis
06 May 2002 08:42:37 +0200
"David Abrahams" <email@example.com> writes:
> I don't know what the rules are when there are no virtual functions,
> or the virtual functions are inlinied, or the thrown type is a
> tempalte which is instantiated implicitly... of course this is OT
> for Python-dev but I'm hoping now that I've got the attention of MvL
> (a gcc developer) he'll answer these questions or direct me to
> someone who can ;-)
:-) In these cases, the compiler emits RTTI whenever it is "used",
which essentially means when a constructor or destructor is emitted
(since those explicitly reference the vtable, which explicitly
references the type_info object).
Thus, you may end up with multiple copies of the RTTI at the object
file level. When combining them into shared objects or executables,
when using the GNU linker, the linker will eliminate duplicates as
part of the gnu.linkonce processing; other linkers will pick an
arbitrary copy as part of the weak symbol processing.
At run-time, multiple copies across different DSOs are eliminated by
the dynamic loader (ld.so) *if* all those copies are in the global
symbol space (RTLD_GLOBAL).
During the development of the standard C++ ABI, people thought that
those mechanisms will guarantee that symbols can be resolved uniquely
at run-time, thus allowing address comparisons for typeinfo object
equality. It turned out that this won't work even in cases that are
meant to be supported, so the C++ runtime is now back to comparing
typeinfo object's .name() strings to establish equality.