简体   繁体   中英

My c++filt doesn't seem to work properly, no output changes

On my linux, I've a .cpp file having

void f(){}
struct C{void f(){}};

I compiled it and strings the binary, try to de-mangle the function name:

$c++filt __Z1gv
__Z1gv
$c++filt __ZN1C1fEv
__ZN1C1fEv

Well, it doesn't seem to work as I expected. Did I get anything wrong here? Do I have to add some letters or remove some letters to make it work?

Note these names are clang symbols, seems c++filt only work for my gcc version? Or c++filt should have newer version to support both compilers?

You may need to pass the -_ flag.

$ c++filt -_ __Z1gv
g()
$ c++filt -_ __ZN1C1fEv
C::f()

-_
--strip-underscore

On some systems, both the C and C++ compilers put an underscore in front of every name. For example, the C name " foo " gets the low-level name " _foo ". This option removes the initial underscore. Whether c++filt removes the underscore by default is target dependent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM