aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06
diff options
context:
space:
mode:
Diffstat (limited to 'chapter06')
-rw-r--r--chapter06/chapter06.xml92
1 files changed, 88 insertions, 4 deletions
diff --git a/chapter06/chapter06.xml b/chapter06/chapter06.xml
index c64770b2a..287b94540 100644
--- a/chapter06/chapter06.xml
+++ b/chapter06/chapter06.xml
@@ -502,11 +502,98 @@ Most likely something went wrong with the specs file amendment above.</para>
&c6-gcc-2953;
+<sect1 id="ch-system-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 <command>gcc</command>'s <emphasis>-g</emphasis>
+option). This means that, 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>The inclusion of these debugging symbols, however, 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 somewhat, 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. For
+your convenience, the next section shows how to strip all debugging symbols
+from all programs and libraries. Information on other ways of optimizing your
+system can be found in the hint at <ulink
+url="&hints-root;optimization.txt"/>.</para>
+
+</sect1>
+
+
+<sect1 id="ch-system-strippingagain">
+<title>Stripping again</title>
+<?dbhtml filename="strippingagain.html" dir="chapter06"?>
+
+<para>If you are not a programmer and don't plan to do any debugging on your
+system software, you can shrink your system by about 200 MB by removing the
+debugging symbols from binaries and libraries. This causes no inconvenience
+other than not being able to debug the software fully any more.</para>
+
+<para>Most people who use the command mentioned below don't experience any
+problems. But it is easy to make a typo and render your new system unusable, so
+before running the strip command it is probably a good idea to make a backup of
+the current situation.</para>
+
+<para>If you are going to perform the stripping, special care is needed to
+ensure you're not running any of the binaries that are about to be stripped.
+If you're not sure whether you entered chroot with the command given in
+<xref linkend="ch-system-chroot"/>, then now exit from chroot and reenter it
+with the following commands:</para>
+
+<screen><userinput>logout; chroot $LFS /tools/bin/env -i \
+&nbsp;&nbsp;&nbsp;&nbsp;HOME=/root TERM=$TERM PS1='\u:\w\$ ' \
+&nbsp;&nbsp;&nbsp;&nbsp;PATH=/bin:/usr/bin:/sbin:/usr/sbin \
+&nbsp;&nbsp;&nbsp;&nbsp;/tools/bin/bash --login</userinput></screen>
+
+<para>Now you can safely strip the binaries and libraries:</para>
+
+<screen><userinput>/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \
+&nbsp;&nbsp;&nbsp;-exec /tools/bin/strip --strip-debug '{}' ';'</userinput></screen>
+
+<para>A large number of files will be reported as having their file format not
+recognized. These warnings can be safely ignored, they just mean that those
+files are scripts instead of binaries, no harm is done.</para>
+
+<para>If you are really tight on disk space, you may want to use
+<emphasis>--strip-all</emphasis> on the binaries in
+<filename>/{,usr/}{bin,sbin}</filename> to gain several more megabytes. But do
+<emphasis>not</emphasis> use this option on libraries: they would be
+destroyed.</para>
+
+</sect1>
+
+
<sect1 id="ch-system-revisedchroot">
<title>Revised chroot command</title>
<?dbhtml filename="revisedchroot.html" dir="chapter06"?>
-<para>From now on when you exit the chroot environment and wish to re-enter
+<para>From now on when you exit the chroot environment and wish to reenter
it, you should run the following modified chroot command:</para>
<screen><userinput>chroot $LFS /usr/bin/env -i \
@@ -521,8 +608,5 @@ just yet. There is still some use for it towards the end of the book.</para>
</sect1>
-
-&c6-aboutdebug;
-
</chapter>