The mangling scheme used by Sun C++ is not secret, but it is quite complicated. We don't have a document that describes it. available for public access. Maybe you could explain why you need the details
We provide the "dem" program with the compiler, and library /usr/lib/libdemangle.so with header <demangle.h> to demangle names for you.
If you need to generate a mangled name, the simplest and most reliable way is to use the compiler to create it. For example: [code]
% cat mang.cc
namespace N1 {
class C1 { };
class C2 {
int foo(C1*);
};
int C2::foo(C1*) { return 0; }
}
% CC -c mang.cc
% nm mang.o | grep GLOB | grep FUNC
[6]| 0|21|FUNC |GLOB |0|2|__1cCN1CC2Dfoo6Mpn0ACC1__i_
[/code]You can see that the mangled name of N1::C2::foo is __1cCN1CC2Dfoo6Mpn0ACC1__i_
Yes, of course I know the "dem" program. Thanks to it I already know some rules of mangling. But my experience is not full. I tried to google but didn't find anything interesting.
I need to call functions from CC libraries directly using dlsym(). I parse "iostream.h" header and then need to call function (e.g. cout<<"hello";) from C++ library to execute the code. Because I need to know the function-name saved in a library to make a dlsym() call, I must know how CC does mangling.
The mangling rules are too complicated for you to generate the correct mangled name yourself. Even the engineer who developed the algorithm can't do it himself correctly every time.
In particular, the mangler uses some compression techniques. It keeps track of types and partial types as it sees them, and uses an encoding to indicate the type (or partial type) number previously seen instead of repeating the mangling for that type (or partial type).
The mangler also has some known bugs that we can't fix because it would break binary compatibility. So even if you could execute the mangling algorithm yourself without error, you still might wind up with a mangled name different from what thecompiler actually generates.
I strongly recommend you use the techniques I outlined earlier.