Re: Strip debugging information from MSVC EXE
<chrisstankevitz@gmail.com> wrote:
why would you make your profile build
use /debug? That'll just bloat up the executable with
unoptimized
code, and confuse the profiler.
That is incorrect. The /DEBUG flag does not control
optimizations.
The /DEBUG flag controls whether or not symbols are
included.
Actually, Nathan is right. Besides compiler optimization
there is linker optimization. /DEBUG flag disables following
linker optimizations (see /OPT for comprehensive list):
- functions and data that never referenced are not
removed by linker; everyhting is preserved in the resulting
image
- redundant COMDATs are not folded
This makes final executable bigger, as you noticed in your
other post.
Now, there are two compiler flags that cause debug info to
be embedded in .OBJ file:
- /Zd (store line numbers); this flag has been removed
from VC++2005
- /Z7 (store full debug info); this flag stores full
debug info in executable, no .PDB file is created
Default settings for VC++ project is /Zi (or /ZI), which
stores debug info in accompanying .PDB file.
If you built your program with /Z7 flag, then you can use
REBASE.EXE tool to strip debug info and put in separate
file. See here for more info:
KB258205 - "How To Use Rebase to Extract Symbols for
DrWtSn32.exe"
http://support.microsoft.com/kb/258205
However, linker documentation for VC++2005 states:
<quote>
It is not possible to create an .exe or .dll that contains
debug information. Debug information is always placed in a
..pdb file.
</quote>
So, probably newer linkers (after VC++6.0) won't store debug
info in the executable image no matter which compiler flag
was used.
HTH
Alex