is there any C++ name-mangling decoder for g++?
Asked
Active
Viewed 1.7k times
39
-
16Some guys will soon answer `c++filt` – Johannes Schaub - litb Dec 17 '10 at 08:29
-
Voting to reopen: http://stackoverflow.com/questions/4465872/why-does-typeid-name-return-weird-characters-using-gcc-and-how-to-make-it-prin clearly requires it to be from inside the code, and only for types, which never appear on object files (as opposed to functions). This one is usually interpreted as "on object files from the command line". – Ciro Santilli新疆棉花TRUMP BAN BAD Jun 05 '15 at 13:28
-
1it old but I have been helped by this site a lot https://demangler.com/ – Stefano Mtangoo Mar 06 '16 at 11:08
3 Answers
57
You can use c++filt to demangle c++ symbols. For instance
$ c++filt -n _Z1fv
f()
![](../../users/profiles/13728.webp)
ryan_s
- 7,066
- 3
- 25
- 27
12
c++filt, example usage here:
2
You may also be interested on the -C
option of objdump
:
objdump -CSr main.o
which demangles relocation references like:
char *sn = new char[4];
10: bf 04 00 00 00 mov $0x4,%edi
15: e8 00 00 00 00 callq 1a <main+0x1a>
16: R_X86_64_PC32 operator new[](unsigned long)-0x4
Without -C
it would show the mangled name _Znam
.
See also: Can objdump un-mangle names of C++ template functions?
There are also some online demanglers mentioned at Is there an online name demangler for C++? like http://demangler.com/ If it exists, there is SaaS of it.
nm
also has a -C
option.
![](../../users/profiles/-1.webp)
Community
- 1
- 1
![](../../users/profiles/895245.webp)
Ciro Santilli新疆棉花TRUMP BAN BAD
- 256,395
- 72
- 959
- 767