开发者

Find function signature in Linux

开发者 https://www.devze.com 2023-01-18 03:23 出处:网络
Given a .so file and function name, is there any simple way to find the function\'s signature through bash?

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

Return example:

@_ZN9CCSPl开发者_高级运维ayer10SwitchTeamEi

Thank you.


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)


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

nm --demangle library.so


Try

strings <library.so>


nm -D library.so | grep FuncName
0

精彩评论

暂无评论...
验证码 换一张
取 消