All other factors being equal (eg optimisation level), how does having debug symbols in an ELF or SO affect:
- Load time.
- Runtime memory footprint.
- Runtime performance?
And what could be done to mitigate any negative effects?
EDIT
I’ve seen this question but I find the discussion unhelpful, as the code optimization factor has confused the issue there. Why does my code run slower with multiple threads than with a single thread when it is compiled for profiling (-pg)?
The debug symbols are located in totally different sections from the code/data sections. You can check it with
objdump:You can see the extra sections (27 through 33). These sections won’t be loaded at runtime, so there won’t be any performance penalty. Using
gdb, you can also examine them at runtime:So the only penalty is that you need extra disk space to store this information. You can also use
stripto remove the debug information:Use
objdumpto check it again, you’ll see the difference.EDIT:
Instead of looking at sections, actually the loader loads elf file according to its
Program Header, which can be seen byobjdump -p(the following example uses using a different elf binary):The program headers tell which segment will be loaded with what
rwxflags; multiple sections with the same flags will be merged to a single segment.BTW:
The loader doesn’t care about sections when loading elf file, but it will look at several symbol-related sections to resolve symbols when needed.