Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get source code of .so file in android

I want to see source code of shared object library (so) file in android. how can i convert .so binary file to native c/c++ code.

like image 893
Riyas Ahamed Avatar asked Oct 15 '16 09:10

Riyas Ahamed


People also ask

How do I get the source code of an .so file?

There isn't. Once you compile your code there is no trace of it left in the binary, only machine code. Some may mention decompilers but those don't extract the source, they analyze the executable and produce some source that should have the same effect as the original one did.

What is .so file in Android?

The SO file stands for Shared Library. You compile all C++ code into the.SO file when you write it in C or C++. The SO file is a shared object library that may be dynamically loaded during Android runtime. Library files are larger, often ranging from 2MB to 10MB in size.

Can you open .so files?

An . so file is a binary file used as a native library on Android. Normally it's a part of an Android application. If you want to see its content, you need to open it as a binary file in a binary (hex) viewer.


1 Answers

The purpose of making an so file is to NOT share the source code, no matter if it is android or not. This is intentionally designed this way so as not to open the design. Following this, many firms share .so file (machine instructions) keeping their design confidential.

However, if you are keen to know what the .so file contains, you may read the ELF (Executable and Linkable Format) of the library. command

readelf -a yourLibraryName.so > yourLibraryName_elf.txt

The output contains symbol table. You may search for the function names, global variables etc from the generated text file.

More details of the contects here http://www.skyfree.org/linux/references/ELF_Format.pdf

like image 181
Raja Jitendra Avatar answered Oct 13 '22 01:10

Raja Jitendra