[lfs] branch trunk updated: Change stripping to use --strip-debug

"Git Owner" ([email protected] via lfs-book Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.book
Message-ID <174477645810.26200.12934808711985283996@rivendell.linuxfromscratch.org>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch trunk
in repository lfs.

The following commit(s) were added to refs/heads/trunk by this push:
     new 3d1e81b5a Change stripping to use --strip-debug
     new cc36837f7 Merge branch 'trunk' of git.linuxfromscratch.org:lfs into trunk
3d1e81b5a is described below

commit 3d1e81b5a8397464f2ef0f54fb22b810c03c24c2
Author: Bruce Dubbs <[email protected]>
AuthorDate: Tue Apr 15 22:53:28 2025 -0500

    Change stripping to use --strip-debug
    
    When we use -strip-unneeded it removes some symbols that are needed in static
    libraries that may be needed in addition to debugging symbols.  Changing the
    stripping to the more conservative --strip-debug retains thise symbols.
    
    In the case of libc.a the unstripped file size is 22.4 MB.  Using
    --strip-debug reduces the file size by 74 percent to 5.9 MB.
    
    Using --strip-unneeded only reduces the file further by 89 KB,
    so any gain is relatively trivial.
---
 chapter08/stripping.xml | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/chapter08/stripping.xml b/chapter08/stripping.xml
index 5ce0235d3..2839cfda7 100644
--- a/chapter08/stripping.xml
+++ b/chapter08/stripping.xml
@@ -24,10 +24,15 @@
   backup of the LFS system in its current state.</para>
 
   <para>A <command>strip</command> command with the
-  <parameter>--strip-unneeded</parameter> option removes all debug symbols
-  from a binary or library.  It also removes all symbol table entries not
+  <parameter>--strip-unneeded</parameter> option removes all debug symbols from
+  a binary or library.  It also removes all symbol table entries not normally
   needed by the linker (for static libraries) or dynamic linker (for
-  dynamically linked binaries and shared libraries).</para>
+  dynamically linked binaries and shared libraries). Using
+  <parameter>--strip-debug</parameter> does not remove symbol table entries
+  that may be needed by some applications.  The difference between "unneeded"
+  and "debug" is very small. For example, an unstripped libc.a is 22.4 MB.
+  After stripping with --strip-debug it is 5.9 MB.  Using --strip-unneeded only
+  reduces the size further to only 5.8 MB.</para>
 
   <!-- TODO: Zstd is better than Zlib for both speed and size.
              Unfortunately Valgrind does not support Zstd-compressed debug
@@ -83,7 +88,7 @@ cd /usr/lib
 for LIB in $save_usrlib; do
     objcopy --only-keep-debug --compress-debug-sections=zlib $LIB $LIB.dbg
     cp $LIB /tmp/$LIB
-    strip --strip-unneeded /tmp/$LIB
+    strip --strip-debug /tmp/$LIB
     objcopy --add-gnu-debuglink=$LIB.dbg /tmp/$LIB
     install -vm755 /tmp/$LIB /usr/lib
     rm /tmp/$LIB
@@ -102,14 +107,14 @@ online_usrlib="libbfd-&binutils-version;.so
 
 for BIN in $online_usrbin; do
     cp /usr/bin/$BIN /tmp/$BIN
-    strip --strip-unneeded /tmp/$BIN
+    strip --strip-debug /tmp/$BIN
     install -vm755 /tmp/$BIN /usr/bin
     rm /tmp/$BIN
 done
 
 for LIB in $online_usrlib; do
     cp /usr/lib/$LIB /tmp/$LIB
-    strip --strip-unneeded /tmp/$LIB
+    strip --strip-debug /tmp/$LIB
     install -vm755 /tmp/$LIB /usr/lib
     rm /tmp/$LIB
 done
@@ -120,7 +125,7 @@ for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \
     case "$online_usrbin $online_usrlib $save_usrlib" in
         *$(basename $i)* )
             ;;
-        * ) strip --strip-unneeded $i
+        * ) strip --strip-debug $i
             ;;
     esac
 done

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/lfs-book
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.