Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a downside to leaving in debug symbols in release builds?

I'm trying to determine whether there are any downsides to building release binaries with debug symbols left in. For our release builds, we compile with -O3 at the moment and if there are any crashes, the cores are next to useless.

So, what I would like to do is modify the build to leave in debug symbols, i.e. -O3 -g, but there is resistance to this as the feeling is that there could be some impact (aside from size of binary). I know that the size issue can be fixed by stripping out the symbols, but is there anything else subtle that I'm missing?

like image 774
Nim Avatar asked Apr 06 '11 16:04

Nim


People also ask

Do debug symbols affect performance?

Load time will be increased when the debug symbols are present over when not present. The on-disk footprint will be larger. If you compiled with zero optimization then you really lose nothing. If you set optimization, then the optimized code will be less optimized because of the debug symbols.

Is release with debug info slower?

A debug build of your code will add a lot (potentially) of extra debug information and mostly disables any optimizations. As such a debug build is always larger and slower than a release build. Debug builds should only be used for development.

How do I get rid of debug symbols?

To remove debugging symbols from a binary (which must be an a. out or ELF binary), run strip --strip-debug filename. Wildcards can be used to treat multiple files (use something like strip --strip-debug $LFS/tools/bin/*).

Are PDB files a security risk?

The inclusion of . PDB files in a web application's deployment is safe and doesn't include the risks associated with publishing a Debug build.


1 Answers

Separate symbols from binary.

g++ -ggdb -o target obj1.o obj2.o ...
strip target --only-keep-debug -o target.dbg
strip target

Then in gdb, use symbol-file target.dbg

EDIT: On the actual question:

The downsides are:

  • Easier reverse engineering (if that worries you)
  • Larger binaries

Execution speed is not affected - Debug symbols are simply added to the binary in a separate section, they may affect your virtual address space size but nothing else.

like image 64
Erik Avatar answered Oct 16 '22 07:10

Erik