0

What changes does the -g flag actually make to the executable when added?

Stephen Jacob
  • 889
  • 1
  • 15
  • 33
  • I think this question has been answered here [link](http://stackoverflow.com/questions/8422678/what-does-the-p-and-g-flag-in-compiler) – Lokesh A. R. Aug 08 '13 at 17:58

3 Answers3

1

Basically it includes more information about the source of your program that would otherwise be lost in the compilation process. This includes more symbol names, and the line numbers that pieces of machine code correspond to. See this reference for a bit more detail.

Troy
  • 1,599
  • 14
  • 28
1

The main change will be an increase in the size of the binary, as it will now hold extra debug information. Depending on the target you are building for, it might (or not) have any other effect during execution. For example when generating ELF, all debug information is maintained in a separate section that need not even be loaded into memory unless when running inside a debugger (so it will not require more actual memory to run even thought the binary is larger)

David Rodríguez - dribeas
  • 204,818
  • 23
  • 294
  • 489
0

Debugging informations are added to your executable. See this link.

Pierre T.
  • 380
  • 1
  • 13