Stripping linux shared libraries

前端 未结 6 1961
醉梦人生
醉梦人生 2020-12-12 18:00

We\'ve recently been asked to ship a Linux version of one of our libraries, previously we\'ve developed under Linux and shipped for Windows where deploying libraries is gene

6条回答
  •  温柔的废话
    2020-12-12 18:37

    In general, across multiple Linux and Unix systems, the answer here is that there is no answer here at link time. it's fairly fundamental to how ld.so works.

    This leads to some rather labor-intensive alternatives. For example, we rename STL to live in _STL instead of std to avoid conflicts over STL, and we use namespaces high, low, and in-between to keep our symbols away from possible conflicts with other people's symbols.

    Here's a solution you won't love:

    1. Create a small .so with only your exposed API it.
    2. Have it open the real implementation with dlopen, and link with dlsym.

    So long as you don't use RTLD_GLOBAL, you now have complete insulation if not particular secrecy .. -Bsymbolic might also be desirable.

提交回复
热议问题