I have overloaded functions like:
void f(int)
void f(int, int)
void f(int, float)
How to compile it, so that i can see the mangled output?
Something like:
void f(int) should show: ?f@@YAXH@Z(int)
Like for example, to see pre-processor output we use -E
, assembler output -s
, what is it for name mangled output?
P.S: Platform is Linux
EDIT:
And by the answers here we go:
void func(int);
void func(int, int);
void func(void);
void func(char);
[root@localhost ~]# cat a.map | grep func
0x0804881a _Z4funcc
0x08048790 _Z4funcv
0x080487be _Z4funcii
0x080487ec _Z4funci
For GCC try using:
-Xlinker -Map=output.map
http://gcc.gnu.org/onlinedocs/gcc/Link-Options.html
This will generate a map file which will have all of the mangled symbol names.
And for MSVC:
http://msdn.microsoft.com/en-us/library/k7xkk3e2(v=vs.80).aspx
This will generate something such as:
0002:00094190 ??0SerializationException@EM@@QAE@ABV01@@Z 10148190 f i y:foo.obj
In Linux, I can see the names of all symbols via nm
. For example:
$ nm a.out | grep pthread
w pthread_cancel@@GLIBC_2.2.5
U pthread_key_create@@GLIBC_2.2.5
U pthread_key_delete@@GLIBC_2.2.5
The -S
option tells GCC to only compile but not assemble a function. I. e., it will output human-readable assembly text, in which you'll be able to see the function names. Run it through c++filt
so that you can associate the mangled names with the unmangled ones.
There should be some options in your compiler/linker to create a map file.
Within that file you can see the mangled names of all functions and methods.