Should the HAS_DEBUG flag appear in release g++ executable?

0

I'm a college student make some search in tips that increase the C++ performance.

And I was inspecting my "release" (compiler optimized) executable with the GCC tools. When I use the objdump, it displayed the file headers:

C:\Users\Nicobook\Uni\TCC\TCCII\Fontes\Códigos\teste>c:\MinGW32\bin\objdump.exe -f main.exe    
main.exe:     file format pei-i386
architecture: i386, flags 0x0000013a:
EXEC_P, HAS_DEBUG, HAS_SYMS, HAS_LOCALS, D_PAGED
start address 0x004014f0

There's a flag HAS_DEBUG, should it have? I'm measuring the runtime with optimizations enabled (I hope, see below in G++ flags), so I wanted the most optimized binary, but I think there's debug information on it. There is a way that I can remove the debug information?

I'm using MinGW32, G++ 4.8.1 and OBJDUMP 2.23.52. I use the following flags on G++:

C:\Users\Nicobook\Uni\TCC\TCCII\Fontes\Códigos\teste>c:\MinGW32\bin\g++.exe -O3 -Wall -Wextra -pedantic-errors -ansi --std=c++11 -o main.exe main.cpp

The main.cpp is a 'hello world' test program, not which I was measuring but with the same debug flag. Thanks in advance...

c++
mingw
compiler-optimization
objdump
asked on Stack Overflow Aug 22, 2014 by Nico Engels

1 Answer

0

To remove all the extraneous sections in the file you need to strip it. Just do strip main.exe to accomplish this.

Alternatively you can link your code with the -s flag, which accomplishes the same thing. If you're compiling from .cpp -> .exe directly (e.g. with your command line) then putting it into that command line will accomplish it.

answered on Stack Overflow Aug 22, 2014 by Petesh

User contributions licensed under CC BY-SA 3.0