1

I only have access to an object file for my assignment. When I disassemble the file I can read most of the assembly, but I'm having some trouble with a few calls. A call will mention some mangled names like:

callq 0x147 <main+206> _ZNSirsERi-0x4

So I did some research and found that using readelf -s 'filename' shows the .symtable and gives me these mangled names

19: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZSt3cin
20: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSirsERi
21: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSolsEi

Is there a way to demangle this? Or find out what the -0x4 is referencing in the call? Obviously _ZSt3cin is a cin call. But I don't know what the rest are doing.

Troutt025
  • 55
  • 4
  • 1
    would the `--demangle[=style]` option help? – jspcal Jun 09 '22 at 20:03
  • How would I implement this? ```readelf -s 'filename' --demangle[=style]``` and ```readelf -s --demangle[=style] 'filename'``` both give errors for readelf syntax. – Troutt025 Jun 09 '22 at 20:14
  • 2
    @Troutt025 `[=style]` means that you can optionally pass a demangling style to the option. Just `--demangle` (i.e. `-C`) should do the trick. – fuz Jun 09 '22 at 20:42

1 Answers1

0

It seems that nm had options that helped me.

nm -gC 'filename' gave me the demangled names I was looking for!

Troutt025
  • 55
  • 4
  • 1
    `readelf` has the same `-C` aka `--demangle` option, the default demangling style being the same one g++/clang++ use on that platform. So does `objdump`. e.g. `alias disas=objdump -drwC -Mintel` is a shell shortcut I find useful. – Peter Cordes Jun 09 '22 at 21:12