What changes does the -g flag actually make to the executable when added?
Asked
Active
Viewed 66 times
0
-
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 Answers
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
-
-
@StephenJacob: [Executable and Linkable Format](http://en.wikipedia.org/wiki/Executable_and_Linkable_Format). It is the binary format in some platforms including linux. – David Rodríguez - dribeas Aug 09 '13 at 03:06
-