简体   繁体   English

如何在OSX中打印.so文件的符号列表?

[英]How to print symbol list for .so file in OSX?

I have an .SO file (note, not .a, not .dylib and not .o) and I need to get symbol information from it on OSX. 我有一个.SO文件(请注意,不是.a,.dylib和.o),我需要在OSX上从该文件中获取符号信息。

I have tried 我努力了

nm -gU lib.so

However, nothing is printed out. 但是,什么都没有打印出来。

I can't use otool because it's not an object file, and readelf does not exists on OSX. 我不能使用otool,因为它不是目标文件,并且OSX上不存在readelf。 How do I get the symbol information? 我如何获得符号信息?

Please note, that I am using this .so file in another project, and there is symbol information. 请注意,我正在另一个项目中使用此.so文件,并且其中包含符号信息。 I am able to load the library, and reference functions from it. 我能够加载该库,并从中引用函数。 However, I have yet to find a tool on OSX to let me print the symbol information from it. 但是,我还没有在OSX上找到可以让我从中打印符号信息的工具。

As asked, 根据要求

file lib.so

ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, stripped

Try using c++filt piped from nm : 尝试使用从nm管道输送的c++filt

nm lib.so | c++filt -p -i

c++filt - Demangle C++ and Java symbols. c ++ filt-分解C ++和Java符号。

-p --no-params When demangling the name of a function, do not display the types of the function's parameters. -p --no-params取消函数名称时,不显示函数参数的类型。

-i --no-verbose Do not include implementation details (if any) in the demangled output. -i --no-verbose不要在已拆散的输出中包括实现详细信息(如果有)。

EDIT : Based upon the new ( ARM ) info provided in the question, try using symbols instead: 编辑 :根据问题中提供的新( ARM )信息,尝试改用symbols

symbols lib.so -arch arm | awk '{print $4}'

I've used awk to simplify output; 我用awk简化了输出。 remove to output everything. 删除以输出所有内容。

Manual page : Symbols 手册页:符号

https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/nm.1.html Nm displays the name list (symbol table) of each object file in the argument list. https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/nm.1.html Nm在参数列表中显示每个对象文件的名称列表(符号表)。 If an argument is an archive, a listing for each object file in the archive will be produced. 如果参数是存档,则将为存档中的每个目标文件生成清单。 File can be of the form libx.a(xo), in which case only symbols from that member of the object file are listed. 文件可以采用libx.a(xo)的形式,在这种情况下,仅列出来自目标文件成员的符号。 (The paren- theses have to be quoted to get by the shell.) If no file is given, the symbols in a.out are listed. (外壳程序必须用引号将其括起来。)如果未给出文件,则会列出a.out中的符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM