| [bf8c11f] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?> | 
|---|
|  | 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" | 
|---|
|  | 3 | "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [ | 
|---|
|  | 4 | <!ENTITY % general-entities SYSTEM "../../general.ent"> | 
|---|
|  | 5 | %general-entities; | 
|---|
|  | 6 | ]> | 
|---|
|  | 7 |  | 
|---|
|  | 8 | <sect1 id="ch-system-adjusting"> | 
|---|
|  | 9 | <?dbhtml filename="adjusting.html"?> | 
|---|
|  | 10 |  | 
|---|
|  | 11 | <title>Adjusting the Toolchain</title> | 
|---|
|  | 12 |  | 
|---|
|  | 13 | <para os="a">Now we amend the GCC specs file so that it points to the new | 
|---|
|  | 14 | dynamic linker. A <command>perl</command> command accomplishes this:</para> | 
|---|
|  | 15 |  | 
|---|
|  | 16 | <screen os="c"><userinput>gcc -dumpspecs | \ | 
|---|
| [109c00d] | 17 | perl -p -e 's@/tools/lib/ld@/lib/ld@g;' \ | 
|---|
| [bf8c11f] | 18 | -e 's@\*startfile_prefix_spec:\n@$_/usr/lib/ @g;' > \ | 
|---|
| [b28b386d] | 19 | $(dirname $(gcc --print-libgcc-file-name))/specs</userinput></screen> | 
|---|
| [bf8c11f] | 20 |  | 
|---|
|  | 21 | <para os="d">It is a good idea to visually inspect the specs file to verify the | 
|---|
|  | 22 | intended change was actually made.</para> | 
|---|
|  | 23 |  | 
|---|
|  | 24 | <para os="e">Note that <filename class="directory">/lib</filename> is now | 
|---|
|  | 25 | the prefix of our dynamic linker.</para> | 
|---|
|  | 26 |  | 
|---|
|  | 27 | <caution> | 
|---|
|  | 28 |  | 
|---|
|  | 29 | <para os="f">It is imperative at this point to stop and ensure that | 
|---|
|  | 30 | the basic functions (compiling and linking) of the adjusted toolchain | 
|---|
|  | 31 | are working as expected. To do this, perform a sanity | 
|---|
|  | 32 | check:</para> | 
|---|
|  | 33 |  | 
|---|
|  | 34 | <screen os="g"><userinput>echo 'main(){}' > dummy.c | 
|---|
|  | 35 | cc dummy.c | 
|---|
|  | 36 | readelf -l a.out | grep ': /lib'</userinput></screen> | 
|---|
|  | 37 |  | 
|---|
|  | 38 | <para os="h">If everything is working correctly, there should be no errors, | 
|---|
|  | 39 | and the output of the last command will be:</para> | 
|---|
|  | 40 |  | 
|---|
|  | 41 | <screen os="i"><computeroutput>[Requesting program interpreter: /lib/ld-linux.so.2]</computeroutput></screen> | 
|---|
|  | 42 |  | 
|---|
|  | 43 | <para os="j">Note that <filename class="directory">/lib</filename> is now | 
|---|
|  | 44 | the prefix of our dynamic linker.</para> | 
|---|
|  | 45 |  | 
|---|
|  | 46 | <para os="k">If the output does not appear as shown above or is not received | 
|---|
|  | 47 | at all, then something is seriously wrong. Investigate and retrace the | 
|---|
|  | 48 | steps to find out where the problem is and correct it. The most likely | 
|---|
|  | 49 | reason is that something went wrong with the specs file amendment | 
|---|
|  | 50 | above. Any issues will need to be resolved before continuing on with | 
|---|
|  | 51 | the process.</para> | 
|---|
|  | 52 |  | 
|---|
|  | 53 | <para os="l">Once everything is working correctly, clean up the test | 
|---|
|  | 54 | files:</para> | 
|---|
|  | 55 |  | 
|---|
| [dd9906e] | 56 | <screen os="m"><userinput>rm -v dummy.c a.out</userinput></screen> | 
|---|
| [bf8c11f] | 57 |  | 
|---|
|  | 58 | </caution> | 
|---|
|  | 59 |  | 
|---|
|  | 60 | </sect1> | 
|---|