Alon Gubkin
Alon Gubkin

Reputation: 57129

Find function signature in Linux

Given a .so file and function name, is there any simple way to find the function's signature through bash?

Return example:

@_ZN9CCSPlayer10SwitchTeamEi

Thank you.

Upvotes: 1

Views: 3078

Answers (4)

Paul Rubel
Paul Rubel

Reputation: 27232

nm has a useful --demangle flag that can demangle your .so all at once

nm --demangle library.so

Upvotes: 2

shodanex
shodanex

Reputation: 15406

nm -D library.so | grep FuncName

Upvotes: 0

Michael Anderson
Michael Anderson

Reputation: 73520

My compiler mangles things a little different to yours (OSX g++) but changing your leading @ to an underscore and passing the result to c++filt gives me the result that I think you want:

bash> echo __ZN9CCSPlayer10SwitchTeamEi | c++filt
CCSPlayer::SwitchTeam(int)

doing the reverse is trickier as CCSPlayer could be a namespace or a class (and I suspect they're mangled differently). However since you have the .so you can do this:

bash> nm library.so | c++filt | grep CCSPlayer::SwitchTeam
000ca120 S CCSPlayer::SwitchTeam
bash> nm library.so | grep 000ca120
000ca120 S __ZN9CCSPlayer10SwitchTeamEi

Though you might need to be a bit careful about getting some extra results. ( There are some funny symbols in those .so files sometimes)

Upvotes: 9

Raghuram
Raghuram

Reputation: 52655

Try

strings <library.so>

Upvotes: 0

Related Questions