Is there a way to read the contents of a .so file without downloading it?

Is there a way to read the contents of a .SO (shared objects) file without loading it?

My use case:

  • I have a .so file on windows. I need to request some methods, whether they are present in .so or not.
  • Know all the classes in the .so file.
  • To determine the class name, you must find all the methods of this class.

Note. I can easily do this in a DLL. I am also working on windows, so I cannot load the .SO file.

thanks

+6
source share
3 answers

You can read these files using the tools included with GNU binutils. Although GNU binutils is usually installed on Linux systems, this does not apply to Windows. However, they work on Cygwin or minGW on Windows.

Resources

Note that with MinGW (3.) you do not need Cygwin (2.) and compile Binutils (1.) yourself. Binutils is included in MinGW (3.), but you can also try to download only a part of Binutils MinGW (4.).

How to use nm and readelf to get information is explained here: How to list the characters in a .so file

If you want to include this functionality in a C ++ program, you can either include the source code of these tools (beware of the license!) Or call them from your program. You will probably need the Cygwin environment to copy the source code under Windows.

+4
source

To screen: readelf -a <file>

To save the output, upload it to a file. For example, I am studying the Python RPi.GPIO module on the Raspberry Pi, which is stored in / usr / lib / python 2.7 / dist-packages / RPi, so I run: readelf -a GPIO.so > ~/gpio.so.out

+4
source

Yes, the necessary solution for Windows. I used the nm.exe tool present in the ndk tools in android sdk / ndk.

i unloaded the output of nm.exe to some file, and then using a regular expression I extracted all the classes and methods from it.

+1
source

Source: https://habr.com/ru/post/956043/


All Articles