Stripping linux shared libraries

前端 未结 6 1962
醉梦人生
醉梦人生 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:54

    If you wrap up your private part in an anonymous namespace then neither std::abs nor private_function can be seen in the symbol table:

    namespace{
    #include
      float private_function(float f)
      {
        return std::abs(f);
      }
    }
    extern "C" float public_function(float f)
    {
            return private_function(f);
    }
    

    compiling (g++ 4.3.3):

    g++ -shared -o libtest.so test.cpp -s

    inspecting:

    # nm -DC libtest.so
             w _Jv_RegisterClasses
    0000200c A __bss_start
             w __cxa_finalize
             w __gmon_start__
    0000200c A _edata
    00002014 A _end
    000004a8 T _fini
    000002f4 T _init
    00000445 T public_function
    

提交回复
热议问题