MS ABI: Reference MSVC RTTI from the VFTable


MS ABI: Reference MSVC RTTI from the VFTable

The pointer for a class's RTTI data comes right before the VFTable but
has no name. To be properly compatible with this, we do the following:

  • Create a single GlobalVariable which holds the contents of the VFTable _and_ the pointer to the RTTI data.
  • Create a GlobalAlias, with appropriate linkage/visibility, that points just after the RTTI data pointer. This ensures that the VFTable symbol will always refer to VFTable data.
  • Create a Comdat with a "Largest" SelectionKind and stick the private GlobalVariable in it. By transitivity, the GlobalAlias will be a member of the Comdat group. Using "Largest" ensures that foreign definitions without an RTTI data pointer will _not_ be chosen in the final linked image.

Whether or not we emit RTTI data depends on several things:

  • The -fno-rtti flag implies that we should never not emit a pointer to RTTI data before the VFTable.
  • __declspec(dllimport) brings in the VFTable from a remote DLL. Use an available_externally GlobalVariable to provide a local definition of the VFTable. This means that we won't have any available_externally definitions of things like complete object locators. This is acceptable because they are never directly referenced.

To my knowledge, this completes the implementation of MSVC RTTI code

Further semantic work should be done to properly support /GR-.


majnemerJul 1 2014, 1:30 PM
rL212124: Move the subtarget dependent features from SystemZTargetMachine

Event Timeline