Reading C++ symbols in a binary

objdump -t will pull the raw symbols out of an elf binary, but it is mangled format like this

0000000000000000       F *UND*  0000000000000006              _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@@GLIBCXX_3.4

c++ file will translate this to a human readly string that maps to the rigianlfunction definition:

 adyoung@adyoung-devd$ echo _ZNSt13basic_ostreamIwSt11char_traitsIwEElsEPFRS2_S3_E@@GLIBCXX_3.4 | c++filt
std::basic_ostream<wchar_t, std::char_traits<wchar_t> >::operator<<(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >& (*)(std::basic_ostream<wchar_t, std::char_traits<wchar_t> >&))@@GLIBCXX_3.4

To do this for an entire file, you want to print only the last column, a task custom made for awk:

 objdump -t   casttest | awk ‘{print $(NF)}’ | c++filt

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.