Search code examples
c++gnu

Changes -g flag in GNU compiler makes in executable for c++


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


Solution

  • 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)