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