对于so动态库及可执行文件,可以直接调用不带参数的strip (-s, 即--strip-all)去除大多数不必要的信息。因为so库非常标准,所以strip之后仍然可以进行完美的动态连接;而可执行文件已经进行了链接,所以也可以用strip进行完美的strip。

 

对于静态库和目标文件(.o文件),不能直接调用不带参数的strip,因为o文件大多数是relocate文件,如果去除的参数不恰当,在编译成so或可执行文件时就无法找到对应的符号。

 

对于a库,可以先采用编译优化 -O3,将某些不必要的信息进行掩盖或去除:

Use of the GCC optimization flags will help make the code look much less readable to a human. When you compile with the highest level of optimization gcc -O3 the compiler will move things around such that the "flow" might not be at all what you expect.

对于a库,还可以考虑使用这2个strip选项进行瘦身:

       -g
       -S
       -d
       --strip-debug
           Remove debugging symbols only.

       --strip-unneeded
           Remove all symbols that are not needed for relocation processing.

 

相关文章:

  • 2021-07-27
  • 2022-12-23
  • 2021-09-06
  • 2021-08-08
  • 2022-12-23
  • 2021-09-08
  • 2021-08-22
  • 2021-08-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案