Alexey
Alexey

Reputation: 800

Is it possible to get function's signature from a library?

Let's suppose nm reports a function symbol in the library utils:

$ nm --defined-only utils.so
T function_symbol

Is it possible to determine the signature of that function (return type and parameters)? Or at least the number of parameters and the size of each parameter?

Upvotes: 2

Views: 1358

Answers (1)

Florian Weimer
Florian Weimer

Reputation: 33717

It is possible to obtain this information from DWARF debugging information. But if the debugging information is unavailable (either because it has been stripped or was not generated during compilation in the first place), this is not possible. An ELF object does not contain this information.

For C++ function symbols, the mangling shows the type of the function arguments, but even there, the type of the function result is missing, so the picture is still incomplete.

Upvotes: 2

Related Questions