Post

how to reduce binary size

评估

使用bloaty针对最后交付的动态库或者是binary进行分析

常见的

1
2
3
4
5
6
7
8
9
10
armembers       the .o files in a .a file
compileunits    source file for the .o file (translation unit). requires debug info.
inputfiles      the filename specified on the Bloaty command-line
inlines         source line/file where inlined code came from.  requires debug info.
sections        object file section
segments        load commands in the binary
symbols         symbols from symbol table (configure demangling with --demangle)
rawsymbols      unmangled symbols
fullsymbols     full demangled symbols
shortsymbols    short demangled symbols 

一般都是要看那个文件大,然后去分析, 比如就看bloaty的话

1
2
3
4
./bloaty ./bloaty -d compileunits -n 0

    FILE SIZE        VM SIZE
 --------------  --------------

file size是文件大小,vm size是到虚拟内存的大小,会看到每个compile unit的大小,这样就能花更多的时间在具体文件的体积分析上

REF

  1. A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux
  2. Size optimizations
  3. How to make smaller C and C++ binaries
  4. Binary sizes and compiler flags
This post is licensed under CC BY 4.0 by the author.

Trending Tags