From 3d1e81b5a8397464f2ef0f54fb22b810c03c24c2 Mon Sep 17 00:00:00 2001 From: Bruce Dubbs Date: Tue, 15 Apr 2025 22:53:28 -0500 Subject: [PATCH] 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. A strip command with the - --strip-unneeded option removes all debug symbols - from a binary or library. It also removes all symbol table entries not + --strip-unneeded 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). + dynamically linked binaries and shared libraries). Using + --strip-debug 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.