From b1575581743d136f81bb3c06aae38a6a556bef1f Mon Sep 17 00:00:00 2001 From: Alex Gronenwoud Date: Sun, 22 Feb 2004 22:32:27 +0000 Subject: Moving the final strip from the last chapter to the end of chapter 6. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3258 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/chapter06.xml | 92 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 88 insertions(+), 4 deletions(-) (limited to 'chapter06') 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. &c6-gcc-2953; + +About debugging symbols + + +Most programs and libraries are, by default, compiled with debugging +symbols included (with gcc's -g +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. + +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: + + + +a bash binary +with debugging symbols: 1200 KB + +a bash binary +without debugging symbols: 480 KB + +Glibc and GCC files (/lib and /usr/lib) +with debugging symbols: 87 MB + +Glibc and GCC files +without debugging symbols: 16 MB + + + +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. + +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 . + + + + + +Stripping again + + +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. + +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. + +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 +, then now exit from chroot and reenter it +with the following commands: + +logout; chroot $LFS /tools/bin/env -i \ +    HOME=/root TERM=$TERM PS1='\u:\w\$ ' \ +    PATH=/bin:/usr/bin:/sbin:/usr/sbin \ +    /tools/bin/bash --login + +Now you can safely strip the binaries and libraries: + +/tools/bin/find /{,usr/}{bin,lib,sbin} -type f \ +   -exec /tools/bin/strip --strip-debug '{}' ';' + +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. + +If you are really tight on disk space, you may want to use +--strip-all on the binaries in +/{,usr/}{bin,sbin} to gain several more megabytes. But do +not use this option on libraries: they would be +destroyed. + + + + Revised chroot command -From now on when you exit the chroot environment and wish to re-enter +From now on when you exit the chroot environment and wish to reenter it, you should run the following modified chroot command: 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. - -&c6-aboutdebug; - -- cgit v1.2.3-54-g00ecf