The Protocol: Release binaries should not have debug information with them to prevent malicious users from reverse engineering the code.
Issues: When issue comes in field from customer it becomes difficult for the developer to crack the issue without proper debug symbols.
Resolution:
1. Generate distribution builds with debug information.
2. Separate the debug information from release builds and store them for future in a file.
3. Ship the stripped binary.
4. For external issues use the debug information separated earlier to debug the issue.
Windows (PDB)
With Visual Studio (Windows) its easy. VS provides the facility to create Program Database (PDB) files to store the debug information.
A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program. A PDB file is created when you compile a C/C++ program with /ZI or /Zi.
In Visual C++, the /Fd option names the PDB file created by the compiler.
Example:
cl.exe /Zi /Fd"Test.pdb" Test.cpp
Linux (objcopy)
In Linux objcopy command can be used to achieve the same results.
1. Generate distribution builds with debug information
Use compiler flag -g while building the libs and binaries.
2. Separate the debug information from release builds and store them for future in a file.
Run objcopy --only-keep-debug
3. Remove the symbol information from the executable
Run objcopy --strip-all test to create a stripped executable.
4. Creates a .gnu_debuglink section which contains a reference to debug file in executable
Run objcopy --add-gnu-debuglink=test.dbg test to add a link to the debugging info into the stripped executable.
No comments:
Post a Comment