]> granicus.if.org Git - clang/commit
[MS ABI] Mangle symbols names longer than 4096 characters correctly
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 7 Mar 2016 08:51:17 +0000 (08:51 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 7 Mar 2016 08:51:17 +0000 (08:51 +0000)
commitcd2998e355f02a830f6a842968ae6f23ad23e8bf
tree396b0ec1c5b5262279bd3ca20b7395764d0ea321
parent1946734bb6b449978aeeac7341a63d968122b6ef
[MS ABI] Mangle symbols names longer than 4096 characters correctly

Really long symbols are hashed using MD5 and prefixed/suffixed with the
usual sigils.  There is an additional reason beyond the usual
compatibility with MSVC, it is important to keep COFF symbols shorter
than 0xFFFF because the CodeView debugging format has a maximum
symbol/record size of 0xFFFF.

There are some quirks worth noting:
- Some mangled names reference other entities which are mangled
separately.  A quick example:

int I;
template <int *> struct S {};
S<I> s;

In this case, the mangling for 's' doesn't depend directly on the
mangling for 'I'.  While 's' would need an MD5 hash if 'I' also needed
one, the hash for 's' applied to the fully realized mangled name.  In
other words, the mangled name for 's' will not depend on the MD5 of the
mangled name for 'I'.

- Some mangled names, like the venerable CatchableType, embed the MD5
verbatim.

- Finally, the complete object locator is handled as a special case.
A complete object locators are mangled exactly like a VFTable except for
a small deviation in the prefix sigils.  However, complete object
locators for hashed vftables result in a complete object locator whose
name is identical to the vftable except for an additional suffix.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@262818 91177308-0d34-0410-b5e6-96231b3b80d8
lib/AST/MicrosoftMangle.cpp
test/CodeGenCXX/mangle-ms-md5.cpp [new file with mode: 0644]