aboutdebug.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <sect1 id="ch06-aboutdebug">
  2. <title>About debugging symbols</title>
  3. <para>
  4. Most programs and libraries by default are compiled with debugging
  5. symbols and optimizing level 2 (gcc options -g and -O2) and are compiled
  6. for a specific CPU. On Intel platforms software is compiled for i386
  7. processors by default. If you don't wish to run software on other
  8. machines other than your own, you might want to change the default
  9. compiler options so that they will be compiled with a higher
  10. optimization level, no debugging symbols and generate code for your
  11. specific architecture. Let me first explain what debugging symbols
  12. are.
  13. </para>
  14. <para>
  15. A program compiled with debugging symbols means you can run a program or
  16. library through a debugger and the debugger's output will be user friendlier.
  17. These debugging symbols also enlarge the program or library significantly.
  18. </para>
  19. <para>
  20. To remove debugging symbols from a binary (must be an a.out or ELF binary)
  21. run <userinput>strip --strip-debug filename</userinput> You can use wild cards
  22. if you need to strip debugging symbols from multiple files (use something like
  23. strip --strip-debug $LFS/usr/bin/*). Another, easier, options is just
  24. not to compile programs with debugging symbols. Most people will probably
  25. never use a debugger on software, so by leaving those symbols out you
  26. can save a lot of diskspace.
  27. </para>
  28. <para>
  29. Before you wonder if these debugging symbols would make a big difference,
  30. here are some statistics:
  31. </para>
  32. <itemizedlist>
  33. <listitem><para>
  34. A dynamic Bash binary with debugging symbols: 1.2MB
  35. </para></listitem>
  36. <listitem><para>
  37. A dynamic Bash binary without debugging symbols: 478KB
  38. </para></listitem>
  39. <listitem><para>
  40. /lib and /usr/lib (glibc and gcc files) with debugging
  41. symbols: 87MB
  42. </para></listitem>
  43. <listitem><para>
  44. /lib and /usr/lib (glibc and gcc files) without
  45. debugging symbols: 16MB
  46. </para></listitem>
  47. </itemizedlist>
  48. <para>
  49. Sizes may vary depending on which compiler was used and which C library
  50. version was used to link dynamic programs against, but your results will be
  51. similar if you compare programs with and without debugging symbols. After
  52. I was done with this chapter and stripped all debugging symbols from all LFS
  53. binaries and libraries I regained a little over 102 MB of disk space. Quite
  54. the difference.
  55. </para>
  56. </sect1>