From 08f72423ce26a60982fb06fb4b34f800d2c8a3ad Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Wed, 28 Jul 2021 17:00:25 +0800 Subject: [PATCH] always use --strip-unneeded for stripping The behavior of --strip-unneeded and --strip-all are same for executables and shared libraries. For static libraries, --strip-unneeded keeps the symbols needed for relocation processing so it won't break static archives. --- chapter01/changelog.xml | 10 ++++++++++ chapter07/stripping.xml | 7 +------ chapter08/strippingagain.xml | 23 +++++------------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/chapter01/changelog.xml b/chapter01/changelog.xml index ab4b04b7e..c84ee042a 100644 --- a/chapter01/changelog.xml +++ b/chapter01/changelog.xml @@ -43,6 +43,16 @@ appropriate for the entry or if needed the entire day's listitem. --> + + 2021-07-27 + + + [xry111] - Always use --strip-unneeded for stripping. + + + + + 2021-07-27 diff --git a/chapter07/stripping.xml b/chapter07/stripping.xml index 99caf7e3c..22a5a0804 100644 --- a/chapter07/stripping.xml +++ b/chapter07/stripping.xml @@ -87,7 +87,7 @@ umount $LFS/{sys,proc,run} symbols. Strip off debugging symbols from binaries: -strip --strip-debug $LFS/usr/lib/* +strip --strip-unneeded $LFS/usr/lib/* strip --strip-unneeded $LFS/usr/{,s}bin/* strip --strip-unneeded $LFS/tools/bin/* @@ -97,11 +97,6 @@ strip --strip-unneeded $LFS/tools/bin/* Binutils pass 2, since it is the one that knows how to strip our cross-compiled programs.--> - Take care NOT to use - --strip-unneeded on the libraries. The static - ones would be destroyed and the toolchain packages would need to be - built all over again. - At this point, you should have at least 5 GB of free space on the chroot partition that can be used to build and install Glibc and GCC in the next phase. If you can build and install Glibc, you can build and install diff --git a/chapter08/strippingagain.xml b/chapter08/strippingagain.xml index ed690eb1a..f1eaa060d 100644 --- a/chapter08/strippingagain.xml +++ b/chapter08/strippingagain.xml @@ -67,7 +67,7 @@ online_usrlib="libbfd-&binutils-version;.so libdl-&glibc-version;.so for BIN in $online_usrbin; do cp /usr/bin/$BIN /tmp/$BIN - strip --strip-all /tmp/$BIN + strip --strip-unneeded /tmp/$BIN install -vm755 /tmp/$BIN /usr/bin rm /tmp/$BIN done @@ -79,11 +79,10 @@ for LIB in $online_usrlib; do rm /tmp/$LIB done -find /usr/lib -type f -name \*.a \ - -exec strip --strip-debug {} ';' - -for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg); do - case "$online_usrlib $save_usrlib" in +for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \ + $(find /usr/lib -type f -name \*.a) \ + $(find /usr/{bin,sbin,libexec} -type f); do + case "$online_usrbin $online_usrlib $save_usrlib" in *$(basename $i)* ) ;; * ) strip --strip-unneeded $i @@ -91,18 +90,6 @@ for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg); do esac done -for i in $(find /usr/bin -type f); do - case "$online_usrbin" in - *$(basename $i)* ) - ;; - * ) strip --strip-all $i - ;; - esac -done - -find /usr/{sbin,libexec} -type f \ - -exec strip --strip-all {} ';' - unset BIN LIB save_usrlib online_usrbin online_usrlib