http://llvm.org/bugs/show_bug.cgi?id=18248

            Bug ID: 18248
           Summary: [-cxx-abi microsoft] Mange string literals properly
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

consider:
inline char const *g() {
  static char *b = "\00\00\00";
  static wchar_t const *c = L"\00";
  return c ? 0 : b;
}
const char *h() { return g(); }

MSVC mangles the literal for 'b' as ??_C@_03NOLLCAOD@?$AA?$AA?$AA?$AA@
and the literal for 'c' as ??_C@_13NOLLCAOD@?$AA?$AA?$AA?$AA@

subtracting 'P' from 'NOLLCAOD' for each character and converting to hex yields
0xdebb20e3.

This appears to be a crc:
>>> hex(crcmod.mkCrcFun(0x104C11DB7, initCrc=0xffffffff, rev=True, 
>>> xorOut=0)("\00\00\00\00"))
'0xdebb20e3L'

Here is my best bet for it's mangling:

<char-type> ::= 0   # char
            ::= 1   # wchar_t
            ::= ??? # char16_t/char32_t will need a mangling too...

<literal-length> ::= <non-negative integer> # the length of the literal

<encoded-crc> ::= <hex digit>+ @ # crc of the literal including null-terminator

<encoded-string> ::= <simple character>      # uninteresting character
                 ::= <hex digit> <hex digit> # these two nibbles encode the
byte for the character

<literal> ::= ?? _C @ _ <char-type> <literal-length> <encoded-crc>
<encoded-string>

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to