Different behavior of override weak function in shared library between OS X and Android

前端 未结 2 834
Happy的楠姐
Happy的楠姐 2020-12-10 09:16

I am encountering a different behavior between OS X and Android:

  • There is a weak function foo in my shared library,
  • I want to override it
2条回答
  •  [愿得一人]
    2020-12-10 09:57

    Android dynamic linker does in fact support weak symbols. The problem is this particular case is that library is compiled with -Bsymbolic (to check this run "readelf -d libshared.so").

    The work around this is to use '-Wl,-shared' instead of '-shared' when linking the library.

    Please see https://code.google.com/p/android/issues/detail?id=68956 for details and workaround.

提交回复
热议问题