1

I'm trying to improve SymbolSort library, which reads PDB files with DIA SDK. I need to match the symbols read from object files with the symbols read from PDB.

The question is: given an IDiaSymbol variable, how can I obtain its real name? I'm not interesting in the undecorated or human-readable name, I need the mangled name, exactly as it appears in the object file, exactly as linker sees it.


The undecorated name can be easily obtained via IDiaSymbol::get_undecoratedName (ref). For decorated name, I use the following code:

    string rawName;
    IDiaSymbolUndecoratedNameExFlags flags = Flags.UNDNAME_32_BIT_DECODE | Flags.UNDNAME_TYPE_ONLY;
    diaSymbol.get_undecoratedNameEx((uint)flags, out rawName);

It was found empirically that this hack seems to work well in most cases (for no reason). But sometimes it gives some trash as result, e.g.:

diaSymbol.undecoratedName:
    "private: bool __cdecl idPhysics_Player::SlideMove(bool,bool,bool,bool) __ptr64"
rawSymbol:
    " ?? :: ?? ::Z::_N_N000 & __ptr64 volatile "
4

1 回答 1

2

我只从 PDB 中读取私有符号。私有符号通常不提供原始符号名称(在某些情况下甚至没有)。

该问题通过读取公共符号来解决(使用SymTagEnum.SymTagPublicSymbol)。对他们来说,diaSymbol.name总是给出符号的原始名称。

所有这些都在公共和私人符号文章中有详细记录。

于 2018-05-20T17:42:52.453 回答