RTTI across module boundaries in Itanium and MSVC ABI

I am reading Itanium ABI which says that

Two type_info pointers are supposed to point to equivalent type descriptions if and only if the pointers are equal. An implementation must satisfy this limitation, for example. using characters, COMDAT sections, or other mechanisms.

Does anyone know the details of how this is done in practice on popular platforms, such as, for example, Linux using GCC and GNU binutils when using dynamically loaded libraries? How reliable is it?

In addition, I have the impression that the comparison typeid in MSVC (sold?) Implemented using performance mapping strings of distorted character names just because this requirement can not be guaranteed. Is this still how it is done? Are there limitations in the technical platform that prevent MSVC from using the same method as on Itanium ABI platforms?

EDIT Another question: does the exception trap at the borders of the modules (in the ABI) rely on RTTI information, or is there another mechanism besides the dynamic_cast s runtime equivalent?

+4
source share
1 answer

MSVC first uses pointer comparison, and then, if that fails, compares the strings. You can see the implementation in the CRT VS2012 sources:

 extern "C" _CRTIMP int __cdecl __TypeMatch( HandlerType *pCatch, // Type of the 'catch' clause CatchableType *pCatchable, // Type conversion under consideration ThrowInfo *pThrow // General information about the thrown // type. ) { // First, check for match with ellipsis: if (HT_IS_TYPE_ELLIPSIS(*pCatch)) { return TRUE; } // Not ellipsis; the basic types match if it the same record *or* the // names are identical. if (HT_PTD(*pCatch) != CT_PTD(*pCatchable) && strcmp(HT_NAME(*pCatch), CT_NAME(*pCatchable)) != 0) { return FALSE; } ... 

Itanium ABI always uses only pointer comparisons. The way it should work with the DLL is that the dynamic loader must ensure that for each exception in the program address space there is a single instance of the typeinfo object.

If you are interested in actually implementing the RTTI exception and catch information, see my OpenRCE (MSVC) article and Recon 2012 presentation (GCC, MSVC x64).

+1
source

All Articles