Android 4.2 - LD_PRELOAD supported or not?

二次信任 提交于 2019-12-07 16:39:37

问题


I wonder if LD_PRELOAD is now supported with the newer Android-versions?

At the time of 4.0 ICS it wasn't, and in the documentation (NDK docs/SYSTEM-ISSUES.html) there's still:

No support for LD_LIBRARY_PATH, LD_PRELOAD, RTLD_LOCAL and many other options.

But some days ago I have used LD_LIBRARY_PATH on my Android 4.2 Galaxy Nexus and it worked (!).

Thanks in advance!


回答1:


Generally speaking, LD_LIBRARY_PATH has worked on engineering builds (a.k.a. rooted devices) for quite a while. The problem is that this does not help for production builds - not because the loader is changed, but because the environment for your app is secured.




回答2:


Although the offical NDK-r9d documentation still says the same, but it turns out that LD_PRELOAD does work on rooted devices. Run

adb shell
setprop wrap.com.xyz.yourapp LD_PRELOAD=/path/to/your/library.so
stop
start

after pushing the library to the device. I tried it successfully on ANDROID-19 emulator to provide alternate definition of a function.

Check out this link - http://cedricvb.be/post/intercepting-android-native-library-calls/



来源:https://stackoverflow.com/questions/14426191/android-4-2-ld-preload-supported-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!