Name mangling

Daveed Vandevoorde daveed at edg.com
Mon Oct 18 18:12:51 UTC 1999


It's probably time to start working on this.

I think we'll first need to agree on what we want to mangle, and 
how much "optional info" we wish to have in mangled names (like 
return types).

To get the ball rolling, I've jotted down some notes collecting
"aspects of the problem"  (attached).

Please verify what items I might have left out.  If someone has
an authoritative answer as to which characters are allowed in
linkable names, please post them (or send them to me), and I'll 
add them to the document.

Opinions, fears, comments, insights and all those sorts of things
are eagerly sought ;-)

Cheers,

	Daveed
-------------- next part --------------
Name mangling
=============

Entities with linkable names
----------------------------
. functions and members functions (including operators)
. namespace scope variables and static data members
. virtual function tables
. any auxiliary tables used for installing construction vtables
. RTTI structures (std::type_info derivations)
. EH structures?

For entities with C name linkage, the entity's linkable name is identical to
its base name (as usual).


Decomposition of linkable names for function-like entities:
-----------------------------------------------------------
For function-like entities with C++ name linkage, the following components
MUST be part of the of the name:
  . an encoding of the base name (presumably, the base name itself)
  . an encoding of the declarative scope (classes and namespaces), when
    applicable
  . an encoding of each parameter type (with known positions)
  . an encoding of each template argument and the parameter it is associated
    with, when applicable

[ For the last item, consider:
    template<typename T1, typename T2> void f(T1, T2);
    template<typename T1, typename T2> void f(T2, T1);
  The encoding of each of these templates instantiated for <char, char> should
  be distinct. ]

In addition, it may be desirable to encode the following components:
  . the function's return type
  . the function's exception specifications
(Combined with the parameter types, this encodes the type of the function.
Note that even though exception specifications are not considered part of the
function type in the C++ standard; it actually is.)


Decomposition of linkable names for namespace scope variables and static
data members
------------
Such entities' linkable name must include at least:
  . an encoding of the base name (presumably, the base name itself)
  . an encoding of the declarative scope (classes and namespaces), when
    applicable

In addition, it may be desirable to encode the following components:
  . the variable's type (possibly including exception specifications)


General structure
-----------------


Available characters
--------------------
C++ identifiers consist of the following characters:
   'a'..'z'  'A'..'Z'  '0'..'9'  '_'
   Universal character codes: \u<hex-quad>, \U<hex-quad><hex-quad>

Overloadable C++ operators can contain the following additional characters:
   '['  ']'  '('  ')'  '<'  '>'  '%'  '*'  '+'  '-'  '/'
   '^'  '&'  '|'  '~'  '!'  '='  ','

All these should be encoded using the following characters acceptable in
linkable names:

   ???

subject to the following constraints:
  . encodings cannot collide with valid C names
  . ???


Special indicators (operators, tables, ...)
-------------------------------------------


Fundamental types and type operators
------------------------------------


Compression
-----------



More information about the cxx-abi-dev mailing list