mirror of
https://git.linuxfromscratch.org/lfs.git
synced 2025-03-05 22:04:48 +00:00
Adjust chapter 5 binutils to build a static ld-new for use in the chapter 6 readjusting section.
Also add some extended sanity checks. These fixes are adapted from DIY-Linux and Greg Schafer. Thanks to Dan Nicholson for the report, as well. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@7308 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
This commit is contained in:
parent
40abfd5df2
commit
2914987be2
@ -43,6 +43,12 @@
|
||||
<para>[jhuntwork] - Modify chapter 6 Glibc's make install command to
|
||||
allow test-installation.pl to run.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>[jhuntwork] - Adjust chapter 5 binutils to build a static ld-new
|
||||
for use in the chapter 6 readjusting section. Also add some extended
|
||||
sanity checks. These fixes are adapted from DIY-Linux and Greg Schafer.
|
||||
Thanks to Dan Nicholson for the report, as well.
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</listitem>
|
||||
|
||||
|
@ -49,7 +49,7 @@ cd ../binutils-build</userinput></screen>
|
||||
<para>Prepare Binutils for compilation:</para>
|
||||
|
||||
<screen><userinput>../binutils-&binutils-version;/configure --prefix=/tools \
|
||||
--disable-nls --enable-shared --with-lib-path=/tools/lib</userinput></screen>
|
||||
--disable-nls --with-lib-path=/tools/lib</userinput></screen>
|
||||
|
||||
<variablelist>
|
||||
<title>The meaning of the new configure options:</title>
|
||||
@ -80,6 +80,13 @@ cd ../binutils-build</userinput></screen>
|
||||
|
||||
<para>Install the package:</para>
|
||||
|
||||
<para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in
|
||||
the next chapter:</para>
|
||||
|
||||
<screen><userinput>make -C ld clean
|
||||
make -C ld LDFLAGS="-s" LIB_PATH=/usr/lib:/lib
|
||||
cp -v ld/ld-new /tools/bin</userinput></screen>
|
||||
|
||||
<screen><userinput>make install</userinput></screen>
|
||||
|
||||
</sect2>
|
||||
|
@ -19,12 +19,17 @@ be guided from that same <filename class="directory">/tools/lib</filename>
|
||||
directory to the LFS <filename class="directory">/{,usr/}lib</filename>
|
||||
directories.</para>
|
||||
|
||||
<para>First, amend the GCC specs file so that it points to the new
|
||||
<para>First, create a symlink to the adjusted linker we created in chapter 5.</para>
|
||||
|
||||
<screen><userinput>ln -sv /tools/bin/ld-new /usr/bin/ld</userinput></screen>
|
||||
|
||||
<para>Next, amend the GCC specs file so that it points to the new
|
||||
dynamic linker. A <command>sed</command> command accomplishes this:</para>
|
||||
|
||||
<screen><userinput>SPECFILE=`dirname $(gcc -print-libgcc-file-name)`/specs &&
|
||||
gcc -dumpspecs > $SPECFILE &&
|
||||
sed -i 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE &&
|
||||
sed -i -e '/^\*link:$/{n;s,$, -L/usr/lib,}' \
|
||||
-e 's@^/tools/lib/ld-linux.so.2@/lib/ld-linux.so.2@g' $SPECFILE &&
|
||||
unset SPECFILE</userinput></screen>
|
||||
|
||||
<para>It is a good idea to visually inspect the specs file to verify the intended
|
||||
@ -38,20 +43,16 @@ dynamic linker in the above commands. Refer back to <xref
|
||||
linkend="ch-tools-toolchaintechnotes" role=","/> if
|
||||
necessary.</para></important>
|
||||
|
||||
<para>Now create temporary wrapper scripts for <filename>gcc</filename> and
|
||||
<filename>ld</filename>. These scripts will point to their real counterparts
|
||||
<para>Now create a temporary wrapper script for <filename>gcc</filename>.
|
||||
This script will point to the real <filename>gcc</filename>
|
||||
in <filename class="directory">/tools</filename> but with adjusted parameters
|
||||
to ensure that GCC in the next section links to our newly installed Glibc.</para>
|
||||
|
||||
<screen><userinput>cat > /usr/bin/gcc << "EOF"
|
||||
#!/bin/bash
|
||||
/tools/bin/gcc -B/usr/lib $@
|
||||
/tools/bin/gcc -B/usr/lib/ -B/usr/bin/ $@
|
||||
EOF
|
||||
cat > /usr/bin/ld << "EOF"
|
||||
#!/bin/bash
|
||||
/tools/bin/ld -nostdlib -L/usr/lib -L/lib $@
|
||||
EOF
|
||||
chmod 755 /usr/bin/{ld,gcc}
|
||||
chmod 755 /usr/bin/gcc
|
||||
ln -s gcc /usr/bin/cc</userinput></screen>
|
||||
|
||||
<caution><para>It is imperative at this point to stop and ensure that
|
||||
@ -60,7 +61,7 @@ are working as expected. To do this, perform a sanity
|
||||
check:</para>
|
||||
|
||||
<screen><userinput>echo 'main(){}' > dummy.c
|
||||
cc dummy.c
|
||||
cc dummy.c -Wl,--verbose &> dummy.log
|
||||
readelf -l a.out | grep ': /lib'</userinput></screen>
|
||||
|
||||
<para>If everything is working correctly, there should be no errors,
|
||||
@ -72,6 +73,36 @@ platform-specific differences in dynamic linker name):</para>
|
||||
<para>Note that <filename class="directory">/lib</filename> is now
|
||||
the prefix of our dynamic linker.</para>
|
||||
|
||||
<para>Now make sure that we're setup to use the correct start files:</para>
|
||||
|
||||
<screen><userinput>grep "/usr/lib/crt.* " dummy.log</userinput></screen>
|
||||
|
||||
<para>If everything is working correctly, there should be no errors,
|
||||
and the output of the last command will be:</para>
|
||||
|
||||
<screen><computeroutput>attempt to open /usr/lib/crt1.o succeeded
|
||||
attempt to open /usr/lib/crti.o succeeded
|
||||
attempt to open /usr/lib/crtn.o succeeded</computeroutput></screen>
|
||||
|
||||
<para>Next make sure that we're using the correct libc:</para>
|
||||
|
||||
<screen><userinput>grep "/lib/libc.so.6 " dummy.log</userinput></screen>
|
||||
|
||||
<para>If everything is working correctly, there should be no errors,
|
||||
and the output of the last command will be:</para>
|
||||
|
||||
<screen><computeroutput>attempt to open /lib/libc.so.6 succeeded</computeroutput></screen>
|
||||
|
||||
<para>Lastly, make sure GCC is using the correct dynamic linker:</para>
|
||||
|
||||
<screen><userinput>grep found dummy.log</userinput></screen>
|
||||
|
||||
<para>If everything is working correctly, there should be no errors,
|
||||
and the output of the last command will be (allowing for
|
||||
platform-specific differences in dynamic linker name):</para>
|
||||
|
||||
<screen><computeroutput>found ld-linux.so.2 at /lib/ld-linux.so.2</computeroutput></screen>
|
||||
|
||||
<para>If the output does not appear as shown above or is not received
|
||||
at all, then something is seriously wrong. Investigate and retrace the
|
||||
steps to find out where the problem is and correct it. The most likely
|
||||
@ -82,7 +113,7 @@ the process.</para>
|
||||
<para>Once everything is working correctly, clean up the test
|
||||
files:</para>
|
||||
|
||||
<screen><userinput>rm -v dummy.c a.out</userinput></screen></caution>
|
||||
<screen><userinput>rm -v dummy.c a.out dummy.log</userinput></screen></caution>
|
||||
|
||||
</sect1>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user