dlopen on new binary with same name returns old handle

假如想象 提交于 2019-12-01 13:48:21

Most probly dlclose failed to unload the library. This usually happens when it contains GNU_UNIQUE symbols (which tend to sneak in if you link with static libstdc++). This can be verified via

$ readelf -sW --dyn-syms path/to/libxyz.so | grep '\bUNIQUE\b'
...
3808: 0000000000302e78     8 OBJECT  UNIQUE DEFAULT   27 _ZNSt8messagesIcE2idE@@GLIBCXX_3.4

To fix this, you can try one of the following:

  • build library with -fvisibility=hidden and __attribute__((visibility("default"))) to hide unique symbols
  • build with -Wl,--version-script to achieve the same
  • build shlib with toolchain that was configured with --disable-gnu-unique-object (see discussion in GCC list)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!