Post Reply

[TUTORIAL] Find out which shared libs (.so) are missing

OP tuxboy

6th January 2015, 10:54 PM   |  #31  
bluflight's Avatar
Senior Member
Thanks Meter: 675
 
422 posts
Join Date:Joined: Nov 2008
Quote:
Originally Posted by _that

For finding native library dependencies of apks, you need to decompile them, search the smali files for invokes of "loadLibrary" and trace the argument back to the string constant (usually it's just a few lines above the loadLibrary call). Prepend "lib" to the string constant and append ".so", that's the name of the required native library.

An example could look like this:

Code:
    const-string v0, "defcontainer_jni"
    invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V
So we know that this app requires libdefcontainer_jni.so.

Many thanks mate, you do not know how long I was looking for this so I imagine that if I do not find in Smali invoke of loadLibrary mean this app not need/create any .so file when installed, right?
7th January 2015, 12:32 AM   |  #32  
Recognized Contributor
Thanks Meter: 2,650
 
3,645 posts
Join Date:Joined: Oct 2012
More
Quote:
Originally Posted by bluflight

Many thanks mate, you do not know how long I was looking for this so I imagine that if I do not find in Smali invoke of loadLibrary mean this app not need/create any .so file when installed, right?

If it's not a system app, the apk will contain all required libraries anyway, so you just need to look what's inside the apk. For system apps it's different, because all their shared libraries are mixed together in /system/lib. For both system and non-system apps, the native libraries need to be loaded somehow from the compiled Java code, and I think there is no other way than calling loadLibrary. So, yes, if there is no loadLibrary call, the app doesn't use any native libraries. Or it uses an unknown mechanism to load them.

Not directly related to your apk question, but related to the topic of this thread:
I've recently written a script to check native dynamic library dependencies. It does not only check which libraries are needed, but also if those libraries are compatible and if all unresolved symbols are resolved, and which symbols are used from which library. Very useful for porting ROMs onto older proprietary HAL libraries or for porting stock system apps to different ROMs. If there is interest, I'm going to release it in a separate thread with some documentation. If you need it already now, look for "ldcheck" in my github.
The Following User Says Thank You to _that For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes