I have a shared library that interposes some GLES calls (glClear, for example).
It works fine on Linux with a simple LD_PRELOAD
, but I can't get it working on Android.
My library prints to logcat on load, so I can know if it's loaded or not.
LD_PRELOAD
loads the library, but doesn't interpose gl calls - the app still calls functions from the "original" system gl lib.- Tried to load it by modifying different parts of AOSP (14), for example call
dlopen
before loading any other gl libs inframeworks/native/opengl/libs/EGL/egl.cpp:egl_init_drivers
. It loads, but again interposition doesn't work.
Symbols seem to be fine:
nm -D libgl.so | grep glClear
00000000001ecdb0 T glClear
00000000001ed5c0 T glClearColor
- My library is in
/data/local/tmp/
, not bundled in any app. - SELinux is set to permissive mode.
- I can modify any part of AOSP source.
- I can't replace the system GL libs, as I need to "override" only few functions and only for few apps.
Any ideas how to make it work?
dlsym
calls directly on the OpenGL library.Loader::init_api
. That's the most likely reason why interposition doesn't work.