1

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 in frameworks/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?

4
  • Did you verify that the application is not using an OpenGL function loader, as is common? Those libraries explicitly eschew the standard symbol resolution in favor of hundreds of dlsym calls directly on the OpenGL library.
    – Botje
    Commented Jun 28 at 9:58
  • @Botje I didn't, how to check it? I'm testing it with this simple app: github.com/Actinis/android-native-gles-demo
    – artem
    Commented Jun 28 at 10:10
  • That does not use a function loader, so nevermind my comment.
    – Botje
    Commented Jun 28 at 10:16
  • @Botje well after some research I can say that you were right. My app doesn't use it directly, but EGL loader does - in Loader::init_api. That's the most likely reason why interposition doesn't work.
    – artem
    Commented Jun 28 at 19:38

0