<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../../general.ent">
  %general-entities;
]>

<sect1 id="ch-system-adjusting">
  <?dbhtml filename="adjusting.html"?>

  <title>Adjusting the Toolchain</title>

  <para os="a">Now we amend the GCC specs file so that it points to the new
  dynamic linker. A <command>perl</command> command accomplishes this:</para>

<screen os="c"><userinput>gcc -dumpspecs | \
perl -p -e 's@/tools/lib/ld@/lib/ld@g;' \
     -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \
     $(dirname $(gcc --print-libgcc-file-name))/specs</userinput></screen>

  <para os="d">It is a good idea to visually inspect the specs file to verify the
  intended change was actually made.</para>

  <para os="e">Note that <filename class="directory">/lib</filename> is now
  the prefix of our dynamic linker.</para>

  <caution>

    <para os="f">It is imperative at this point to stop and ensure that
    the basic functions (compiling and linking) of the adjusted toolchain
    are working as expected. To do this, perform a sanity
    check:</para>

<screen os="g"><userinput>echo 'main(){}' &gt; dummy.c
cc dummy.c
readelf -l a.out | grep ': /lib'</userinput></screen>

    <para os="h">If everything is working correctly, there should be no errors,
    and the output of the last command will be:</para>

<screen os="i"><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen>

    <para os="j">Note that <filename class="directory">/lib</filename> is now
    the prefix of our dynamic linker.</para>

    <para os="k">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
    reason is that something went wrong with the specs file amendment
    above. Any issues will need to be resolved before continuing on with
    the process.</para>

    <para os="l">Once everything is working correctly, clean up the test
    files:</para>

<screen os="m"><userinput>rm -v dummy.c a.out</userinput></screen>

  </caution>

</sect1>
