Android native libraries are pretty easy to decompile; they are, after all, just C/C++ object files and binaries compiled from the ARM platform. So decompiling them is as simple as finding a decompiler like the "ever-popular" objdump
decompiler for Linux that accommodates ARM binaries, and, as it turns out, this problem has been solved for us by the Android NDK.
Before we get into the details of this process, you need to make sure you have the right tools.
Getting ready for this recipe is as easy as making sure you have a fresh copy of the Android NDK package; you can grab a copy at http://developer.android.com/tools/sdk/ndk/index.html.
Decompiling a native library is as simple as invoking one of the tools provided with the Android NDK toolchain known as objdump
; it has been prebuilt to include all of the plugins that allow objdump
to interpret the endianness and code structures specific to the ARM binaries.
To decompile an Android native library, you need to execute the following command from your terminal or command prompt:
arm-linux-androideabi-objdump –D [native library].so
Here's an example:
Where arm-linux-androideabi-objdump
is located under the toolchains/arm-linux-androideabi-[version]/prebuilt/[arch]/bin/
folder of the Android NDK, where [arch]
would be the architecture or build version relevant to your machine. I'm using a Linux x86_64 machine in this example.
To make use of the information in the output of objdump
, you need to understand the opcode formats and instructions for the ARM platform and a little about the ELF format. I've included some good references to follow up in the See also section, including a link to an Android application called Sieve, which is used to demonstrate some of the commands used in this recipe.
18.189.185.42