Special characters in mangled names

Mark Mitchell mark at codesourcery.com
Mon Nov 15 16:55:22 UTC 1999


>>>>> "Jonathan" == Jonathan Schilling <jls at sco.com> writes:

    >> From: Christophe de Dinechin <ddd at cup.hp.com>
    >> 
    >> > Two weeks ago we made some initial discussions about what
    >> special > characters we could us as an "escape encoding" for
    >> mangled names > (in cfront and cfront-like models, a double
    >> underscore is used, > but it seems desirable to instead have a
    >> convention that cannot > collide with C identifiers at all).
    >> 
    >> Is it really desirable? It did not cause a problem so-far, and
    >> there are occasions where being able to define a C++ function
    >> in C or assembly is useful.

    Jonathan> Agreed.  SCO's OS has at least one place where we have
    Jonathan> to refer to a mangled name from C.

In a discussion with Matt Austern I suggested using a
collision-resistant hash function on the manglings to generate the
names actually used in object files.  (The algorithm is: first mangle,
then hash.)  This could really reduce .o size a ton; think expression
templates, etc.  I bet this would have a much bigger impact that any
obvious compression algorithm; you could just decree that all symbols
be no longer than 256 bits long, say.  Lots of tools (assemblers,
debuggers) will use less space/time dealing with the shorter names.
You would keep around a table mapping hashes back to the original
mangled names for debugging.

An interesting twist on this would be to use a secure hash with a key.
For ordinary compilation, use some well-known key.  But, by setting
some flag/environment-variable you could tell the compiler to use a
key of your choice.  You can now distribute a .o that is hard to link
to -- unless you know the key.

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list