Reputation: 429
Using Android NDK is it possible (from native C-code) to get a list of loaded .so libraries? I am looking for an Android-version of the iOS functions _dyld_image_count()/_dyld_get_image_name().
Also is it possible to get the library name of the .so containing a specific function (on iOS this function is dladdr()).
Upvotes: 2
Views: 612
Reputation: 7023
Yes you can Get this Here is Sample
try {
Set<String> libs = new HashSet<String>();
String mapsFile = "/proc/" + android.os.Process.myPid() + "/maps";
BufferedReader reader = new BufferedReader(new
FileReader(mapsFile));
String line;
while ((line = reader.readLine()) != null) {
if (line.endsWith(".so")) {
int n = line.lastIndexOf(" ");
libs.add(line.substring(n + 1));
}
}
Log.d("Ldd", libs.size() + " libraries:");
for (String lib : libs) {
Log.d("Ldd", lib);
}
} catch (FileNotFoundException e) {
// Do some error handling...
} catch (IOException e) {
// Do some error handling...
}
try this This Might Help You
Upvotes: 1
Reputation: 28087
You can read and parse /proc/self/maps
file. It contains which address each shared object loaded for your application. self
will help your application to read its own info.
nm command line utiliy which is also available in Android NDK can show you which symbols are available from certain shared object files. You can look how it is implemented and try to utilize the same libraries, but it won't be trivial.
Upvotes: 1