0

I do some C++ disassembling with IDA Pro. But I often see lines likes these.

call    __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc ;std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char  const*)

What are these glyphs about? Why does the C++ function look so complex? And how can I simplify my ASM. Thanks in advance.

jarCrack
  • 106
  • 2
  • 9
  • 1
    The symbol name contains information about the return type and parameter count and types of a function. This is done to allow for, among other things, function overloading. –  May 09 '14 at 23:25
  • possible duplicate of [Why does the function name in .o file different from the one in .cc file after compiling?](http://stackoverflow.com/questions/18243578/why-does-the-function-name-in-o-file-different-from-the-one-in-cc-file-after-c) and/or [What is name mangling, and how does it work?](http://stackoverflow.com/q/1314743) – Cody Gray - on strike May 10 '14 at 00:24
  • `Options -> Demangled names -> [x] Names` This should make it a bit easier to read. – athre0z May 14 '14 at 15:15

2 Answers2

4

C++ ensures that overloaded functions can be distinguished by the linker by mangling their names. What you are seeing is type information encoded in the mangled function name.

thus spake a.k.
  • 1,607
  • 12
  • 12
2

That is the output function for (for example)

cout << "something";

std::operator<< is the name of the function. It takes a std::basic_ostream<char, std::char_traits<char>>& argument - in other words, std::ostream The second argument is a char const *, in other words, a classic C style string that isn't supposoed to change.

Since operator<< also returns a std::ostream&, this is encoded before the name

It's "complicated" because it's easier to define one, templated, basic_ostream since there are various types of streams, such as owstream that takes "wide chars", it's useful to have a templated basic_ostream that can be instantiated to form a std::ostream, than to have to implement several different, essentially the same, stream classes.

Mats Petersson
  • 126,704
  • 14
  • 140
  • 227