LDP/LDP/retired/LFS/chapter06/aboutdebug.xml

51 lines
1.9 KiB
XML

<sect1 id="ch06-aboutdebug">
<title>About debugging symbols</title>
<?dbhtml filename="aboutdebug.html" dir="chapter06"?>
<para>Most programs and libraries are, by default, compiled with debugging
symbols included (with gcc option -g).</para>
<para>When debugging a program or library that was compiled with debugging
information included, the debugger can give you not only memory addresses
but also the names of the routines and variables.</para>
<para>But the inclusion of these debugging symbols enlarges a program or
library significantly. To get an idea of the amount of space these symbols
occupy, have a look at the following:</para>
<itemizedlist>
<listitem><para>a bash binary
with debugging symbols: 1200 KB</para></listitem>
<listitem><para>a bash binary
without debugging symbols: 480 KB</para></listitem>
<listitem><para>Glibc and GCC files (/lib and /usr/lib)
with debugging symbols: 87 MB</para></listitem>
<listitem><para>Glibc and GCC files
without debugging symbols: 16 MB</para></listitem>
</itemizedlist>
<para>Sizes may vary a little, depending on which compiler was used and
which C library. But when comparing programs with and without debugging
symbols, the difference will generally be a factor between 2 and 5.</para>
<para>As most people will probably never use a debugger on their system
software, a lot of disk space can be regained by removing these symbols .</para>
<para>To remove debugging symbols from a binary (which must be an a.out
or ELF binary), run <userinput>strip --strip-debug filename</userinput>.
Wildcards can be used to treat multiple files (use something like
<userinput>strip --strip-debug $LFS/tools/bin/*</userinput>).</para>
<para>For your convenience, <xref linkend="chapter09"/> includes one simple
command to strip all debugging symbols from all programs and libraries on your
system. Additional information on optimization can be found in the hint at
<ulink url="&hints-root;optimization.txt"/>.</para>
</sect1>