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

谁都会走 提交于 2019-11-28 10:31:41

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.

Android doesn't support weak symbol override.

In the recent release android-5.0.2_r1, see the comment at line 539 in linker.cpp source code

/*
 *
 * Notes on weak symbols:
 * The ELF specs are ambigious about treatment of weak definitions in
 * dynamic linking.  Some systems return the first definition found
 * and some the first non-weak definition.   This is system dependent.
 * Here we return the first definition found for simplicity.
 */

This comment exists from version 2.2_r1 (which is in linker.c) to newest version 5.0.2_r1

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