Search code examples
c++gccg++name-mangling

GCC C++ Name mangling reference


Looking around, I see mostly questions about demangling C++ symbols rather than how to mangle them. Yes, one could invoke g++, using the -S option, on some dummy code containing the symbols to be mangled, and then examine the resulting assembly, but I haven't been able to find a good reference or specification on GCC's name mangling. The closest thing I could find was at http://www.int0x80.gr/papers/name_mangling.pdf, but it doesn't seem to cover things like how names template instantiations are mangled or why _Z3fooIN3BarEE3FooIXT_EEv would translate into Foo<Bar> foo<Bar>() (though I can kind of see how, but what the hell is IXT_EE? Why is there no N after the _Z in this one? What's that even mean?).


Solution

  • Quote from source code of gcc's implementation of name mangling:

    This file implements mangling of C++ names according to the IA64 C++ ABI specification.

    And here is the rules from this specification: https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling