简体   繁体   中英

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.

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. How do I get the symbol information?

Please note, that I am using this .so file in another project, and there is symbol information. 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.

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 lib.so | c++filt -p -i

c++filt - Demangle C++ and Java symbols.

-p --no-params When demangling the name of a function, do not display the types of the function's parameters.

-i --no-verbose Do not include implementation details (if any) in the demangled output.

EDIT : Based upon the new ( ARM ) info provided in the question, try using symbols instead:

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

I've used awk to simplify output; 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. 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. (The paren- theses have to be quoted to get by the shell.) If no file is given, the symbols in a.out are listed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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