google / bloaty

Bloaty: a size profiler for binaries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What can add a lot of debug info in binaries?

paulocoutinhox opened this issue · comments

Hey guys,

How are you?

I have a project called ezored (github.com/ezored/ezored) and when i build a simple file in debug mode it add a lof of data that i see with bloaty tool. But this informations was added recently and i don't know what i changed in my cmake that add it to the compiled binaries:

This is from my private project that use ezored with some plus of c++ code only:

  41.6%  32.5Mi   0.0%       0    [section .debug_info]
  22.0%  17.2Mi   0.0%       0    [section .symtab]
   9.0%  7.00Mi   0.0%       0    [section .debug_line]
   6.8%  5.34Mi   0.0%       0    [section .debug_str]
   4.0%  3.14Mi   0.0%       0    [section .debug_frame]
   1.2%   985Ki   0.0%       0    [section .debug_ranges]
   1.2%   958Ki   0.0%       0    [section .debug_abbrev]
   0.5%   401Ki   0.0%       0    [section .debug_loc]
   0.4%   355Ki   4.8%   355Ki    [section .rodata]
   0.2%   194Ki   2.6%   194Ki    [section .ARM.extab]

More than 70% of the final binary has debug info.

And this is the original ezored data:

    FILE SIZE        VM SIZE    
 --------------  -------------- 
  27.2%  6.13Mi   0.0%       0    [section .debug_info]
  14.8%  3.33Mi   0.0%       0    [section .symtab]
  11.5%  2.59Mi   0.0%       0    [section .debug_str]
  10.8%  2.43Mi   0.0%       0    [section .debug_line]
   3.2%   742Ki   0.0%       0    [section .debug_frame]
   1.5%   353Ki   0.0%       0    [section .debug_loc]
   1.2%   285Ki   0.0%       0    [section .debug_abbrev]
   0.9%   205Ki   0.0%       0    [section .debug_ranges]
   0.8%   178Ki   3.7%   178Ki    [section .rodata]
   0.5%   116Ki   2.4%   116Ki    [section .rel.dyn]
   0.3%  79.3Ki   1.6%  79.3Ki    [section .gnu.hash]
   0.3%  77.3Ki   1.6%  77.3Ki    [section .ARM.extab]
   0.3%  75.2Ki   1.6%  75.2Ki    [section .plt]
   0.3%  72.1Ki   1.5%  72.1Ki    [section .hash]
   0.3%  64.5Ki   1.3%  64.5Ki    [section .ARM.exidx]

The first data are my other library that is a copy of ezored project, but with more c++ code but other things are the same.

What i can do wrong that add a lot of debug data more than the normal?

Thanks for any help.

Debug information tends to be bulk of the binary in general, particularly so for C++ code. You can always strip the binary with strip -g to remove the debug sections or you can use fission (-fsplit-debug). There isn't support for handling the fission enabled builds if you want to use the debug information, so it might be best to just perform the split post analysis and assume that anything reported as being debug info will be removed.

The symbol table (.symtab) however is a different story, as that will not get stripped by strip -g.