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

前端 未结 2 836
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:54

    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

提交回复
热议问题