加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – Itanium和MSVC ABI中跨模块边界的RTTI

发布时间:2020-12-16 07:03:41 所属栏目:百科 来源:网络整理
导读:我正在阅读 Itanium ABI It is intended that two type_info pointers point to equivalent type descriptions if and only if the pointers are equal. An implementation must satisfy this constraint,e.g. by using symbol preemption,COMDAT sections,o
我正在阅读 Itanium ABI

It is intended that two type_info pointers point to equivalent type descriptions if and only if the pointers are equal. An implementation must satisfy this constraint,e.g. by using symbol preemption,COMDAT sections,or other mechanisms.

有没有人知道在使用动态加载的库时,在使用GCC和GNU binutils的Linux等流行平台上如何实现这一点的血腥细节?它有多可靠?

另外,我对MSVC中的typeid比较的印象是(使用?)在错位符号名称上使用运行时字符串比较,因为无法保证满足此要求.这仍然是它的方式吗?是否有技术平台限制阻止MSVC使用与Itanium ABI平台相同的技术?

编辑还有一个问题:跨越模块边界的异常(在ABI中)是否也依赖于RTTI信息,或者除了相当于运行时dynamic_casts之外还有其他机制吗?

解决方法

MSVC首先使用指针比较,然后,如果失败,则比较字符串.您可以在VS2012的CRT源中看到实现:

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's 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始终仅使用指针比较.它应该与DLL一起使用的方式是动态加载器应该确保在程序的地址空间中存在每个异常的typeinfo对象的单个实例.

如果您对RTTI异常的实际实现和捕获信息感兴趣,请查看我的OpenRCE article(MSVC)和Recon 2012 presentation(GCC,MSVC x64).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读