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.
This commit is contained in:
Xi Ruoyao 2021-07-28 17:00:25 +08:00
parent 79902f4e51
commit 08f72423ce
No known key found for this signature in database
GPG Key ID: D95E4716CCBB34DC
3 changed files with 16 additions and 24 deletions

View File

@ -43,6 +43,16 @@
appropriate for the entry or if needed the entire day's listitem. appropriate for the entry or if needed the entire day's listitem.
--> -->
<listitem>
<para>2021-07-27</para>
<itemizedlist>
<listitem>
<para>[xry111] - Always use --strip-unneeded for stripping.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<listitem> <listitem>
<para>2021-07-27</para> <para>2021-07-27</para>
<itemizedlist> <itemizedlist>

View File

@ -87,7 +87,7 @@ umount $LFS/{sys,proc,run}</userinput></screen>
symbols.</para> symbols.</para>
<para>Strip off debugging symbols from binaries:</para> <para>Strip off debugging symbols from binaries:</para>
<screen role="nodump"><userinput>strip --strip-debug $LFS/usr/lib/* <screen role="nodump"><userinput>strip --strip-unneeded $LFS/usr/lib/*
strip --strip-unneeded $LFS/usr/{,s}bin/* strip --strip-unneeded $LFS/usr/{,s}bin/*
strip --strip-unneeded $LFS/tools/bin/*</userinput></screen> strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
@ -97,11 +97,6 @@ strip --strip-unneeded $LFS/tools/bin/*</userinput></screen>
<quote>Binutils pass 2</quote>, since it is the one that knows how to strip <quote>Binutils pass 2</quote>, since it is the one that knows how to strip
our cross-compiled programs.--></para> our cross-compiled programs.--></para>
<para>Take care <emphasis>NOT</emphasis> to use
<parameter>--strip-unneeded</parameter> on the libraries. The static
ones would be destroyed and the toolchain packages would need to be
built all over again.</para>
<para>At this point, you should have at least 5 GB of free space on the <para>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 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 the next phase. If you can build and install Glibc, you can build and install

View File

@ -67,7 +67,7 @@ online_usrlib="libbfd-&binutils-version;.so libdl-&glibc-version;.so
for BIN in $online_usrbin; do for BIN in $online_usrbin; do
cp /usr/bin/$BIN /tmp/$BIN cp /usr/bin/$BIN /tmp/$BIN
strip --strip-all /tmp/$BIN strip --strip-unneeded /tmp/$BIN
install -vm755 /tmp/$BIN /usr/bin install -vm755 /tmp/$BIN /usr/bin
rm /tmp/$BIN rm /tmp/$BIN
done done
@ -79,11 +79,10 @@ for LIB in $online_usrlib; do
rm /tmp/$LIB rm /tmp/$LIB
done done
find /usr/lib -type f -name \*.a \ for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg) \
-exec strip --strip-debug {} ';' $(find /usr/lib -type f -name \*.a) \
$(find /usr/{bin,sbin,libexec} -type f); do
for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg); do case "$online_usrbin $online_usrlib $save_usrlib" in
case "$online_usrlib $save_usrlib" in
*$(basename $i)* ) *$(basename $i)* )
;; ;;
* ) strip --strip-unneeded $i * ) strip --strip-unneeded $i
@ -91,18 +90,6 @@ for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg); do
esac esac
done 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 unset BIN LIB save_usrlib online_usrbin online_usrlib
</userinput></screen> </userinput></screen>