aboutdebug.xml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 a user doesn't wish to run software on other
  8. machines other than his own, he 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 his
  11. specific architecture. Let me first explain what debugging symbols
  12. are.
  13. </para>
  14. <para>
  15. A program compiled with debugging symbols means a user 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>. A user can use wild
  22. cards
  23. if he needs to strip debugging symbols from multiple files (use something like
  24. strip --strip-debug $LFS/usr/bin/*). Another, easier, options is just
  25. not to compile programs with debugging symbols. Most people will probably
  26. never use a debugger on software, so by leaving those symbols out
  27. a lot of diskspace can be saved.
  28. </para>
  29. <para>
  30. Before someone wonders if these debugging symbols would make a big difference,
  31. here are some statistics:
  32. </para>
  33. <itemizedlist>
  34. <listitem><para>
  35. A dynamic Bash binary with debugging symbols: 1.2MB
  36. </para></listitem>
  37. <listitem><para>
  38. A dynamic Bash binary without debugging symbols: 478KB
  39. </para></listitem>
  40. <listitem><para>
  41. /lib and /usr/lib (glibc and gcc files) with debugging
  42. symbols: 87MB
  43. </para></listitem>
  44. <listitem><para>
  45. /lib and /usr/lib (glibc and gcc files) without
  46. debugging symbols: 16MB
  47. </para></listitem>
  48. </itemizedlist>
  49. <para>
  50. Sizes may vary depending on which compiler was used and which C library
  51. version was used to link dynamic programs against, but results will be
  52. similar if a user compares programs with and without debugging symbols. After
  53. I was done with this chapter and stripped all debugging symbols from all LFS
  54. binaries and libraries I regained a little over 102 MB of disk space. Quite
  55. the difference.
  56. </para>
  57. </sect1>