Changeset de28837


Ignore:
Timestamp:
07/26/2021 11:34:27 AM (3 years ago)
Author:
Xi Ruoyao <xry111@…>
Branches:
11.0, 11.0-rc1, 11.0-rc2, 11.0-rc3, 11.1, 11.1-rc1, 11.2, 11.2-rc1, 11.3, 11.3-rc1, 12.0, 12.0-rc1, 12.1, 12.1-rc1, arm, bdubbs/gcc13, ml-11.0, multilib, renodr/libudev-from-systemd, s6-init, trunk, xry111/arm64, xry111/arm64-12.0, xry111/clfs-ng, xry111/lfs-next, xry111/loongarch, xry111/loongarch-12.0, xry111/loongarch-12.1, xry111/mips64el, xry111/pip3, xry111/rust-wip-20221008, xry111/update-glibc
Children:
6d6f242
Parents:
ff96923
Message:

Hopefully, complete strip workaround

In stripping, /usr/bin/bash, /usr/bin/find, and /usr/bin/strip are
running. Strip them, and all libraries used by them in /tmp, then
install them back.

We can't use this for all libraries or binaries: the process above
discouples hard links (for example /usr/bin/perl and perl5.34.0). So
unfortunately the stripping instruction is now a stupidly long bash
script...

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • chapter01/changelog.xml

    rff96923 rde28837  
    4848      <itemizedlist>
    4949        <listitem>
     50          <para>[xry111] - (Hopefully) complete stripping workaround.</para>
     51        </listitem>
     52      </itemizedlist>
     53    </listitem>
     54
     55    <listitem>
     56      <para>2021-07-25</para>
     57      <itemizedlist>
     58        <listitem>
    5059          <para>[bdubbs] - Add workaround to strip libraries
    5160          correctly.</para>
  • chapter08/pkgmgt.xml

    rff96923 rde28837  
    122122        deleted libraries.
    123123      </para></listitem>
     124
     125      <listitem>
     126        <para>If a binary or a shared library is overwrote, the processes
     127        using the code or data in the binary or library may crash.  The
     128        correct way to update a binary or a shared library without causing
     129        the process to crash is: remove it first, then install the new
     130        version into position. The <command>install</command> command
     131        provided by <application>Coreutils</application> has already
     132        implemented this and most packages use it to install binaries and
     133        libraries.  So you won't be troubled by this issue most of the time.
     134        However, the install process of some packages (notably Mozilla JS
     135        in BLFS) just overwrites the file if it exists and causes crash, so
     136        it's safer to save your work and close unneeded running processes
     137        before updating a package.</para>
     138      </listitem>
    124139    </itemizedlist>
    125140
  • chapter08/strippingagain.xml

    rff96923 rde28837  
    2424  backup of the LFS system in its current state.</para>
    2525
    26   <para>First place the debugging symbols for selected libraries
    27   in separate files.  This debugging information is needed if running
     26  <para>The debugging symbols for selected libraries are placed
     27  in separate files.  These debugging information is needed if running
    2828  regression tests that use <ulink
    2929  url='&blfs-book;/general/valgrind.html'>valgrind</ulink> or <ulink
     
    3131  </para>
    3232
     33  <para>And, <command>strip</command> will overwrite the binary or library
     34  file.  This may crash the processes using code or data from the file.  If
     35  the process running <command>strip</command> itself is affected, the
     36  binary or library being stripped may be destroyed.  This may make the
     37  system completely unusable.  To avoid it, we'll copy some libraries and
     38  binaries into <filename class="directory">/tmp</filename>, strip them
     39  there, and install them back with the <command>install</command> command.
     40  Read the related entry in <xref linkend="pkgmgmt-upgrade-issues"/> for the
     41  rationale to use the <command>install</command> command here.</para>
     42
    3343<!-- also of interest are libgfortan, libgo, libgomp, and libobjc from GCC -->
    3444
    3545<!--<screen><userinput>save_lib="ld-2.25.so libc-2.25.so libpthread-2.25.so libthread_db-1.0.so"-->
    3646<screen><userinput>save_usrlib="ld-&glibc-version;.so libc-&glibc-version;.so libpthread-&glibc-version;.so libthread_db-&libthread_db-version;.so
    37              libquadmath.so.&libquadmath-version; libstdc++.so.&libstdcpp-version; libz.so.&zlib-version;
     47             libquadmath.so.&libquadmath-version; libstdc++.so.&libstdcpp-version;
    3848             libitm.so.&libitm-version; libatomic.so.&libatomic-version;" <!-- libcilkrts.so.&libcilkrts-version;-->
    3949
     
    4959done
    5060
    51 unset LIB save_usrlib</userinput></screen>
     61online_usrbin="bash find strip"
     62online_usrlib="libbfd-&binutils-version;.so libdl-&glibc-version;.so
     63               libhistory.so.&readline-version; libncursesw.so.&ncurses-version;
     64               libm-&glibc-version;.so libreadline.so.&readline-version;
     65               libz.so.&zlib-version;"
    5266
    53 <!--  <para>Before performing the stripping, take special care to ensure that
    54   none of the binaries that are about to be stripped are running:</para>
     67for BIN in $online_usrbin; do
     68    cp /usr/bin/$BIN /tmp/$BIN
     69    strip --strip-all /tmp/$BIN
     70    install -vm755 /tmp/$BIN /usr/bin
     71    rm /tmp/$BIN
     72done
    5573
    56 <screen role="nodump"><userinput>exec /tools/bin/bash</userinput></screen>
    57  
    58   <para>Now the binaries and libraries can be safely stripped:</para>
    59 -->
    60   <para>Now the binaries and libraries can be stripped:</para>
    61 <screen><userinput>find /usr/lib -type f -name \*.a \
     74for LIB in $online_usrlib; do
     75    cp /usr/lib/$LIB /tmp/$LIB
     76    strip --strip-unneeded /tmp/$LIB
     77    install -vm755 /tmp/$LIB /usr/lib
     78    rm /tmp/$LIB
     79done
     80
     81find /usr/lib -type f -name \*.a \
    6282   -exec strip --strip-debug {} ';'
    6383
    64 find /usr/lib -type f -name \*.so* ! -name \*dbg ! -name libz.so* \
    65    -exec strip --strip-unneeded {} ';'
     84for i in $(find /usr/lib -type f -name \*.so* ! -name \*dbg); do
     85    case "$online_usrlib $save_usrlib" in
     86        *$(basename $i)* ) ;;
     87        * ) strip --strip-unneeded $i ;;
     88    esac
     89done
    6690
    67 find /usr/{bin,sbin,libexec} -type f \
    68     -exec strip --strip-all {} ';'</userinput></screen>
     91for i in $(find /usr/bin -type f); do
     92    case "$online_usrbin" in
     93        *$(basename $i)* ) ;;
     94        * ) strip --strip-all $i ;;
     95    esac
     96done
     97
     98find /usr/{sbin,libexec} -type f \
     99    -exec strip --strip-all {} ';'
     100
     101unset BIN LIB save_usrlib online_usrbin online_usrlib
     102</userinput></screen>
    69103
    70104  <para>A large number of files will be reported as having their file
Note: See TracChangeset for help on using the changeset viewer.