Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get nm to show the return types of a function?

Tags:

c++

linux

I'm trying to write a script to produce a 'fake' version of a huge and messy code library, I thought using 'nm' on the binary and filtering just the text symbols might be the way to go, but I can't seem to get nm to display the return type of the function as well as the signature.

Many thanks in advance.

like image 806
Chris Huang-Leaver Avatar asked Dec 05 '10 19:12

Chris Huang-Leaver


1 Answers

The return type of the function is not part of the name mangling. Return types are enforced by the compiler directly based on type rules.

It is possible to call a function defined as, for example, returning int, and having a declaration for it returning, say char. Most tools will not notice the mismatch. Considering all they ways you might shoot yourself in the foot, this isn't too bad since you would have to have gone out of your way to do it. Like by not using a header file common to both modules.

like image 189
wallyk Avatar answered Oct 10 '22 07:10

wallyk